# Maintainer: Boohbah # Contributor: Tobias Powalowski # Contributor: Thomas Baechler # Contributor: Jonathan Chan # Contributor: misc # Contributor: NextHendrix pkgbase=linux-git _srcname=linux pkgver=5.9.r0.gbbf5c979011a pkgrel=1 arch=('x86_64') url="https://www.kernel.org/" license=('GPL2') makedepends=(bc kmod libelf pahole cpio perl tar xz git) options=('!strip') source=('git+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git#tag=v5.9' #'git+https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git#tag=vX.X.Y' 'config' # the main kernel config file ) sha256sums=('SKIP' 'e8e9d05bc4076915c0b8f4d1d7d8889b6c446a9853a5d5ef09df47689164403b') _kernelname=${pkgbase#linux} pkgver() { cd $_srcname git describe --long | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g;s/\.rc/rc/' } export KBUILD_BUILD_HOST=archlinux export KBUILD_BUILD_USER=$pkgbase export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" prepare() { cd ${_srcname} cp ../config .config echo "Setting version..." sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config sed -i "s|^.*CONFIG_LOCALVERSION_AUTO.*|CONFIG_LOCALVERSION_AUTO=y|" ./.config # prepare for build make prepare # load configuration # Configure the kernel. Replace the line below with one of your choice. #make menuconfig # CLI menu for configuration #make nconfig # new CLI menu for configuration #make xconfig # X-based configuration #make oldconfig # using old config from previous kernel version #make olddefconfig # old config from previous kernel, defaults for new options # ... or manually edit .config } build() { cd $_srcname make LOCALVERSION= bzImage modules } _package() { pkgdesc="The Linux kernel and modules (git version)" depends=('coreutils' 'kmod' 'initramfs') optdepends=('crda: to set the correct wireless channels of your country' 'linux-firmware: firmware images needed for some devices') cd $_srcname # get kernel version _kernver="$(make LOCALVERSION= kernelrelease)" _basekernel=${_kernver%%-*} _basekernel=${_basekernel%.*} local _modulesdir="$pkgdir/usr/lib/modules/$_kernver" echo "Installing boot image..." # systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 install -Dm644 "$(make -s image_name)" "$_modulesdir/vmlinuz" # Used by mkinitcpio to name the kernel echo "$pkgbase" | install -Dm644 /dev/stdin "$_modulesdir/pkgbase" echo "Installing modules..." make LOCALVERSION= INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install # remove build and source links rm "$_modulesdir"/{source,build} echo "Fixing permissions..." chmod -Rc u=rwX,go=rX "$pkgdir" } _package-headers() { pkgdesc="Header files and scripts for building modules for Linux kernel (git version)" cd $_srcname local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" echo "Installing build files..." install -Dt "$_builddir" -m644 .config Makefile Module.symvers System.map vmlinux install -Dt "$_builddir/kernel" -m644 kernel/Makefile install -Dt "$_builddir/arch/x86" -m644 arch/x86/Makefile cp -t "$_builddir" -a scripts # add objtool for external module building and enabled VALIDATION_STACK option install -Dt "$_builddir/tools/objtool" tools/objtool/objtool # add xfs and shmem for aufs building mkdir -p "$_builddir"/{fs/xfs,mm} echo "Installing headers..." cp -t "$_builddir" -a include cp -t "$_builddir/arch/x86" -a arch/x86/include install -Dt "$_builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s install -Dt "$_builddir/drivers/md" -m644 drivers/md/*.h install -Dt "$_builddir/net/mac80211" -m644 net/mac80211/*.h # http://bugs.archlinux.org/task/13146 install -Dt "$_builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h # http://bugs.archlinux.org/task/20402 install -Dt "$_builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h install -Dt "$_builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h install -Dt "$_builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h echo "Installing KConfig files..." find . -name 'Kconfig*' -exec install -Dm644 {} "$_builddir/{}" \; echo "Removing unneeded architectures..." local _arch for _arch in "$_builddir"/arch/*/; do [[ ${_arch} == */x86/ ]] && continue echo "Removing $(basename "$_arch")" rm -r "$_arch" done echo "Removing documentation..." rm -r "$_builddir/Documentation" echo "Removing broken symlinks..." find -L "$_builddir" -type l -printf 'Removing %P\n' -delete echo "Removing loose objects..." find "$_builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete echo "Stripping build tools..." local file while read -rd '' file; do case "$(file -bi "$file")" in application/x-sharedlib\;*) # Libraries (.so) strip -v $STRIP_SHARED "$file" ;; application/x-archive\;*) # Libraries (.a) strip -v $STRIP_STATIC "$file" ;; application/x-executable\;*) # Binaries strip -v $STRIP_BINARIES "$file" ;; application/x-pie-executable\;*) # Relocatable binaries strip -v $STRIP_SHARED "$file" ;; esac done < <(find "$_builddir" -type f -perm -u+x ! -name vmlinux -print0) echo "Adding symlink..." mkdir -p "$pkgdir/usr/src" ln -sr "_$builddir" "$pkgdir/usr/src/$pkgbase" echo "Fixing permissions..." chmod -Rc u=rwX,go=rX "$pkgdir" } pkgname=("$pkgbase" "$pkgbase-headers") for _p in ${pkgname[@]}; do eval "package_$_p() { $(declare -f "_package${_p#$pkgbase}") _package${_p#$pkgbase} }" done # vim:set ts=8 sts=2 sw=2 et: