diff options
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 516 |
1 files changed, 296 insertions, 220 deletions
@@ -1,19 +1,19 @@ -# Contributor: Andrey Alekseev <andrey.android7890@gmail.com> -# used original PKGBUILD from Manjaro linux: https://gitlab.manjaro.org/packages/core/linux58 -# https://aur.archlinux.org/packages/linux-xanmod/ -# see "PKGBUILD_change.patch" for details - - -# Maintainer: Philip Müller <philm[at]manjaro[dot]org> -# Maintainer: Bernhard Landauer <bernhard[at]manjaro[dot]org> -# Maintainer: Helmut Stult <helmut[at]manjaro[dot]org> - -# Arch credits: -# Tobias Powalowski <tpowa@archlinux.org> -# Thomas Baechler <thomas@archlinux.org> - -# Cloud Server -_server=cpx51 +# Maintainer: Andrey Alekseev <andrey.android7890@gmail.com> + +# https://gitlab.manjaro.org/packages/core/linux58 +# +# Maintainer: Philip Müller +# Maintainer: Bernhard Landauer +# Maintainer: Helmut Stult + +# http://aur.archlinux.org/packages/linux-xanmod +# +# Maintainer: Joan Figueras +# Contributor: Torge Matthies +# Contributor: Jan Alexander Steffens (heftig) +# Contributor: Yoshi2889 +# Contributor: Tobias Powalowski +# Contributor: Thomas Baechler ## ## The following variables can be customized at build time. Use env or export to change at your wish @@ -28,267 +28,343 @@ if [ -z ${_microarchitecture+x} ]; then _microarchitecture=0 fi +## Disable NUMA since most users do not have multiple processors. Breaks CUDA/NvEnc. +## Archlinux and Xanmod enable it by default. +## Set variable "use_numa" to: n to disable (possibly increase performance) +## y to enable (stock default) +if [ -z ${use_numa+x} ]; then + use_numa=y +fi + +## For performance you can disable FUNCTION_TRACER/GRAPH_TRACER. Limits debugging and analyzing of the kernel. +## Stock Archlinux and Xanmod have this enabled. +## Set variable "use_tracers" to: n to disable (possibly increase performance) +## y to enable (stock default) +if [ -z ${use_tracers+x} ]; then + use_tracers=y +fi + +## Enable Cachy CPU scheduler by default https://github.com/xanmod/linux/blob/5.8/Documentation/scheduler/sched-Cachy.rst +## Set variable "use_cachy" to: n to disable (stock Xanmod) +## y to enable +if [ -z ${use_cachy+x} ]; then + use_cachy=n +fi + +## Enable CONFIG_USER_NS_UNPRIVILEGED flag https://aur.archlinux.org/cgit/aur.git/tree/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch?h=linux-ck +## Set variable "use_ns" to: n to disable (stock Xanmod) +## y to enable (stock Archlinux) +if [ -z ${use_ns+x} ]; then + use_ns=n +fi + +# Compile ONLY used modules to VASTLYreduce the number of modules built +# and the build time. +# +# To keep track of which modules are needed for your specific system/hardware, +# give module_db script a try: https://aur.archlinux.org/packages/modprobed-db +# This PKGBUILD read the database kept if it exists +# +# More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db +if [ -z ${_localmodcfg} ]; then + _localmodcfg=n +fi + +# Tweak kernel options prior to a build via nconfig +_makenconfig= + +### IMPORTANT: Do no edit below this line unless you know what you're doing + pkgbase=linux-manjaro-xanmod pkgname=("${pkgbase}" "${pkgbase}-headers") -_kernelname=-MANJARO-Xanmod -_basekernel=5.8 -_basever=58 -_aufs=20200622 -pkgver=5.8.6 +pkgver=5.8.14 +_major=5.8 +_branch=5.x xanmod=1 pkgrel=1 -arch=('x86_64') -url="http://www.kernel.org/" -license=('custom') -makedepends=('bc' - 'docbook-xsl' - 'elfutils' - 'git' - 'inetutils' - 'kmod' - 'xmlto') +pkgdesc='Linux Xanmod' +url="http://www.xanmod.org/" +arch=(x86_64) + +__commit="1dfdc631d35094a902c0c64e98668e417a4cbc91" # 5.8.14-1 + +license=(GPL2) +makedepends=( + xmlto kmod inetutils bc libelf cpio + python-sphinx python-sphinx_rtd_theme graphviz imagemagick git +) options=('!strip') -source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.xz" - #"https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz" - # xanmod patch +_srcname="linux-${pkgver}-xanmod${xanmod}" +source=("https://cdn.kernel.org/pub/linux/kernel/v${_branch}/linux-${_major}.tar."{xz,sign} "https://github.com/xanmod/linux/releases/download/${pkgver}-xanmod${xanmod}/patch-${pkgver}-xanmod${xanmod}.xz" - # gcc optimizations choose-gcc-optimization.sh - # the main kernel config files - 'config' 'config.aufs' 'config.anbox' - # ARCH Patches - '0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-CLONE_NEWUSER.patch' - # MANJARO Patches - '0001-i2c-nuvoton-nc677x-hwmon-driver.patch' - '0001-iomap-iomap_bmap-should-accept-unwritten-maps.patch' - #'0001-futex.patch' - '0001-apparmor-patch-to-provide-compatibility-with-v2-net-rules.patch' - '0002-apparmor-af_unix-mediation.patch' - '0003-apparmor-fix-use-after-free-in-sk_peer_label.patch' - '0004-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch' - - # Lenovo + AMD - '0001-lenovo-wmi2.patch' - '0002-pinctrl-amd.patch' - - # Temp Fixes - 'virtualbox-temp.patch' - - # Bootsplash - '0001-bootsplash.patch' - '0002-bootsplash.patch' - '0003-bootsplash.patch' - '0004-bootsplash.patch' - '0005-bootsplash.patch' - '0006-bootsplash.patch' - '0007-bootsplash.patch' - '0008-bootsplash.patch' - '0009-bootsplash.patch' - '0010-bootsplash.patch' - '0011-bootsplash.patch' - '0012-bootsplash.patch' - '0013-bootsplash.gitpatch') + "manjaro.tar.gz::https://gitlab.manjaro.org/packages/core/linux58/-/archive/${__commit}/linux58-${__commit}.tar.gz") sha256sums=('e7f75186aa0642114af8f19d99559937300ca27acaf7451b36d4f9b0f85cf1f5' - #'b4ab9987a715753e64f0aa264dac91c3d7ca0651bfdd8fa5d19c8990f3b08abc' 'SKIP' - 'SKIP' - '0ecba3688f213c56b443145c5ffcf3ddfbe9cb0ee4c1fc4bd1351266224ad997' - 'b44d81446d8b53d5637287c30ae3eb64cae0078c3fbc45fcf1081dd6699818b5' - 'c079a87a7de0001f5f2b7a42a822c262e31f19f2c547613885f273822c9d4dcc' - '986f8d802f37b72a54256f0ab84da83cb229388d58c0b6750f7c770818a18421' - '7823d7488f42bc4ed7dfae6d1014dbde679d8b862c9a3697a39ba0dae5918978' - '95745075edd597caa92b369cfbcd11a04c9e3c88c0c987c70114924e1e01df5c' - #'78dde51123a21ec5efe9c420b309d03263001dafd8684f71c167f02e3f504f9e' - '98202b8ad70d02d86603294bae967874fa7b18704b5c7b867568b0fd33a08921' - '5cbbf3db9ea3205e9b89fe3049bea6dd626181db0cb0dc461e4cf5a400c68dd6' - 'c7dbec875d0c1d6782c037a1dcefff2e5bdb5fc9dffac1beea07dd8c1bdef1d7' - '77746aea71ffb06c685e7769b49c78e29af9b2e28209cd245e95d9cbb0dba3c9' - '1d58ef2991c625f6f0eb33b4cb8303932f53f1c4694e42bae24c9cd36d2ad013' - '427fd41ac742110d413f01daba66d5cd023b8e63fdc63242fcc96f589e66867f' - 'c98893aafd51e83107bb6823cbe3c63ee85c00f439c1facaed3b6ab3c0490e98' - 'a504f6cf84094e08eaa3cc5b28440261797bf4f06f04993ee46a20628ff2b53c' - 'e096b127a5208f56d368d2cb938933454d7200d70c86b763aa22c38e0ddb8717' - '8c1c880f2caa9c7ae43281a35410203887ea8eae750fe8d360d0c8bf80fcc6e0' - '1144d51e5eb980fceeec16004f3645ed04a60fac9e0c7cf88a15c5c1e7a4b89e' - 'dd4b69def2efacf4a6c442202ad5cb93d492c03886d7c61de87696e5a83e2846' - '028b07f0c954f70ca37237b62e04103e81f7c658bb8bd65d7d3c2ace301297dc' - 'c8b0cb231659d33c3cfaed4b1f8d7c8305ab170bdd4c77fce85270d7b6a68000' - '8dbb5ab3cb99e48d97d4e2f2e3df5d0de66f3721b4f7fd94a708089f53245c77' - 'a7aefeacf22c600fafd9e040a985a913643095db7272c296b77a0a651c6a140a' - 'e9f22cbb542591087d2d66dc6dc912b1434330ba3cd13d2df741d869a2c31e89' - '27471eee564ca3149dd271b0817719b5565a9594dc4d884fe3dc51a5f03832bc' - '60e295601e4fb33d9bf65f198c54c7eb07c0d1e91e2ad1e0dd6cd6e142cb266d' - '035ea4b2a7621054f4560471f45336b981538a40172d8f17285910d4e0e0b3ef') + '5ad21f97be90f5feaf09a023a3bad2155eefd0025781150d9b09cfceda75ee1b' + '2c7369218e81dee86f8ac15bda741b9bb34fa9cefcb087760242277a8207d511' + 'a10426315a98f862a8656ba0dd435bfca6440c682b1f0f4475bbe9937f0528d9') +validpgpkeys=( + 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linux Torvalds + '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman +) + +# Archlinux patches +_commits="" +for _patch in $_commits; do + source+=("${_patch}.patch::https://git.archlinux.org/linux.git/patch/?id=${_patch}") +done + +export KBUILD_BUILD_HOST=${KBUILD_BUILD_HOST:-archlinux} +export KBUILD_BUILD_USER=${KBUILD_BUILD_USER:-makepkg} +export KBUILD_BUILD_TIMESTAMP=${KBUILD_BUILD_TIMESTAMP:-$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})} + prepare() { - cd "${srcdir}/linux-${_basekernel}" - - # Let's user choose microarchitecture optimization in GCC - sh ${srcdir}/choose-gcc-optimization.sh $_microarchitecture - - # add upstream patch - #msg "add upstream patch" - #patch -p1 -i "${srcdir}/patch-${pkgver}" + cd linux-${_major} # Apply Xanmod patch patch -Np1 -i ../patch-${pkgver}-xanmod${xanmod} - + + msg2 "Setting version..." + scripts/setlocalversion --save-scmversion + #echo "-$pkgrel" > localversion.10-pkgrel + echo "-MANJARO" > localversion.20-pkgname + + # Archlinux patches local src for src in "${source[@]}"; do - src="${src%%::*}" - src="${src##*/}" - [[ $src = *.patch ]] || continue - msg2 "Applying patch: $src..." - patch -Np1 < "../$src" + src="${src%%::*}" + src="${src##*/}" + [[ $src = *.patch ]] || continue + msg2 "Applying patch $src..." + patch -Np1 < "../$src" done + + # Manjaro patches + rm ../linux58-$__commit/0001-fix-iwlwifi.patch + rm ../linux58-$__commit/0103-futex.patch + local _patch + for _patch in ../linux58-$__commit/*; do + [[ $_patch = *.patch ]] || continue + msg2 "Applying patch: $_patch..." + patch -Np1 < "../linux58-$__commit/$_patch" + done + git apply -p1 < "../linux58-$__commit/0513-bootsplash.gitpatch" + scripts/config --enable CONFIG_BOOTSPLASH + + # CONFIG_STACK_VALIDATION gives better stack traces. Also is enabled in all official kernel packages by Archlinux team + scripts/config --enable CONFIG_STACK_VALIDATION + + # Enable IKCONFIG following Arch's philosophy + scripts/config --enable CONFIG_IKCONFIG \ + --enable CONFIG_IKCONFIG_PROC + + # User set. See at the top of this file + if [ "$use_tracers" = "n" ]; then + msg2 "Disabling FUNCTION_TRACER/GRAPH_TRACER..." + scripts/config --disable CONFIG_FUNCTION_TRACER \ + --disable CONFIG_STACK_TRACER + fi - msg2 "0013-bootsplash" - git apply -p1 < "${srcdir}/0013-bootsplash.gitpatch" + if [ "$use_numa" = "n" ]; then + msg2 "Disabling NUMA..." + scripts/config --disable CONFIG_NUMA + fi - cat "${srcdir}/config" > ./.config + if [ "$use_cachy" = "y" ]; then + msg2 "Enabling Cachy CPU scheduler by default (also NUMA and grouping for tasks, which are not compatible with Cachy)..." + scripts/config --disable CONFIG_NUMA + scripts/config --disable FAIR_GROUP_SCHED + scripts/config --enable CONFIG_CACHY_SCHED + fi - if [ "${_kernelname}" != "" ]; then - sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config - sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config + if [ "$use_ns" = "n" ]; then + msg2 "Disabling CONFIG_USER_NS_UNPRIVILEGED" + scripts/config --disable CONFIG_USER_NS_UNPRIVILEGED fi + + msg2 "add anbox support" + scripts/config --enable CONFIG_ASHMEM + # CONFIG_ION is not set + scripts/config --enable CONFIG_ANDROID + scripts/config --enable CONFIG_ANDROID_BINDER_IPC + scripts/config --enable CONFIG_ANDROID_BINDERFS + scripts/config --set-str CONFIG_ANDROID_BINDER_DEVICES "binder,hwbinder,vndbinder" + # CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set + + scripts/config --set-str CONFIG_DEFAULT_HOSTNAME="manjaro" - msg "set extraversion to pkgrel" - sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile + # Let's user choose microarchitecture optimization in GCC + sh ${srcdir}/choose-gcc-optimization.sh $_microarchitecture - msg "don't run depmod on 'make install'" - # We'll do this ourselves in packaging - sed -i '2iexit 0' scripts/depmod.sh + # This is intended for the people that want to build this package with their own config + # Put the file "myconfig" at the package folder to use this feature + # If it's a full config, will be replaced + # If not, you should use scripts/config commands, one by line + if [ -f "${startdir}/myconfig" ]; then + if [ $(wc -l < "${startdir}/myconfig") -gt 1000 ]; then + # myconfig is a full config file. Replace it + msg2 "Using user CUSTOM config..." + cp -f "${startdir}"/myconfig .config + else + # myconfig is a partial file. Applying every line + msg2 "Applying configs..." + cat "${startdir}"/myconfig | while read -r _linec ; do + if echo "$_linec" | grep "scripts/config" ; then + set -- $_linec + "$@" + else + warning "Line format incorrect, ignoring..." + fi + done + fi + echo + fi - msg "get kernel version" make olddefconfig - # 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 - # ... or manually edit .config + ### Optionally load needed modules for the make localmodconfig + # See https://aur.archlinux.org/packages/modprobed-db + if [ "$_localmodcfg" = "y" ]; then + if [ -f $HOME/.config/modprobed.db ]; then + msg2 "Running Steven Rostedt's make localmodconfig now" + make LSMOD=$HOME/.config/modprobed.db localmodconfig + else + msg2 "No modprobed.db data found" + exit + fi + fi + + make -s kernelrelease > version + msg2 "Prepared %s version %s" "$pkgbase" "$(<version)" + + [[ -z "$_makenconfig" ]] || make nconfig - msg "rewrite configuration" - yes "" | make config >/dev/null + # save configuration for later reuse + cat .config > "${startdir}/config.last" } build() { - cd "${srcdir}/linux-${_basekernel}" - - msg "build" - make ${MAKEFLAGS} LOCALVERSION= bzImage modules + cd linux-${_major} + make all } -package_linux-manjaro-xanmod() { +_package() { pkgdesc="The Linux kernel and modules with Xanmod and Manjaro patches (Bootsplash support)" - depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=27') + depends=('coreutils' 'linux-firmware' 'kmod' 'initramfs' 'mkinitcpio>=27') optdepends=('crda: to set the correct wireless channels of your country' - 'bootsplash-systemd: to enable bootsplash') - provides=("linux=${pkgver}" VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE) - - cd "${srcdir}/linux-${_basekernel}" - - KARCH=x86 - - # get kernel version - _kernver="$(make LOCALVERSION= kernelrelease)" + 'linux-firmware: firmware images needed for some devices' + 'bootsplash-systemd: for bootsplash functionality') + provides=('linux' VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE) + replaces=() + conflicts=() - mkdir -p "${pkgdir}"/{boot,usr/lib/modules} - make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 modules_install + cd linux-${_major} + local kernver="$(<version)" + local modulesdir="$pkgdir/usr/lib/modules/$kernver" + msg2 "Installing boot image..." # systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 - cp arch/$KARCH/boot/bzImage "${pkgdir}/usr/lib/modules/${_kernver}/vmlinuz" + install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz" # Used by mkinitcpio to name the kernel - echo "${pkgbase}" | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_kernver}/pkgbase" - echo "${_basekernel}-${CARCH}" | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_kernver}/kernelbase" - + echo "manjaro-xanmod" | install -Dm644 /dev/stdin "$modulesdir/pkgbase" + # echo "${_major}-${CARCH}" | install -Dm644 /dev/stdin "$modulesdir/kernelbase" + # add kernel version - echo "${pkgver}-${pkgrel}-MANJARO x64" > "${pkgdir}/boot/${pkgbase}-${CARCH}.kver" - - # make room for external modules - local _extramodules="extramodules-${_basekernel}${_kernelname:--MANJARO}" - ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules" + echo "${pkgver}-${pkgrel}-Manjaro-Xanmod x64" > "${pkgdir}/boot/${pkgbase}.kver" - # add real version for building modules and running depmod from hook - echo "${_kernver}" | - install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version" + msg2 "Installing modules..." + make INSTALL_MOD_PATH="$pkgdir/usr" modules_install # remove build and source links - rm "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build} - - # now we call depmod... - depmod -b "${pkgdir}/usr" -F System.map "${_kernver}" - - # add vmlinux - install -Dt "${pkgdir}/usr/lib/modules/${_kernver}/build" -m644 vmlinux + rm "$modulesdir"/{source,build} } -package_linux-manjaro-xanmod-headers() { - pkgdesc="Header files and scripts for building modules for ${pkgbase} kernel" - provides=("linux-headers=$pkgver") - - cd "${srcdir}/linux-${_basekernel}" - local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" +_package-headers() { + pkgdesc="Header files and scripts for building modules for linux-manjaro-xanmod kernel" + provides=('linux-headers') + replaces=() + conflicts=() - install -Dt "${_builddir}" -m644 Makefile .config Module.symvers - install -Dt "${_builddir}/kernel" -m644 kernel/Makefile + cd linux-${_major} + local builddir="$pkgdir/usr/lib/modules/$(<version)/build" - mkdir "${_builddir}/.tmp_versions" + msg2 "Installing build files..." + install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \ + localversion.* version vmlinux + install -Dt "$builddir/kernel" -m644 kernel/Makefile + install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile + cp -t "$builddir" -a scripts - cp -t "${_builddir}" -a include scripts + # add objtool for external module building and enabled VALIDATION_STACK option + install -Dt "$builddir/tools/objtool" tools/objtool/objtool - install -Dt "${_builddir}/arch/${KARCH}" -m644 "arch/${KARCH}/Makefile" - install -Dt "${_builddir}/arch/${KARCH}/kernel" -m644 "arch/${KARCH}/kernel/asm-offsets.s" - #install -Dt "${_builddir}/arch/${KARCH}/kernel" -m644 "arch/${KARCH}/kernel/macros.s" + # add xfs and shmem for aufs building + mkdir -p "$builddir"/{fs/xfs,mm} - cp -t "${_builddir}/arch/${KARCH}" -a "arch/${KARCH}/include" + msg2 "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 + 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 + 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 - - # add xfs and shmem for aufs building - mkdir -p "${_builddir}"/{fs/xfs,mm} - - # copy in Kconfig files - find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \; - - # add objtool for external module building and enabled VALIDATION_STACK option - install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool - - # remove unneeded architectures - local _arch - for _arch in "${_builddir}"/arch/*/; do - [[ ${_arch} == */x86/ ]] && continue - rm -r "${_arch}" + 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 + + msg2 "Installing KConfig files..." + find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \; + + msg2 "Removing unneeded architectures..." + local arch + for arch in "$builddir"/arch/*/; do + [[ $arch = */x86/ ]] && continue + echo "Removing $(basename "$arch")" + rm -r "$arch" done - # remove files already in linux-docs package - rm -r "${_builddir}/Documentation" - - # Fix permissions - chmod -R u=rwX,go=rX "${_builddir}" - - # strip scripts directory - local _binary _strip - while read -rd '' _binary; do - case "$(file -bi "${_binary}")" in - *application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so) - *application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a) - *application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries - *) continue ;; + msg2 "Removing documentation..." + rm -r "$builddir/Documentation" + + msg2 "Removing broken symlinks..." + find -L "$builddir" -type l -printf 'Removing %P\n' -delete + + msg2 "Removing loose objects..." + find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete + + msg2 "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 - /usr/bin/strip ${_strip} "${_binary}" - done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null) + done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0) + + msg2 "Adding symlink..." + mkdir -p "$pkgdir/usr/src" + ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase" } + +pkgname=("${pkgbase}" "${pkgbase}-headers") +for _p in "${pkgname[@]}"; do + eval "package_$_p() { + $(declare -f "_package${_p#$pkgbase}") + _package${_p#$pkgbase} + }" +done |