2017-03-01 11:56:49 +01:00
|
|
|
#!/bin/sh
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-06-08 11:36:26 +02:00
|
|
|
set -e
|
2020-12-14 09:33:12 +01:00
|
|
|
set -x
|
2020-06-08 11:36:26 +02:00
|
|
|
|
2016-09-16 22:47:02 +02:00
|
|
|
CWD=$(pwd)
|
2020-12-14 09:33:12 +01:00
|
|
|
THIS_HOST=${THIS_HOST:-$(hostname -s)}
|
2020-09-30 14:48:55 +02:00
|
|
|
PRGNAM=$(basename $CWD)-$THIS_HOST
|
2016-09-16 22:47:02 +02:00
|
|
|
BUILD=${BUILD:-1}
|
2020-09-30 14:33:29 +02:00
|
|
|
BRANCH=${BRANCH:-mainline} # stable ; mainline
|
2016-09-16 22:47:02 +02:00
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
2020-06-25 11:23:11 +02:00
|
|
|
TAG=gwh
|
2016-09-16 22:47:02 +02:00
|
|
|
TMP=/tmp/$TAG
|
|
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
|
|
OUTPUT=/tmp
|
|
|
|
|
2020-12-07 10:29:33 +01:00
|
|
|
NUMJOBS=${NUMJOBS:-" -j$(nproc)"}
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-12-07 10:29:33 +01:00
|
|
|
ANEW=${ANEW:-true}
|
2016-09-16 22:47:02 +02:00
|
|
|
|
|
|
|
rm -fr $PKG
|
|
|
|
|
2020-08-24 15:56:53 +02:00
|
|
|
VERSION=${VERSION:-$(curl https://www.kernel.org/feeds/kdist.xml | grep -o "[0-9.rc-]*: $BRANCH" | head -n1 | cut -d: -f1)}
|
2020-06-09 10:29:47 +02:00
|
|
|
|
2020-09-30 14:33:29 +02:00
|
|
|
mkdir -p $PKG/usr/src/
|
2020-12-07 10:29:33 +01:00
|
|
|
if [ -e /usr/src/linux-$VERSION ] && [[ "$ANEW" != "true" ]]; then
|
2020-09-30 14:33:29 +02:00
|
|
|
cp -a /usr/src/linux-$VERSION $PKG/usr/src/
|
2020-06-09 10:29:47 +02:00
|
|
|
else
|
2020-09-30 14:33:29 +02:00
|
|
|
if [ $BRANCH == "stable" ]; then
|
|
|
|
SRC_URL="https://cdn.kernel.org/pub/linux/kernel/v$(echo $VERSION | cut -d. -f1).x"
|
|
|
|
else
|
|
|
|
SRC_URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot"
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ ! -e $CWD/linux-$VERSION.tar.?z* ] && wget -c "$SRC_URL/linux-$VERSION.tar.gz" -O $CWD/linux-$VERSION.tar.gz
|
|
|
|
tar xf $CWD/linux-$VERSION.tar.gz -C $PKG/usr/src/
|
2020-06-09 10:29:47 +02:00
|
|
|
fi
|
2020-08-24 15:56:53 +02:00
|
|
|
|
2020-09-10 13:26:38 +02:00
|
|
|
cd $PKG/usr/src/
|
|
|
|
ln -s linux-$VERSION linux
|
|
|
|
cd linux-$VERSION
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-09-30 14:48:55 +02:00
|
|
|
if [ -e $CWD/config-$THIS_HOST-$VERSION ] ; then
|
|
|
|
cp $CWD/config-$THIS_HOST-$VERSION .config
|
2020-06-09 10:29:47 +02:00
|
|
|
else
|
2020-09-30 14:48:55 +02:00
|
|
|
if [ -e $CWD/config-$THIS_HOST ] ; then
|
|
|
|
cp $CWD/config-$THIS_HOST .config
|
2016-09-16 22:47:02 +02:00
|
|
|
else
|
2020-06-09 10:29:47 +02:00
|
|
|
zcat /proc/config.gz > .config
|
2016-09-16 22:47:02 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
make oldconfig $*
|
2020-06-09 10:29:47 +02:00
|
|
|
|
2016-09-16 22:47:02 +02:00
|
|
|
make $NUMJOBS
|
2020-09-30 14:33:29 +02:00
|
|
|
make modules $NUMJOBS
|
|
|
|
make modules_install INSTALL_MOD_PATH=$PKG
|
2020-08-24 15:56:53 +02:00
|
|
|
if [[ "$ARCH" == "aarch64" ]]; then
|
|
|
|
make dtbs
|
|
|
|
make dtbs_install INSTALL_DTBS_PATH=$PKG/boot/dtb
|
|
|
|
fi
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-09-10 13:26:38 +02:00
|
|
|
if [ -z "${HEADERS_ARCH}" ]; then
|
|
|
|
case "$(uname -m)" in
|
|
|
|
i?86) HEADERS_ARCH=x86 ;;
|
|
|
|
x86_64) HEADERS_ARCH=x86 ;;
|
2020-10-25 14:18:51 +01:00
|
|
|
aarch64) HEADERS_ARCH=arm64 ;;
|
2020-09-10 13:26:38 +02:00
|
|
|
# Use uname -m for all other archs:
|
|
|
|
*) HEADERS_ARCH=$(uname -m) ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
# Generate the kernel headers and clean them up:
|
|
|
|
( echo "Generating headers from the Linux kernel source tree in ${KERNEL_SOURCE}:"
|
|
|
|
make headers_install ARCH=${HEADERS_ARCH} INSTALL_HDR_PATH=$PKG/usr
|
|
|
|
cd $PKG/usr/include
|
|
|
|
# You won't want these files. The ones in libdrm work better.
|
|
|
|
rm -rf drm
|
|
|
|
# This next part seems pretty much cosmetic, but since we've been doing this
|
|
|
|
# for a long time (and others also do), we'll stick with it:
|
|
|
|
mv asm asm-${HEADERS_ARCH}
|
|
|
|
ln -sf asm-${HEADERS_ARCH} asm
|
|
|
|
# Remove unneeded dotfiles:
|
|
|
|
find . -name ".??*" -exec rm -f {} \+
|
|
|
|
)
|
|
|
|
|
2020-08-10 21:42:27 +02:00
|
|
|
VERSION=$(basename $(ls $PKG/lib/modules/ | head -n1))
|
|
|
|
|
2020-08-24 15:56:53 +02:00
|
|
|
mkdir -p $PKG/install
|
2016-09-16 22:47:02 +02:00
|
|
|
mkdir -p $PKG/boot/
|
2020-06-08 11:36:26 +02:00
|
|
|
cp System.map $PKG/boot/System.map-gwh-$VERSION
|
|
|
|
cp .config $PKG/boot/config-gwh-$VERSION
|
2020-08-24 15:56:53 +02:00
|
|
|
if [[ "$ARCH" == "aarch64" ]]; then
|
|
|
|
cp arch/arm64/boot/Image $PKG/boot/vmlinux-gwh-$VERSION
|
|
|
|
( cd $PKG/boot/
|
|
|
|
ln -s vmlinux-gwh-$VERSION vmlinux-gwh
|
|
|
|
)
|
|
|
|
cat <<EOF > $PKG/install/doinst.sh
|
|
|
|
[ -e /boot/Image ] && mv /boot/Image /boot/Image.old
|
|
|
|
cp /boot/vmlinux-gwh-$VERSION /boot/Image
|
|
|
|
eval \$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -k $VERSION -r )
|
|
|
|
cp /boot/initrd.gz /boot/initrd-gwh.gz
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
cp arch/${ARCH}/boot/bzImage $PKG/boot/vmlinuz-gwh-$VERSION
|
|
|
|
( cd $PKG/boot/
|
|
|
|
ln -s vmlinuz-gwh-$VERSION vmlinuz-gwh
|
|
|
|
)
|
2020-06-09 10:29:47 +02:00
|
|
|
|
2020-08-24 15:56:53 +02:00
|
|
|
cat <<EOF > $PKG/install/doinst.sh
|
2020-06-08 11:36:26 +02:00
|
|
|
cp /boot/elilo-x86_64.efi /boot/efi/EFI/Slackware/elilo.efi
|
|
|
|
cp /boot/vmlinuz-gwh-$VERSION /boot/efi/EFI/Slackware/vmlinuz-gwh
|
2020-10-23 09:11:04 +02:00
|
|
|
if [ -e /boot/intel-ucode.cpio ]; then
|
|
|
|
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'))
|
|
|
|
else
|
|
|
|
eval \$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -k $VERSION -r -m crc32-pclmul:crc32c-intel:crc32_generic\$(lspci | grep -iq radeon && echo ':amdgpu:radeon'))
|
|
|
|
fi
|
2020-06-08 11:36:26 +02:00
|
|
|
cp /boot/initrd.gz /boot/efi/EFI/Slackware/initrd-gwh.gz
|
|
|
|
EOF
|
2020-08-24 15:56:53 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
make clean
|
2016-09-16 22:47:02 +02:00
|
|
|
|
|
|
|
cat <<EOF > $PKG/install/slack-desc
|
2020-08-10 21:42:27 +02:00
|
|
|
$PRGNAM: $PRGNAM (kernel)
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: Linux is a clone of the operating system Unix, written from scratch by
|
|
|
|
$PRGNAM: Linus Torvalds with assistance from a loosely-knit team of hackers
|
|
|
|
$PRGNAM: across the Net. It aims towards POSIX and Single UNIX Specification
|
|
|
|
$PRGNAM: compliance.
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: It has all the features you would expect in a modern fully-fledged Unix
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: http://www.kernel.org
|
|
|
|
$PRGNAM:
|
2016-09-16 22:47:02 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cd $PKG
|
2018-04-20 23:02:35 +02:00
|
|
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
2020-08-24 15:56:53 +02:00
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD$TAG.txz
|