# Maintainer: Sébastien Luttringer # Customized version of linux for seblu computers pkgname=linux-seblu pkgver=5.12.0 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') 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+$_main#tag=v5.12" "config.$CARCH") sha256sums=('SKIP' '76b6967cbf841a05f3df3b664e1b9ab143a18a51939a88208dfe9af6872e548f') 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 # no scm version # this prevent an issue with “make kernelrelease” which add -dirty to version # because ownership of git files has fakely been changed by fakeroot when # called from makepkg echo '' > .scmversion } pkgver() { cd linux make -s kernelversion|tr '-' '_' } build() { cd linux msg2 'Make prepare' make LLVM=1 prepare msg2 'Make bzImage' make LLVM=1 bzImage msg2 'Make modules' make LLVM=1 modules } package() { cd linux # get real compiled kernel version kernrel=$(make kernelrelease) pkgdesc+=", version $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" install_sources msg2 'Removing firmwares' rm -rf "$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: