Patchwork [Saucy] UBUNTU: [debian] ship 'cpupower' in linux-tools

login
register
mail settings
Submitter Kamal Mostafa
Date Aug. 9, 2013, 11:03 p.m.
Message ID <1376089426-22207-2-git-send-email-kamal@canonical.com>
Download mbox | patch
Permalink /patch/266178/
State New
Headers show

Comments

Kamal Mostafa - Aug. 9, 2013, 11:03 p.m.
BugLink: http://bugs.launchpad.net/bugs/1158668

New Build-depends: libpci-dev

Adds to binary package "linux-tools-$(abi_version)"
  /usr/bin/cpupower_$(abi_version)
  /usr/lib/libcpupower.so.$(abi_version)

Adds to binary package "linux-tools-common"
  /usr/bin/cpupower
  /usr/share/man/man1/cpupower-set.1.gz
  /usr/share/man/man1/cpupower-frequency-set.1.gz
  /usr/share/man/man1/cpupower-frequency-info.1.gz
  /usr/share/man/man1/cpupower-monitor.1.gz
  /usr/share/man/man1/cpupower-info.1.gz
  /usr/share/man/man1/cpupower-idle-info.1.gz
  /usr/share/man/man1/cpupower.1.gz

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 debian.master/control.stub.in    |  2 +-
 debian/rules.d/2-binary-arch.mk  | 17 +++++++++++++++++
 debian/rules.d/3-binary-indep.mk |  3 +++
 debian/tools/cpupower            | 16 ++++++++++++++++
 4 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 debian/tools/cpupower
Andy Whitcroft - Aug. 11, 2013, 1:33 p.m.
On Fri, Aug 09, 2013 at 04:03:46PM -0700, Kamal Mostafa wrote:
> BugLink: http://bugs.launchpad.net/bugs/1158668

That looks reasonable I think.  As I am in the middle of refactoring
that code to fix some naming issues with linux-tools, I would like
to pick this one up on tuesday and integrate it myself on top of
that work.

-apw
Andy Whitcroft - Aug. 14, 2013, 4:27 p.m.
Applied to Saucy.

-apw

Patch

diff --git a/debian.master/control.stub.in b/debian.master/control.stub.in
index 1bc503c..f45d269 100644
--- a/debian.master/control.stub.in
+++ b/debian.master/control.stub.in
@@ -3,7 +3,7 @@  Section: devel
 Priority: optional
 Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com>
 Standards-Version: 3.9.4.0
-Build-Depends: debhelper (>= 5), cpio, module-init-tools, kernel-wedge (>= 2.24ubuntu1), makedumpfile [amd64 i386], libelf-dev, libnewt-dev, binutils-dev, rsync, libdw-dev, dpkg (>= 1.16.0~ubuntu4), pkg-config, flex, bison, libunwind8-dev, openssl, libaudit-dev, bc, python-dev, gcc-4.7 [armhf], gawk
+Build-Depends: debhelper (>= 5), cpio, module-init-tools, kernel-wedge (>= 2.24ubuntu1), makedumpfile [amd64 i386], libelf-dev, libnewt-dev, binutils-dev, rsync, libdw-dev, libpci-dev, dpkg (>= 1.16.0~ubuntu4), pkg-config, flex, bison, libunwind8-dev, openssl, libaudit-dev, bc, python-dev, gcc-4.7 [armhf], gawk
 Build-Depends-Indep: xmlto, docbook-utils, ghostscript, transfig, bzip2, sharutils, asciidoc
 Vcs-Git: http://kernel.ubuntu.com/git-repos/ubuntu/ubuntu-saucy.git
 XS-Testsuite: autopkgtest
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 5087804..1957779 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -458,6 +458,14 @@  endif
 $(stampdir)/stamp-build-perarch: $(stampdir)/stamp-prepare-perarch
 	@echo Debug: $@
 ifeq ($(do_tools),true)
+
+	# Allow for multiple installed versions of cpupower and libcpupower.so:
+	# Override LIB_MIN in order to to generate a versioned .so named
+	# libcpupower.so.$(abi_release) and link cpupower with that.
+	make -C $(builddirpa)/tools/power/cpupower \
+		CROSS_COMPILE=$(CROSS_COMPILE) \
+		LIB_MIN=$(abi_release) CPUFREQ_BENCH=false
+
 ifeq ($(do_tools_perf),true)
 	cd $(builddirpa)/tools/perf && \
 		make prefix=/usr HAVE_CPLUS_DEMANGLE=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPYTHON=1 NO_LIBPERL=1 PYTHON=python2.7
@@ -478,6 +486,15 @@  install-perarch: $(stampdir)/stamp-build-perarch
 	# Add the tools.
 ifeq ($(do_tools),true)
 	install -d $(toolspkgdir)/usr/bin
+	install -d $(toolspkgdir)/usr/lib
+
+	install -m755 $(builddirpa)/tools/power/cpupower/cpupower \
+		$(toolspkgdir)/usr/bin/cpupower_$(abi_release)
+	# Install only the full versioned libcpupower.so.$(abi_release), not
+	# the usual symlinks to it.
+	install -m644 $(builddirpa)/tools/power/cpupower/libcpupower.so.$(abi_release) \
+		$(toolspkgdir)/usr/lib/
+
 ifeq ($(do_tools_perf),true)
 	install -m755 $(builddirpa)/tools/perf/perf \
 		$(toolspkgdir)/usr/bin/perf_$(abi_release)
diff --git a/debian/rules.d/3-binary-indep.mk b/debian/rules.d/3-binary-indep.mk
index ea6ce68..4e62f51 100644
--- a/debian/rules.d/3-binary-indep.mk
+++ b/debian/rules.d/3-binary-indep.mk
@@ -92,6 +92,9 @@  ifeq ($(do_tools),true)
 	install -d $(toolsbin)
 	install -d $(toolsman)/man1
 
+	install -m755 debian/tools/cpupower $(toolsbin)/cpupower
+	install -m644 $(CURDIR)/tools/power/cpupower/man/*.1 $(toolsman)/man1/
+
 ifeq ($(do_tools_perf),true)
 	install -m755 debian/tools/perf $(toolsbin)/perf
 endif
diff --git a/debian/tools/cpupower b/debian/tools/cpupower
new file mode 100644
index 0000000..9a66eb8
--- /dev/null
+++ b/debian/tools/cpupower
@@ -0,0 +1,16 @@ 
+#!/bin/bash
+full_version=`uname -r`
+
+# Removing flavour from version i.e. generic or server.
+flavour_abi=${full_version#*-}
+flavour=${flavour_abi#*-}
+version=${full_version%-$flavour}
+cpupower="cpupower_$version"
+
+if ! which "$cpupower" > /dev/null; then
+    echo "$cpupower not found" >&2
+    echo "You may need to install linux-tools-$version" >&2
+    exit 2
+fi
+
+exec "$cpupower" "$@"