Building my own kernel again

This commit is contained in:
Gwenhael Le Moine 2020-06-08 11:36:26 +02:00
parent bad1c9ed5b
commit b78ba89932
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
4 changed files with 22 additions and 66 deletions

View file

@ -1,30 +0,0 @@
#!/bin/bash
USRSRC=/usr/src
GITSRC=/home/installs/linux-linus
KERNELSLACKBUILD=$(pwd)/$(basename $(pwd)).SlackBuild
PATCHFILE=/home/installs/patch
(cd $GITSRC
git pull
)
CURRENT_VERSION=$(ls /usr/src/ | grep linux | tail -n1 | sed 's|^linux-||')
LATEST_TAG=$(cd $GITSRC; git tag | tail -n1 | sed 's|^v||')
if [[ $CURRENT_VERSION == $LATEST_TAG ]]; then
echo "No new version"
exit -1
else
#make patch file
(cd $GITSRC
git diff v$CURRENT_VERSION v$LATEST_TAG > $PATCHFILE
)
(cd $USRSRC
mv linux-$CURRENT_VERSION linux-$LATEST_TAG
cd linux-$LATEST_TAG
patch -p1 -i $PATCHFILE
)
cd $(dirname $KERNELSLACKBUILD)
VERSION=$LATEST_TAG ./$(basename $KERNELSLACKBUILD)
fi

View file

@ -1,11 +1,13 @@
#!/bin/sh
set -e
CLEAN_SRC=${CLEAN_SRC:-NO}
CWD=$(pwd)
PRGNAM=$(basename $CWD)
VERSION=${VERSION:-$(echo /usr/src/linux-* | sort | tail | cut -d- -f2)}
VERSION=${VERSION:-$(curl https://www.kernel.org/feeds/kdist.xml | grep -o "[0-9.]*: stable" | head -n1 | cut -d: -f1)}
BUILD=${BUILD:-1}
ARCH=$(uname -m)
@ -18,17 +20,15 @@ OUTPUT=/tmp
NUMJOBS=${NUMJOBS:-" -j4 "}
SRC_URL="https://cdn.kernel.org/pub/linux/kernel/v4.x"
SRC_URL="https://cdn.kernel.org/pub/linux/kernel/v$(echo $VERSION | cut -d. -f1).x"
rm -fr $PKG
if [ $CLEAN_SRC != "NO" ] ; then
rm -fr $SOURCES/linux-$VERSION
fi
if [ $CLEAN_SRC != "NO" ]; then
[ ! -e $CWD/linux-$VERSION.tar.?z* ] && wget -c "$SRC_URL/linux-$VERSION.tar.xz" -O $CWD/linux-$VERSION.tar.xz
[ ! -e $SOURCES ] && mkdir -p $SOURCES
tar xf $CWD/linux-$VERSION.tar.?z* -C $SOURCES
tar xf $CWD/linux-$VERSION.tar.xz -C $SOURCES
fi
cd $SOURCES/linux-$VERSION
@ -49,53 +49,39 @@ make oldconfig $*
make $NUMJOBS
make modules_install INSTALL_MOD_PATH=$PKG
KERNEL_TAG=$(grep "CONFIG_LOCALVERSION=" .config | sed 's|CONFIG_LOCALVERSION=||' | tr -d \" )
KERNEL_VERSION=$(grep -o "[0-9]\+\.[0-9]\+.*[0-9]" .config)$KERNEL_TAG
mkdir -p $PKG/boot/
for i in .config System.map; do
cp $i $PKG/boot/${i}-$KERNEL_VERSION
done
mv $PKG/boot/{.,}config-$KERNEL_VERSION
cp arch/x86/boot/bzImage $PKG/boot/vmlinuz-$KERNEL_VERSION
cp System.map $PKG/boot/System.map-gwh-$VERSION
cp .config $PKG/boot/config-gwh-$VERSION
cp arch/${ARCH}/boot/bzImage $PKG/boot/vmlinuz-gwh-$VERSION
( cd $PKG/boot/
ln -s vmlinuz-$KERNEL_VERSION vmlinuz-cycojesus
ln -s vmlinuz-gwh-$VERSION vmlinuz-gwh
)
# mkdir -p $PKG/install
# cat <<EOF > $PKG/install/doinst.sh
# cp /etc/lilo.conf /etc/lilo.conf.orig
# grep -q "image = /boot/$KERNEL_VERSION/bzImage" /etc/lilo.conf || \
# cat <<EOLILO >> /etc/lilo.conf
# # Linux bootable partition config begins
# image = /boot/$KERNEL_VERSION/bzImage
# root = /dev/sda1
# label = $KERNEL_VERSION
# read-only
# # Linux bootable partition config ends
mkdir -p $PKG/install
cat <<EOF > $PKG/install/doinst.sh
cp /boot/elilo-x86_64.efi /boot/efi/EFI/Slackware/elilo.efi
# EOLILO
# sed -i "s|default=.*|default=$KERNEL_VERSION|" /etc/lilo.conf
# lilo
# EOF
cp /boot/vmlinuz-gwh-$VERSION /boot/efi/EFI/Slackware/vmlinuz-gwh
cp /boot/intel-ucode.cpio /boot/efi/EFI/Slackware/
eval $(/usr/share/mkinitrd/mkinitrd_command_generator.sh -a '-P /boot/intel-ucode.cpio' -k $VERSION -r -m crc32-pclmul:crc32c-intel:crc32_generic$(lspci | grep -iq radeon && echo ':amdgpu:radeon'))
cp /boot/initrd.gz /boot/efi/EFI/Slackware/initrd-gwh.gz
EOF
VERSION=$(echo $VERSION | tr - _)
cat <<EOF > $PKG/install/slack-desc
$PRGNAM-$VERSION: $PRGNAM-$VERSION (kernel)
$PRGNAM-$VERSION:
$PRGNAM-$VERSION:
$PRGNAM-$VERSION: Linux is a clone of the operating system Unix, written from scratch by
$PRGNAM-$VERSION: Linus Torvalds with assistance from a loosely-knit team of hackers
$PRGNAM-$VERSION: across the Net. It aims towards POSIX and Single UNIX Specification
$PRGNAM-$VERSION: compliance.
$PRGNAM-$VERSION:
$PRGNAM-$VERSION:
$PRGNAM-$VERSION: It has all the features you would expect in a modern fully-fledged Unix
$PRGNAM-$VERSION:
$PRGNAM-$VERSION:
$PRGNAM-$VERSION: http://www.kernel.org
$PRGNAM-$VERSION:
$PRGNAM-$VERSION:
EOF
cd $PKG
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}_$(echo $KERNEL_TAG | tr - _)-$ARCH-$BUILD$TAG.txz
makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}-$ARCH-$BUILD$TAG.txz