Skip to content

Instantly share code, notes, and snippets.

@strohel
Created March 22, 2015 10:01
Show Gist options
  • Save strohel/14568a34b4896dbbd224 to your computer and use it in GitHub Desktop.
Save strohel/14568a34b4896dbbd224 to your computer and use it in GitHub Desktop.
Script to install kernel binary to /boot
#!/bin/bash
bootdir="/boot"
installfiles=".config arch/x86/boot/bzImage"
cdpath=/usr/src/linux
grub_config=grub2-mkconfig
testfile() {
if [ ! -r "$1" ]; then
echo "$1" not found
exit 1
fi
}
if ! make kernelrelease > /dev/null; then
echo Cannot issue make kernelrelease, attempting to cd into right dir
cd "${cdpath}"
if ! make kernelrelease > /dev/null; then
echo No luck even here, exiting
exit 1
fi
fi
kernelversion=`make kernelrelease`
make modules_install || exit 1
echo Installing kernel version ${kernelversion} to ${bootdir}
for file in ${installfiles}; do
testfile ${file}
done
mkdir ${bootdir}/${kernelversion}
for file in ${installfiles}; do
if [ "${file}" = ".config" -a -r ${bootdir}/${kernelversion}/`basename "${file}"` ]; then
diff -u ${bootdir}/${kernelversion}/`basename "${file}"` ${file} | less
fi
cp -iv ${file} ${bootdir}/${kernelversion}/`basename "${file}"`
done
echo
echo "Done. Run \`${grub_config} -o ${bootdir}/grub2/grub.cfg\`? (y/N)"
read answer
if [ "X${answer}" = "Xy" -o "X${answer}" = "XY" ]; then
${grub_config} -o ${bootdir}/grub2/grub.cfg
else
echo "Not running grub-mkconfig. Bye."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment