powertop: pull down latest version from Gentoo

Upgraded sys-power/powertop to version 2.0 on amd64, arm, x86

This one fixes building with gcc-4.7.

BUG=None
TEST=`emerge-amd64-generic powertop` worked
TEST=`emerge-arm-generic powertop` worked
TEST=`emerge-x86-generic powertop` worked

Change-Id: I5abdb5e03b822efe8757e80bb9c4dbf3526d72ab
Reviewed-on: https://gerrit.chromium.org/gerrit/24311
Reviewed-by: Han Shen <shenhan@google.com>
Reviewed-by: Han Shen <shenhan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/metadata/md5-cache/sys-power/powertop-1.98 b/metadata/md5-cache/sys-power/powertop-1.98
deleted file mode 100644
index ced9b7c..0000000
--- a/metadata/md5-cache/sys-power/powertop-1.98
+++ /dev/null
@@ -1,13 +0,0 @@
-DEFINED_PHASES=configure install postinst prepare
-DEPEND=dev-libs/libnl sys-apps/pciutils sys-devel/gettext sys-libs/ncurses[unicode?] sys-libs/zlib
-DESCRIPTION=tool that helps you find what software is using the most power
-EAPI=4
-HOMEPAGE=http://www.lesswatts.org/projects/powertop/
-IUSE=unicode
-KEYWORDS=~amd64 ~x86 ~amd64-linux ~x86-linux
-LICENSE=GPL-2
-RDEPEND=dev-libs/libnl sys-apps/pciutils sys-devel/gettext sys-libs/ncurses[unicode?] sys-libs/zlib net-wireless/bluez x11-apps/xset
-SLOT=0
-SRC_URI=mirror://kernel/linux/status/powertop/powertop-1.98.tar.bz2
-_eclasses_=eutils	33ef77a15337022e05342d2c772a7a5a	multilib	5f4ad6cf85e365e8f0c6050ddd21659e	portability	0be430f759a631e692678ed796e09f5c	toolchain-funcs	6526ac6fc9aedf391efb91fcd75ace68	user	9e552f935106ff0bc92af16da64b4b29
-_md5_=edef0ec9ad00313b1743e3d28663fe6f
diff --git a/metadata/md5-cache/sys-power/powertop-2.0 b/metadata/md5-cache/sys-power/powertop-2.0
new file mode 100644
index 0000000..c4c4ed2
--- /dev/null
+++ b/metadata/md5-cache/sys-power/powertop-2.0
@@ -0,0 +1,13 @@
+DEFINED_PHASES=configure install postinst
+DEPEND=dev-libs/libnl sys-apps/pciutils sys-devel/gettext sys-libs/ncurses[unicode?] sys-libs/zlib
+DESCRIPTION=tool that helps you find what software is using the most power
+EAPI=4
+HOMEPAGE=https://01.org/powertop/ http://www.lesswatts.org/projects/powertop/
+IUSE=unicode
+KEYWORDS=amd64 x86 ~amd64-linux ~x86-linux
+LICENSE=GPL-2
+RDEPEND=dev-libs/libnl sys-apps/pciutils sys-devel/gettext sys-libs/ncurses[unicode?] sys-libs/zlib x11-apps/xset
+SLOT=0
+SRC_URI=https://01.org/powertop/sites/default/files/downloads/powertop-2.0.tar.bz2
+_eclasses_=eutils	33ef77a15337022e05342d2c772a7a5a	multilib	5f4ad6cf85e365e8f0c6050ddd21659e	portability	0be430f759a631e692678ed796e09f5c	toolchain-funcs	6526ac6fc9aedf391efb91fcd75ace68	user	9e552f935106ff0bc92af16da64b4b29
+_md5_=dd1770127f5bc0be3572b3a702c0365c
diff --git a/sys-power/powertop/Manifest b/sys-power/powertop/Manifest
index 50be922..39d9cd8 100644
--- a/sys-power/powertop/Manifest
+++ b/sys-power/powertop/Manifest
@@ -1 +1 @@
-DIST powertop-1.98.tar.bz2 88110 RMD160 ebbd0867aba4d2a72584e19e3ab55c50cd82911c SHA1 15c082c0ed9134b07124d90f23d4518da6d8b781 SHA256 078b2d05a467ae83a6ee567d11ed7f80b917a3e2ad9d9de0e4b9facd857353f4
+DIST powertop-2.0.tar.bz2 456654 RMD160 d2c657fac6b1c0b430099d60fe8ee80e3d379e57 SHA1 ec64a472a4e1539d6dfc9725f6d934e908d5930c SHA256 7af51d320856b3446bcc314c9414385f3b05b9360f650883b0210cd3b12c5c1c
diff --git a/sys-power/powertop/files/csstoh b/sys-power/powertop/files/csstoh
new file mode 100644
index 0000000..51d1ec1
--- /dev/null
+++ b/sys-power/powertop/files/csstoh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+in=$1
+out=$2
+
+(
+cat <<EOF
+#ifndef __INCLUDE_GUARD_CCS_H
+#define __INCLUDE_GUARD_CCS_H
+
+const char css[] =
+EOF
+sed -e 's:^:\t":' -e 's:$:\\n":' "${in}"
+cat <<EOF
+;
+#endif
+EOF
+) > "${out}"
diff --git a/sys-power/powertop/files/powertop-1.98-build-libnl-3.patch b/sys-power/powertop/files/powertop-1.98-build-libnl-3.patch
new file mode 100644
index 0000000..bbe2b1c
--- /dev/null
+++ b/sys-power/powertop/files/powertop-1.98-build-libnl-3.patch
@@ -0,0 +1,27 @@
+From 21dcbd03507632c987e8c68b3efcf7b4a5d51147 Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Wed, 18 Apr 2012 21:11:22 -0400
+Subject: [PATCH] use right libnl pkg-config name
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ Makefile |    3 +--
+ 1 files changed, 1 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 94ed2be..8a90b85 100644
+--- a/Makefile
++++ b/Makefile
+@@ -39,8 +39,7 @@ endif
+ 
+ ifeq ($(NL3FOUND),Y)
+ CPPFLAGS += -DCONFIG_LIBNL20
+-LIBS += -lnl-genl
+-NLLIBNAME = libnl-3.0
++NLLIBNAME = libnl-genl-3.0
+ endif
+ 
+ ifeq ($(NLLIBNAME),)
+-- 
+1.7.8.5
+
diff --git a/sys-power/powertop/files/powertop-1.98-build.patch b/sys-power/powertop/files/powertop-1.98-build.patch
index cebb09f..8f130fd 100644
--- a/sys-power/powertop/files/powertop-1.98-build.patch
+++ b/sys-power/powertop/files/powertop-1.98-build.patch
@@ -1,26 +1,80 @@
-From f60a30a247fd1bfdd58de42934937a861e4b927a Mon Sep 17 00:00:00 2001
+From cafa47147fdc503103cda1e67e736ab95051e44a Mon Sep 17 00:00:00 2001
 From: Mike Frysinger <vapier@gentoo.org>
 Date: Tue, 23 Aug 2011 18:01:36 -0400
-Subject: [PATCH] use CFLAGS/LDFLAGS when linking
+Subject: [PATCH] use right flag names
+
+CFLAGS for the C compiler, CXXFLAGS for the C++ compiler, and
+CPPFLAGS for preprocessor flags.
 
 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
 ---
- Makefile |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
+ Makefile |   20 ++++++++++++--------
+ 1 files changed, 12 insertions(+), 8 deletions(-)
 
 diff --git a/Makefile b/Makefile
-index b0b6cb7..f637bfe 100644
+index b0b6cb7..bf9b79a 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -70,7 +70,7 @@ clean:
+@@ -2,9 +2,13 @@ all: powertop  po/powertop.pot
+ 
+ VERSION := 1.98
+ 
+-CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat -D_FORTIFY_SOURCE=2
+-CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer
+-CXXFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat -D_FORTIFY_SOURCE=2
++WFLAGS = -Wall -Wshadow -Wformat
++COMMON_FLAGS = -O2 -g -fno-omit-frame-pointer -fstack-protector
++CFLAGS ?= $(COMMON_FLAGS)
++CFLAGS += $(WFLAGS)
++CXXFLAGS ?= $(COMMON_FLAGS)
++CXXFLAGS += $(WFLAGS)
++CPPFLAGS += -D_FORTIFY_SOURCE=2
+ PKG_CONFIG ?= pkg-config
+ 
+ OBJS := lib.o main.o display.o html.o devlist.o
+@@ -31,13 +35,13 @@ NLLIBNAME = libnl-1
+ endif
+ 
+ ifeq ($(NL2FOUND),Y)
+-CFLAGS += -DCONFIG_LIBNL20
++CPPFLAGS += -DCONFIG_LIBNL20
+ LIBS += -lnl-genl
+ NLLIBNAME = libnl-2.0
+ endif
+ 
+ ifeq ($(NL3FOUND),Y)
+-CFLAGS += -DCONFIG_LIBNL20
++CPPFLAGS += -DCONFIG_LIBNL20
+ LIBS += -lnl-genl
+ NLLIBNAME = libnl-3.0
+ endif
+@@ -47,7 +51,7 @@ $(error Cannot find development files for any supported version of libnl)
+ endif
+ 
+ LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
+-CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
++CPPFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
+ 
+ 
+ 
+@@ -70,7 +74,7 @@ clean:
  	rm -f *.o *~ powertop DEADJOE core.* */*.o */*~ csstoh css.h
  	
  powertop: $(OBJS) $(HEADERS)
 -	$(CXX) $(OBJS) $(LIBS) -o powertop
-+	$(CXX) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o powertop
++	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o powertop
  	@(cd po/ && $(MAKE))
  	
  install: powertop
+@@ -90,7 +94,7 @@ css.h: csstoh powertop.css
+ %.o: %.cpp lib.h css.h Makefile
+ 	@echo "  CC  $<"
+ 	@[ -x /usr/bin/cppcheck ] && /usr/bin/cppcheck -q $< || :
+-	@$(CC) $(CFLAGS) -c -o $@ $<
++	@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
+ 
+ 
+ uptrans:
 -- 
-1.7.6
+1.7.8.5
 
diff --git a/sys-power/powertop/files/powertop-1.98-gcc-4.7.patch b/sys-power/powertop/files/powertop-1.98-gcc-4.7.patch
new file mode 100644
index 0000000..78d2d70
--- /dev/null
+++ b/sys-power/powertop/files/powertop-1.98-gcc-4.7.patch
@@ -0,0 +1,151 @@
+From b86877fb2f24563d74cd3faf7eceffcc8fa59299 Mon Sep 17 00:00:00 2001
+From: Han Shen <shenhan@chromium.org>
+Date: Thu, 19 Apr 2012 12:14:08 -0400
+Subject: [PATCH] include unistd.h when necessary
+
+Older versions of gcc (pre-4.7) would implicitly include unistd.h in some
+of its internal headers.  With newer versions though, that is no longer
+the case, so building powertop breaks with files that use things from the
+unistd.h header but don't include it explicitly.
+
+Signed-off-by: Han Shen <shenhan@chromium.org>
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ cpu/intel_cpus.cpp         |    1 +
+ devices/alsa.cpp           |    2 +-
+ devices/device.cpp         |    1 +
+ devices/i915-gpu.cpp       |    2 +-
+ devices/network.cpp        |    1 +
+ devices/rfkill.cpp         |    2 +-
+ devices/thinkpad-fan.cpp   |    1 +
+ devices/thinkpad-light.cpp |    1 +
+ html.cpp                   |    1 +
+ main.cpp                   |    1 +
+ 10 files changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/cpu/intel_cpus.cpp b/cpu/intel_cpus.cpp
+index f42f3b4..bbbd460 100644
+--- a/cpu/intel_cpus.cpp
++++ b/cpu/intel_cpus.cpp
+@@ -34,6 +34,7 @@
+ #include <sys/time.h>
+ #include <string.h>
+ #include <errno.h>
++#include <unistd.h>
+ 
+ #include "../lib.h"
+ #include "../parameters/parameters.h"
+diff --git a/devices/alsa.cpp b/devices/alsa.cpp
+index b0bcd3f..5100c36 100644
+--- a/devices/alsa.cpp
++++ b/devices/alsa.cpp
+@@ -39,7 +39,7 @@ using namespace std;
+ #include "../devlist.h"
+ 
+ #include <string.h>
+-
++#include <unistd.h>
+ 
+ alsa::alsa(char *_name, char *path): device()
+ {
+diff --git a/devices/device.cpp b/devices/device.cpp
+index c38b96c..9ce4509 100644
+--- a/devices/device.cpp
++++ b/devices/device.cpp
+@@ -29,6 +29,7 @@
+ #include <stdio.h>
+ #include <limits.h>
+ #include <stdlib.h>
++#include <unistd.h>
+ 
+ using namespace std;
+ 
+diff --git a/devices/i915-gpu.cpp b/devices/i915-gpu.cpp
+index a9dc899..ca2dad1 100644
+--- a/devices/i915-gpu.cpp
++++ b/devices/i915-gpu.cpp
+@@ -28,7 +28,7 @@
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <dirent.h>
+-
++#include <unistd.h>
+ 
+ using namespace std;
+ 
+diff --git a/devices/network.cpp b/devices/network.cpp
+index 5f3ddf2..72c766d 100644
+--- a/devices/network.cpp
++++ b/devices/network.cpp
+@@ -33,6 +33,7 @@
+ #include <dirent.h>
+ #include <libgen.h>
+ #include <stdlib.h>
++#include <unistd.h>
+ 
+ #include <linux/ethtool.h>
+ 
+diff --git a/devices/rfkill.cpp b/devices/rfkill.cpp
+index 5bf40c4..33a8fcd 100644
+--- a/devices/rfkill.cpp
++++ b/devices/rfkill.cpp
+@@ -29,7 +29,7 @@
+ #include <sys/types.h>
+ #include <dirent.h>
+ #include <libgen.h>
+-
++#include <unistd.h>
+ 
+ using namespace std;
+ 
+diff --git a/devices/thinkpad-fan.cpp b/devices/thinkpad-fan.cpp
+index 4ac3d11..8750c6e 100644
+--- a/devices/thinkpad-fan.cpp
++++ b/devices/thinkpad-fan.cpp
+@@ -29,6 +29,7 @@
+ #include <sys/types.h>
+ #include <dirent.h>
+ #include <math.h>
++#include <unistd.h>
+ 
+ #include "../lib.h"
+ 
+diff --git a/devices/thinkpad-light.cpp b/devices/thinkpad-light.cpp
+index ba4c553..7e91637 100644
+--- a/devices/thinkpad-light.cpp
++++ b/devices/thinkpad-light.cpp
+@@ -29,6 +29,7 @@
+ #include <sys/types.h>
+ #include <dirent.h>
+ #include <math.h>
++#include <unistd.h>
+ 
+ #include "../lib.h"
+ 
+diff --git a/html.cpp b/html.cpp
+index 0a4db2e..8260ed5 100644
+--- a/html.cpp
++++ b/html.cpp
+@@ -29,6 +29,7 @@
+ #include <utility>
+ #include <iostream>
+ #include <fstream>
++#include <unistd.h>
+ 
+ #include "css.h"
+ #include "lib.h"
+diff --git a/main.cpp b/main.cpp
+index 45a126e..0bbb4aa 100644
+--- a/main.cpp
++++ b/main.cpp
+@@ -33,6 +33,7 @@
+ #include <time.h>
+ #include <sys/stat.h>
+ #include <getopt.h>
++#include <unistd.h>
+ 
+ #include "cpu/cpu.h"
+ #include "process/process.h"
+-- 
+1.7.8.5
+
diff --git a/sys-power/powertop/powertop-1.98.ebuild b/sys-power/powertop/powertop-1.98.ebuild
deleted file mode 100644
index 9e7c34d..0000000
--- a/sys-power/powertop/powertop-1.98.ebuild
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright 1999-2011 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-power/powertop/powertop-1.98.ebuild,v 1.1 2011/08/23 22:14:16 vapier Exp $
-
-EAPI="4"
-
-inherit eutils toolchain-funcs
-if [[ ${PV} == "9999" ]] ; then
-	EGIT_REPO_URI="git://git.kernel.org/pub/scm/status/powertop/powertop.git"
-	inherit git-2
-	SRC_URI=""
-else
-	SRC_URI="mirror://kernel/linux/status/${PN}/${P}.tar.bz2"
-	KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
-
-DESCRIPTION="tool that helps you find what software is using the most power"
-HOMEPAGE="http://www.lesswatts.org/projects/powertop/"
-
-LICENSE="GPL-2"
-SLOT="0"
-IUSE="unicode"
-
-DEPEND="
-	dev-libs/libnl
-	sys-apps/pciutils
-	sys-devel/gettext
-	sys-libs/ncurses[unicode?]
-	sys-libs/zlib
-"
-RDEPEND="
-	${DEPEND}
-	net-wireless/bluez
-	x11-apps/xset
-"
-
-DOCS=( TODO README )
-
-src_prepare() {
-	use unicode || sed -i 's:-lncursesw:-lncurses:' Makefile
-	epatch "${FILESDIR}"/${PN}-1.98-build.patch
-	epatch "${FILESDIR}"/${PN}-1.98-build-cc.patch
-	sed -i -r \
-		-e '/FLAGS/s: (-O2|-g|-fno-omit-frame-pointer|-fstack-protector|-D_FORTIFY_SOURCE=2)\>: :g' \
-		-e '/@\$\(CC\)/s:@::' \
-		Makefile || die
-}
-
-src_configure() {
-	tc-export BUILD_CC CC CXX
-	CFLAGS+=" ${CPPFLAGS}" # blah!
-}
-
-src_install() {
-	default
-	keepdir /var/cache/powertop
-}
-
-pkg_postinst() {
-	echo
-	einfo "For PowerTOP to work best, use a Linux kernel with the"
-	einfo "tickless idle (NO_HZ) feature enabled (version 2.6.21 or later)"
-	echo
-}
diff --git a/sys-power/powertop/powertop-2.0.ebuild b/sys-power/powertop/powertop-2.0.ebuild
new file mode 100644
index 0000000..3036188
--- /dev/null
+++ b/sys-power/powertop/powertop-2.0.ebuild
@@ -0,0 +1,65 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/powertop/powertop-2.0.ebuild,v 1.4 2012/06/01 18:36:59 vapier Exp $
+
+EAPI="4"
+
+inherit eutils
+if [[ ${PV} == "9999" ]] ; then
+	EGIT_REPO_URI="git://github.com/fenrus75/powertop.git"
+	inherit git-2
+	SRC_URI=""
+else
+	SRC_URI="https://01.org/powertop/sites/default/files/downloads/${P}.tar.bz2"
+	KEYWORDS="amd64 arm ppc sparc x86 ~amd64-linux ~x86-linux"
+fi
+
+DESCRIPTION="tool that helps you find what software is using the most power"
+HOMEPAGE="https://01.org/powertop/ http://www.lesswatts.org/projects/powertop/"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="unicode"
+
+DEPEND="
+	dev-libs/libnl
+	sys-apps/pciutils
+	sys-devel/gettext
+	sys-libs/ncurses[unicode?]
+	sys-libs/zlib
+"
+RDEPEND="
+	${DEPEND}
+	x11-apps/xset
+"
+
+DOCS=( TODO README )
+
+src_prepare() {
+	sed -i -r \
+		-e '/^powertop_CXXFLAGS/s: (-O2|-g|-I/usr/include/) : :g' \
+		src/Makefile.in || die
+}
+
+src_configure() {
+	export ac_cv_search_delwin=$(usex unicode -lncursesw no)
+	default
+}
+
+src_compile() {
+	emake -C src csstoh
+	cp "${FILESDIR}"/csstoh src/ || die
+	emake
+}
+
+src_install() {
+	default
+	keepdir /var/cache/powertop
+}
+
+pkg_postinst() {
+	echo
+	einfo "For PowerTOP to work best, use a Linux kernel with the"
+	einfo "tickless idle (NO_HZ) feature enabled (version 2.6.21 or later)"
+	echo
+}