Skip to content

Instantly share code, notes, and snippets.

@shlomiv
Last active December 6, 2016 23:52
Show Gist options
  • Save shlomiv/1cd57fd97ca92ac50576b7ce0ac72a0d to your computer and use it in GitHub Desktop.
Save shlomiv/1cd57fd97ca92ac50576b7ce0ac72a0d to your computer and use it in GitHub Desktop.
A script for automatically downloading source, building and installing perf for ubuntu linux kernels. Useful if your kernel version does not have the required pacakages (linux-tools and linux-cloud-tools) available on ppa,
#!/bin/sh
# Author: Shlomi Vaknin
# Automatically build and install perf for ubuntu linux kernels.
# Useful if your kernel version does not have the required pacakages (linux-tools and linux-cloud-tools) available on ppa,
SCRIPT=$(readlink -f "$0")
BASEDIR=$(dirname "$SCRIPT")
echo "Automatic perf build and install script. \n"
if [ ! -d $BASEDIR/mainline-crack ]; then
echo "Linux sources not found. downloding them. it may take a while."
# Use https to avoid proxy problems in company networks
git clone https://git.launchpad.net/\~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack
fi
echo "Make sure you are on the correct kernel tag!"
echo " Current kernel version: " $(uname -r)
echo " Current git repo tag: " $(cd $BASEDIR/mainline-crack/tools/perf; git describe --tags)
echo ""
echo "Example setting tag:\n Use 'git tag -l | grep 4.8.12' to see if a tag exists, and then 'git checkout tag-name'."
echo ""
read -p "Press any key to continue, or abort by pressing CTRL+C" nothing
make -C $BASEDIR/mainline-crack/tools/perf
if [ $? -eq 0 ]; then
echo "Attempting to install perf (requires sudo):"
sudo cp $BASEDIR/mainline-crack/tools/perf/perf $(command -v perf || echo /usr/bin/perf)
if [ $? -eq 0 ]; then
echo "Done!"
else
echo "Did not get root permissions, failed installing. you can still use perf from its location at $BASEDIR/mainline-crack/tools/perf/perf"
fi
else
echo "Compilation failed, check why!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment