slackbuilds/a/kernel-gwh/SlackBuild
2020-06-08 11:36:26 +02:00

87 lines
2.5 KiB
Bash
Executable file

#!/bin/sh
set -e
CLEAN_SRC=${CLEAN_SRC:-NO}
CWD=$(pwd)
PRGNAM=$(basename $CWD)
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)
SOURCES=/usr/src
TAG=cyco
TMP=/tmp/$TAG
PKG=$TMP/pkg-$PRGNAM
OUTPUT=/tmp
NUMJOBS=${NUMJOBS:-" -j4 "}
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
[ ! -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.xz -C $SOURCES
fi
cd $SOURCES/linux-$VERSION
if [ $CLEAN_SRC != "NO" ] || [ ! -e .config ] ; then
if [ -e $CWD/config-$VERSION ] ; then
cp $CWD/config-$VERSION .config
else
if [ -e $CWD/config ]; then
cp $CWD/config .config
else
zcat /proc/config.gz > .config
fi
fi
fi
make oldconfig $*
make $NUMJOBS
make modules_install INSTALL_MOD_PATH=$PKG
mkdir -p $PKG/boot/
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-gwh-$VERSION vmlinuz-gwh
)
mkdir -p $PKG/install
cat <<EOF > $PKG/install/doinst.sh
cp /boot/elilo-x86_64.efi /boot/efi/EFI/Slackware/elilo.efi
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: 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: It has all the features you would expect in a modern fully-fledged Unix
$PRGNAM-$VERSION:
$PRGNAM-$VERSION: http://www.kernel.org
$PRGNAM-$VERSION:
EOF
cd $PKG
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}-$ARCH-$BUILD$TAG.txz