home | list info | list archive | date index | thread index

Script to build .debs of latest kernel

Hi,

On one of my machines, I like to run the latest stable kernel.  I
generally build .deb packages of it.  I was doing the steps over and
over again, so I finally scripted it.  Maybe some of you will find the
script below useful; given a 5.x kernel version as the single
argument, it downloads the kernel source and builds debs of that
kernel.

You have to have all the prerequisites for kernel compilation
installed, as well as GnuPG to verify the signature; the script
doesn't check for that.

Regards,

Dianne.

#========================================================
#!/bin/sh

bail() {
    echo "$1"
    exit 1
}


if test "$1" = "" ; then
    bail "Usage: $0 version"
fi

VERSION=$1

# This will presumably change when kernel 6.x comes out...
BASE="https://cdn.kernel.org/pub/linux/kernel/v5.x";

TARBALL="linux-$VERSION.tar.xz"
SIG="linux-$VERSION.tar.sign"
BUILD_DIR="/usr/src"

cd $BUILD_DIR || bail "Could not cd $BUILD_DIR"

if test -f $TARBALL ; then
    echo "Already have $TARBALL"
else
    echo "Fetching $TARBALL"
    wget $BASE/$TARBALL || bail "Could not fetch $TARBALL"
    wget $BASE/$SIG     || bail "Could not fetch $SIG"
fi

echo "Verifying signature"
xzcat $TARBALL | gpg --verify $SIG -
if test $? != 0 ; then
    bail "Signature failed to verify"
fi

echo "Unpacking $TARBALL"
rm -rf linux-$VERSION > /dev/null 2>&1
tar xf $TARBALL

echo "Copying config"
CONFIG=`ls -1 /boot/config* | tail -n 1`
cp $CONFIG linux-$VERSION/.config || bail "Could not copy config"

echo "Running make oldconfig"
make -C linux-$VERSION oldconfig || bail "'make oldconfig' failed"

echo "Running make bindeb-pkg"
make -C linux-$VERSION -j`nproc` bindeb-pkg || bail "'make bindeb-pkg' failed"

echo "Done!"
exit 0

To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org