SHA256
1
0
forked from pool/cpupower
cpupower/cpupower_export_tarball_from_git.sh
Thomas Renninger b3a3f0b493 Accepting request 639997 from home:trenn:branches:hardware
- Updating to latest 4.19(-rc6) kernel sources
  Turbostat is increased to version 18.07.27 by this
  Patches which got deleted because they are now mainline:
D    turbostat_decode_MSR_IA32_MISC_ENABLE_only_on_Intel.patch
D    turbostat_fix_man_perm.patch
D    x86_perf_fix_man_permissions.patch

OBS-URL: https://build.opensuse.org/request/show/639997
OBS-URL: https://build.opensuse.org/package/show/hardware/cpupower?expand=0&rev=81
2018-10-04 16:34:17 +00:00

152 lines
4.4 KiB
Bash

#!/bin/bash
# Author: Thomas Renninger <trenn@suse.de>
# This code is covered and distributed under
# the General Public Licence v2
GIT_TAG=HEAD
VERSION=""
TOOL=""
function usage(){
echo "$(basename $0) [ -k git_tag ] [ -v tag_to_use ] -t cpupower | turbostat | x86_perf_bias "
echo
echo "git_tag Must be a valid kernel git tag, for example v3.1"
echo " if git_tag is not passed HEAD will be used which"
echo " may produce a package incompatible tarball name"
echo " BEST ALWAYS PASS AN EXISTING TAG"
echo " cpupower got introduced in 3.1-rc1"
echo "tag_to_use obs does not like -rcX as a version tag. Pass a verion"
echo " tag you like to use (e.g. 3.13 instead of 3.13-rc7"
echo
echo "export GIT_DIR= environment variable if the git repo is not the current directory"
echo "For example: GIT_DIR=/path_to_git_repo/.git"
}
function parse_args()
{
while getopts hv:k:t: name ; do
case $name in
v)
VERSION="$OPTARG"
;;
k)
GIT_TAG="$OPTARG"
;;
t)
echo XXXXXXXXX
TOOL="$OPTARG"
echo $TOOL
echo YYYYYYYY
;;
?|h)
usage
exit 1
;;
esac
done
shift $(($OPTIND -1))
}
function export_cpupower() {
echo "Exporting cpupower from kernel version $GIT_TAG"
if [ "$VERSION" = "" ];then
# convert - to . as package versions do not allow -
if [ $# -eq 1 ];then
VERSION="${GIT_TAG/-/.}"
# remove leading v
VERSION="-${VERSION#v}"
elif [ $# -eq 2 ];then
VERSION="${2/-/.}"
# remove leading v
VERSION="-${VERSION#v}"
elif [ $# -gt 2 ];then
usage
exit 1
fi
fi
# Tried to do this with one git archive command, but
# --remote= param seem not to be configured for kernel.org gits
set -x
git archive --format=tar $GIT_TAG tools/power/cpupower |tar -x
set +x
mv tools/power/cpupower cpupower-${VERSION}
tar -cvjf cpupower-${VERSION}.tar.bz2 cpupower-${VERSION}
popd
mv "$DIR/cpupower-${VERSION}".tar.bz2 .
echo cpupower-${VERSION}.tar.bz2
}
function export_turbostat() {
git archive --format=tar $GIT_TAG tools/power/x86/turbostat |tar -x
if [ "$TURBOSTAT_VERSION"x == ""x ];then
TURBOSTAT_VERSION=$(grep "turbostat version" tools/power/x86/turbostat/turbostat.c |grep fprintf |sed 's/.*turbostat version \([0-9][0-9].[0-9][0-9].[0-9][0-9]\).*/\1/')
fi
TURBOSTAT_VERSION=$(echo "-$TURBOSTAT_VERSION")
mv tools/power/x86/turbostat turbostat${TURBOSTAT_VERSION}
git checkout $GIT_TAG arch/x86/include/asm/msr-index.h
git checkout $GIT_TAG arch/x86/include/asm/intel-family.h
cp arch/x86/include/asm/intel-family.h turbostat${TURBOSTAT_VERSION}
cp arch/x86/include/asm/msr-index.h turbostat${TURBOSTAT_VERSION}
tar -cvjf turbostat${TURBOSTAT_VERSION}.tar.bz2 turbostat${TURBOSTAT_VERSION}
popd
mv "$DIR/turbostat${TURBOSTAT_VERSION}".tar.bz2 .
echo turbostat${TURBOSTAT_VERSION}.tar.bz2
}
function export_x86_perf_bias() {
set -x
git archive --format=tar $GIT_TAG tools/power/x86/x86_energy_perf_policy |tar -x
if [ "$PERF_BIAS_VERSION"x == ""x ];then
PERF_BIAS_VERSION=$(grep 'printf("x86_energy_perf_policy .* (C) Len Brown <len.brown@intel.com' tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c |sed 's/.*x86_energy_perf_policy \([0-9][0-9].[0-9][0-9].[0-9][0-9]\).*/\1/')
fi
PERF_BIAS_VERSION=$(echo "-$PERF_BIAS_VERSION")
mv tools/power/x86/x86_energy_perf_policy x86_energy_perf_policy${PERF_BIAS_VERSION}
set +x
git checkout $GIT_TAG arch/x86/include/asm/msr-index.h
cp arch/x86/include/asm/msr-index.h x86_energy_perf_policy${PERF_BIAS_VERSION}
tar -cvjf x86_energy_perf_policy${PERF_BIAS_VERSION}.tar.bz2 x86_energy_perf_policy${PERF_BIAS_VERSION}
popd
mv "$DIR/x86_energy_perf_policy${PERF_BIAS_VERSION}".tar.bz2 .
echo x86_energy_perf_policy${PERF_BIAS_VERSION}.tar.bz2
}
parse_args $*
DIR=`mktemp -d`
pushd $DIR
if [ "$GIT_DIR" = "" ];then
export GIT_DIR=/archteam/trenn/git/linux-2.6/.git
fi
case $TOOL in
cpupower)
echo XXX
export_cpupower
;;
turbostat)
export_turbostat
;;
x86_perf_bias)
export_x86_perf_bias
;;
*)
echo "You have to provide the tool you want to export cpupower|turbostat|x86_energy_perf_bias"
usage
rm -rf "$DIR"
exit 1
;;
esac
#rm -rf "$DIR"