# Maintainer: Sébastien Luttringer # Customized version of linux for seblu computers pkgname=linux-seblu pkgver=6.6.10 pkgrel=1 pkgdesc='The Linux Kernel cooked by Seblu' arch=('x86_64') license=('GPL2') url='http://www.kernel.org' options=('!strip' '!buildflags') makedepends=('llvm' 'clang' 'lld' 'libelf' 'kmod' 'git' 'make' 'bc' 'sed' 'cpio' 'python' 'zstd') optdepends=( 'linux-firmware: linux firmwares' 'kernel-install-hook: systemd installation helpers' ) install=linux-seblu.install _main=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git _stable=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git source=("git+$_stable#tag=v6.6.10" "config.$CARCH") sha256sums=('SKIP' 'a31dcdb2b2b855fa11e71269e11b8e5e65a7c28299c6b7b07b8ffe2ae1753864') prepare() { [[ -d linux-stable ]] && ln -snf linux-stable linux cd linux # apply patch from the source array (should be a pacman feature) local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" [[ $src = *.patch ]] || continue msg2 "Applying patch $src..." patch -Np1 < "../$src" done # loading default config # use make localmodconfig to check .config is correct msg2 'Copying config' install "$srcdir/config.$CARCH" .config # force suffixe in config (must be the right!) msg2 'Setting kernel suffix' sed -ri "s|(CONFIG_LOCALVERSION=).*|\1\"${pkgname#linux*}\"|g" .config # define current build version msg2 'Setting kernel build version' echo "$(($pkgrel - 1 ))" > .version # prevent addition of -dirty to version msg2 'Patch setlocalversion' sed -i 's|no_dirty=false|no_dirty=true|' scripts/setlocalversion msg2 'Force use of LLVM in makefile' # early makefile patching achieve 2 goals. Firstly, avoid adding variables to # each make call. Secondly, it is later used by tools (e.g dkms) to build # out-of-tree modules. echo -e "\nLLVM = 1\nLLVM_IAS = 1\nexport LLVM LLVM_IAS" >> scripts/Kbuild.include msg2 'Make prepare' make prepare } pkgver() { make -C linux -s kernelversion|tr '-' '_' } build() { make -C linux all } package() { cd linux # get real compiled kernel version kernrel=$(make kernelrelease) pkgdesc+=", release $kernrel" pkgname="linux-$kernrel" provides=("linux=$pkgver" "linux-headers=$pkgver" VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE) msg2 "Kernel release: $kernrel" msg2 "Package kernel version: $pkgver" msg2 'Installing vmlinuz' install -D -m644 "$(make -s image_name)" "$pkgdir/usr/lib/kernel/vmlinuz-$kernrel" msg2 'Installing modules' # disable DEPMOD because it fail due to poor hack in scripts/depmod.sh # INSTALL_MOD_STRIP will cause modules to be fully stripped make -s INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 DEPMOD=/bin/true modules_install msg2 'Generating modules.dep and map files' # run depmod to keep track of these files and remove them with the package depmod -b "$pkgdir/usr" -F System.map "$kernrel" msg2 'Add mkinitcpio pkgbase file' # used by mkinitcpio to name the kernel install -Dm644 <(echo "$pkgname") "$pkgdir/usr/lib/modules/$kernrel/pkgbase" install_sources msg2 'Removing firmwares' rm -rvf "$pkgdir/usr/lib/firmware" } install_sources() { local kernsrc="$pkgdir/usr/src/$pkgname" local i cd "$srcdir/linux" msg2 'Installing sources' install -d -m 755 "$kernsrc" msg2 'Installing symlinks in modules/' # remove previous build and source links rm -f "$pkgdir/usr/lib/modules/$kernrel"/{source,build} ln -rs "$kernsrc" "$pkgdir/usr/lib/modules/$kernrel"/source ln -rs "$kernsrc" "$pkgdir/usr/lib/modules/$kernrel"/build msg2 'Installing build files' install -Dt "$kernsrc" -m644 .config Makefile Module.symvers System.map install -Dt "$kernsrc/kernel" -m644 kernel/Makefile install -Dt "$kernsrc/arch/x86" -m644 arch/x86/Makefile for i in version localversion*; do [[ -e "$i" ]] && install -m644 "$i" "$kernsrc/$i" done msg2 'Installing scripts' cp -t "$kernsrc" -a scripts # add objtool for external module building when enabled VALIDATION_STACK option # this is adding dependencty to glibc and libelf to the kernel package msg2 'Installing objtool' install -Dt "$kernsrc/tools/objtool" tools/objtool/objtool msg2 'Installing headers' cp -t "$kernsrc" -a include # arch includes for external modules cp -t "$kernsrc/arch/x86" -a arch/x86/include install -Dt "$kernsrc/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s # dm headers install -Dt "$kernsrc/drivers/md" -m644 drivers/md/*.h # wireless headers install -Dt "$kernsrc/net/mac80211" -m644 net/mac80211/*.h # dvb headers, http://bugs.archlinux.org/task/13146 install -Dt "$kernsrc/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h # dvb headers, http://bugs.archlinux.org/task/20402 install -Dt "$kernsrc/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h install -Dt "$kernsrc/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h install -Dt "$kernsrc/drivers/media/tuners" -m644 drivers/media/tuners/*.h msg2 'Installing Kconfig files' find . -name 'Kconfig*' -exec install -Dm644 {} "$kernsrc/{}" \; msg2 'Removing unneeded architectures' for i in "$kernsrc"/arch/*; do [[ "${i##*/}" != x86 ]] && rm -rf "$i" done msg2 'Removing documentation' rm -r "$kernsrc/Documentation" msg2 'Stripping exectuables' while read -rd '' i; do case "$(file -Sbi "$i")" in application/x-sharedlib\;*) # Libraries (.so) strip -v $STRIP_SHARED "$i" ;; application/x-archive\;*) # Libraries (.a) strip -v $STRIP_STATIC "$i" ;; application/x-executable\;*) # Binaries strip -v $STRIP_BINARIES "$i" ;; application/x-pie-executable\;*) # Relocatable binaries strip -v $STRIP_SHARED "$i" ;; esac done < <(find "$kernsrc" -type f -perm -u+x -print0) msg2 'Removing sources broken symlinks' find -L "$kernsrc" -type l -printf 'Removing %P\n' -delete msg2 'Removing sources lost objects' find "$kernsrc" -type f -name '*.o' -printf 'Removing %P\n' -delete } # vim:set ts=2 sw=2 ft=sh et: