It automatically finds the newest version available in your src directory and updates to that. Might cause issues but since I don't touch the folder it works just fine for me.
Note: IT REQUIRES GRUB2 AND GENTOO!
Code: Select all
#! /bin/bash
# kernel-update.sh version 1.0
# Copyright (c)2014 XenoGamers.com <silence@xenogamers.org>
# This program is licensed under the terms of the GPL version 3.
# This is for GENTOO only!
# Current version of linux kernel
LKVERSION=`uname -r`
# Latest version of linux kernel available
# NOTE: `ls` isn't the best way to do this.
# Will only work correctly if you
# aren't modifying /usr/src/.
LKNEWEST=`ls -t /usr/src/ | head -1 | sed -r 's/^.{5}-//'`
# Processor count for optimising build process
PROCTOTAL=`nproc`
# Prints the current version to the end user
echo "The current version of your Linux kernel is $LKVERSION"
echo "The version that will be installed is $LKNEWEST"
# Sets the symlink manually
rm -rf /usr/src/linux
ln -sf /usr/src/linux-$LKNEWEST /usr/src/linux
# Copies the old version of the kernel config to the new directory
cp /usr/src/linux-$LKVERSION/.config /usr/src/linux/
# Updates the config to the new version
cd /usr/src/linux
make oldconfig <<EOF
EOF
# Reinstall external kernel modules
make modules_prepare
emerge --ask @module-rebuild
# Build the new kernel
make -j$((PROCTOTAL + 1))
# Build the modules
make modules && make modules_install
# Install the new kernel
make install
# Rebuild Grub2 with new kernel
grub2-mkconfig -o /boot/grub/grub.cfg