#!/bin/sh # Copyright 2018, 2020, 2021 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Modified by Didier Spaier didieratslintdotfr for Slint. # zstd compressor everywhere but for the modules # two packages are built: # "kernel" includes the kernel (generic in Slackware parlance), modules and sanitized headers. # "source" # CONFIG_PREEMPT_DEFAULT_MODE= voluntary cd "$(dirname "$0")" || exit 1 CWD="$(pwd)" VERSION=6.6.7 KERNEL_ARCH=x86 ARCH=$(uname -m) HEADERS_ARCH=x86 BUILD=1slint NUMJOBS="-j$(($(nproc)+1))" echo "NUMJOBS=$NUMJOBS" sleep 3 TMP="$CWD" PKGSOURCE="$TMP/PKGSOURCE" PKGKERNEL="$TMP/PKGKERNEL" rm -rf "$PKGSOURCE" "$PKGKERNEL" mkdir -p "$PKGSOURCE"/usr/src \ "$PKGSOURCE"/install \ "$PKGKERNEL"/boot \ "$PKGKERNEL"/install \ "$PKGKERNEL"/lib/modules \ "$PKGKERNEL"/usr/include echo "Using kernel config: $CWD/kernel-configs/config-$VERSION" echo "Untarring $CWD/linux-${VERSION}.tar.?z in $PKGSOURCE/usr/src..." cd "$PKGSOURCE"/usr/src || exit 1 tar xf "$CWD"/linux-"${VERSION}".tar.?z || exit 1 echo "Making /usr/src/linux symlink..." ln -sf linux-"$VERSION" linux cd linux-"$VERSION" || exit 1 cp -a "$CWD"/kernel-configs/config-"$VERSION" .config echo "Fixing permissions/ownership..." chown -R root:root . cd "$PKGSOURCE"/usr/src/linux-"$VERSION" || exit 1 echo "Making oldconfig..." make oldconfig echo "Building kernel and modules..." ZSTD_CLEVEL=19 make "$NUMJOBS" || make || exit 1 cp -a --verbose System.map "$PKGKERNEL"/boot/System.map-"${VERSION}" cp -a --verbose .config "$PKGKERNEL/boot/config-${VERSION}$CONFIG_SUFFIX" cp -a --verbose arch/${KERNEL_ARCH}/boot/bzImage "$PKGKERNEL"/boot/vmlinuz-"$VERSION" make "$NUMJOBS" modules || exit 1 make INSTALL_MOD_PATH="$PKGKERNEL" modules_install || exit 1 echo "Generating headers from the Linux kernel source tree :" make headers_install ARCH="$HEADERS_ARCH" INSTALL_HDR_PATH="$PKGKERNEL"/usr echo "Cleaning up..." make clean # Make sure header files aren't missing... make prepare # Don't package the kernel in the sources: find . -name "*Image" -exec rm "{}" \+ # No need for these: rm -f .config.old .version find . -name "*.cmd" -exec rm -f "{}" \+ rm .*.d # Still some dotfiles laying around... probably fine though # Use the version number found in the Makefile in the package name. cd "$PKGKERNEL"/lib/modules/"$VERSION" || exit 1 for symlink in build source ; do rm -f $symlink ln -s /usr/src/linux-"$VERSION" $symlink done cd "$PKGSOURCE"/usr/src/linux-"$VERSION" || exit 1 depmod -b "$PKGKERNEL" -a "$VERSION" echo "Generating headers from the Linux kernel source tree in $KERNEL_SOURCE:" make headers_install ARCH="$HEADERS_ARCH" INSTALL_HDR_PATH="$PKGKERNEL"/usr cd "$PKGKERNEL"/usr/include || exit 1 # 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 {} \+ PACKAGE_VERSION="$(grep "^VERSION = " Makefile | rev | cut -f 1 -d ' ' | rev).$(grep "^PATCHLEVEL = " Makefile | rev | cut -f 1 -d ' ' | rev).$(grep "^SUBLEVEL = " Makefile | rev | cut -f 1 -d ' ' | rev)$(grep "^EXTRAVERSION = " Makefile | rev | cut -f 1 -d ' ' | rev)" cat "$CWD"/slack-desc/slack-desc.kernel-source > "$PKGSOURCE"/install/slack-desc cd "$PKGSOURCE" || exit 1 /sbin/makepkg -l y -c n "$TMP"/kernel-source-"$(echo "$VERSION" | tr - _)"-noarch-"$BUILD".txz cat "$CWD"/slack-desc/slack-desc.kernel > "$PKGKERNEL"/install/slack-desc cd "$PKGKERNEL" || exit 1 /sbin/makepkg -l y -c n "$TMP"/kernel-"$(echo "$VERSION" | tr - _)"-"$ARCH"-$BUILD.txz echo "All done."