[SRU,precise/master-next,1/1] UBUNTU: tools -- upgrade to common generic helper
diff mbox

Message ID 1384194802-29641-2-git-send-email-apw@canonical.com
State New
Headers show

Commit Message

Andy Whitcroft Nov. 11, 2013, 6:33 p.m. UTC
In order to allow us to have tools from both the current releases and
newer LTS backport releases we need the updated generic helper which
understands all possible locations.  At the same time take the
opportunity to standardise on a single helper.

BugLink: http://bugs.launchpad.net/bugs/1205284
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 debian/rules.d/3-binary-indep.mk    |  6 +++---
 debian/tools/generic                | 24 +++++++++++++++++++-----
 debian/tools/perf                   | 16 ----------------
 debian/tools/turbostat              | 16 ----------------
 debian/tools/x86_energy_perf_policy | 16 ----------------
 5 files changed, 22 insertions(+), 56 deletions(-)
 delete mode 100644 debian/tools/perf
 delete mode 100644 debian/tools/turbostat
 delete mode 100644 debian/tools/x86_energy_perf_policy

Patch
diff mbox

diff --git a/debian/rules.d/3-binary-indep.mk b/debian/rules.d/3-binary-indep.mk
index de3583a..73a251e 100644
--- a/debian/rules.d/3-binary-indep.mk
+++ b/debian/rules.d/3-binary-indep.mk
@@ -92,10 +92,10 @@  ifeq ($(do_tools),true)
 	install -d $(toolsbin)
 	install -d $(toolsman)/man1
 
-	install -m755 debian/tools/perf $(toolsbin)/perf
+	install -m755 debian/tools/generic $(toolsbin)/perf
 	if [ "$(arch)" = "amd64" ] || [ "$(arch)" = "i386" ]; then \
-		install -m755 debian/tools/x86_energy_perf_policy $(toolsbin)/x86_energy_perf_policy; \
-		install -m755 debian/tools/turbostat $(toolsbin)/turbostat; \
+		install -m755 debian/tools/generic $(toolsbin)/x86_energy_perf_policy; \
+		install -m755 debian/tools/generic $(toolsbin)/turbostat; \
 		install -d $(toolssbin) ; \
 		install -m755 debian/tools/generic $(toolssbin)/hv_kvp_daemon; \
 	fi
diff --git a/debian/tools/generic b/debian/tools/generic
index 61b427d..4aa5649 100644
--- a/debian/tools/generic
+++ b/debian/tools/generic
@@ -1,16 +1,30 @@ 
 #!/bin/bash
 full_version=`uname -r`
 
+# First check for a fully qualified version.
+this="/usr/lib/linux-tools/$full_version/`basename $0`"
+if [ -f "$this" ]; then
+	exec "$this" "$@"
+fi
+
+# FALLBACK for older kernel layouts
 # Removing flavour from version i.e. generic or server.
 flavour_abi=${full_version#*-}
 flavour=${flavour_abi#*-}
 version=${full_version%-$flavour}
 this="$0_$version"
+if [ -f "$this" ]; then
+	exec "$this" "$@"
+fi
 
-if [ ! -f "$this" ]; then
-    echo "$this not found" >&2
-    echo "You may need to install linux-tools-$version" >&2
-    exit 2
+# If we have the appropriate package installed but no
+# tool then the tool does not exist.
+if [ -d "/usr/lib/linux-tools/$full_version" ]; then
+	echo "`basename $0` not available for kernel $version" >&2
+	exit 2
 fi
 
-exec "$this" "$@"
+# Give them a hint as to what to install.
+echo "`basename $0` not found for kernel $version" >&2
+echo "You may need to install linux-tools-$version-$flavour" >&2
+exit 2
diff --git a/debian/tools/perf b/debian/tools/perf
deleted file mode 100644
index ab35fab..0000000
--- a/debian/tools/perf
+++ /dev/null
@@ -1,16 +0,0 @@ 
-#!/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}
-perf="perf_$version"
-
-if ! which "$perf" > /dev/null; then
-    echo "$perf not found" >&2
-    echo "You may need to install linux-tools-$version" >&2
-    exit 2
-fi
-
-exec "$perf" "$@"
diff --git a/debian/tools/turbostat b/debian/tools/turbostat
deleted file mode 100644
index ac4af7c..0000000
--- a/debian/tools/turbostat
+++ /dev/null
@@ -1,16 +0,0 @@ 
-#!/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}
-turbostat="turbostat_$version"
-
-if ! which "$turbostat" > /dev/null; then
-    echo "$turbostat not found" >&2
-    echo "You may need to install linux-tools-$version" >&2
-    exit 2
-fi
-
-exec "$turbostat" "$@"
diff --git a/debian/tools/x86_energy_perf_policy b/debian/tools/x86_energy_perf_policy
deleted file mode 100644
index 7b97a9e..0000000
--- a/debian/tools/x86_energy_perf_policy
+++ /dev/null
@@ -1,16 +0,0 @@ 
-#!/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}
-x86_energy_perf_policy="x86_energy_perf_policy_$version"
-
-if ! which "$x86_energy_perf_policy" > /dev/null; then
-    echo "$x86_energy_perf_policy not found" >&2
-    echo "You may need to install linux-tools-$version" >&2
-    exit 2
-fi
-
-exec "$x86_energy_perf_policy" "$@"