funtoo kernel upgrade

While I love many of funtoo’s attempts to streamline the install and upgrade process, I still choose to manage my kernel manually. I have been partial to gentoo-sources. Since I am currently using systemd-boot, when I want to boot to a newer kernel, I just change the relevant kernel and initramfs lines in /boot/loader/entries/funtoo.conf

However, that doesn’t mean a little automation can’t help. Here’s a trivial script I wrote that accepts user input to decide whether or not to clean the build dir before building the new kernel. First the symlinks are set with:

$ eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.8.17-hardened-r2
  [2]   linux-4.9.5-gentoo
  [3]   linux-4.9.6-gentoo *

$ eselect kernel set 3

All I have to do is run ./upgrade-kernel, and I will get a new shiny one built to the same spec as the old. Note that the process will require user input if the kernel upgrade introduces any new configuration options.

#!/bin/sh

cd -P /usr/src/linux

printf "Would you like a fresh build environment? (y,N)\n"

read fresh

if [ "$fresh" == 'y' ] || [ "$fresh" == 'Y' ] ; then
    make clean && make distclean && make mrproper
fi

cp /boot/config-$(uname -r) .config

make oldconfig

time ( make -j5 V=1 && make -j5 V=1 modules_install )

printf "\nKernel complete. \nRemember to 'make install' and update the boot loader entry.\n"