Skip to content
Snippets Groups Projects
PKGBUILD 15.2 KiB
Newer Older
Helmut Stult's avatar
Helmut Stult committed
# Maintainer: Philip Müller <philm[at]manjaro[dot]org>
Helmut Stult's avatar
Helmut Stult committed
# Maintainer: Bernhard Landauer <bernhard[at]manjaro[dot]org>
Helmut Stult's avatar
Helmut Stult committed
# Maintainer: Helmut Stult <helmut[at]manjaro[dot]org>

# Arch credits:
Philip Müller's avatar
Philip Müller committed
# Tobias Powalowski <tpowa@archlinux.org>
# Thomas Baechler <thomas@archlinux.org>

Helmut Stult's avatar
Helmut Stult committed
# Cloud Server
_server=cpx51

Philip Müller's avatar
Philip Müller committed
pkgbase=linux57
pkgname=('linux57' 'linux57-headers')
_kernelname=-MANJARO
_basekernel=5.7
_basever=57
Helmut Stult's avatar
Helmut Stult committed
_aufs=20200622
Helmut Stult's avatar
Helmut Stult committed
pkgver=5.7.16
Helmut Stult's avatar
Helmut Stult committed
pkgrel=1
Helmut Stult's avatar
Helmut Stult committed
arch=('x86_64')
Philip Müller's avatar
Philip Müller committed
url="http://www.kernel.org/"
license=('GPL2')
Bernhard Landauer's avatar
Bernhard Landauer committed
makedepends=('bc'
    'docbook-xsl'
    'elfutils'
    'git'
    'inetutils'
    'kmod'
    'xmlto')
Philip Müller's avatar
Philip Müller committed
options=('!strip')
Helmut Stult's avatar
Helmut Stult committed
source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.xz"
Philip Müller's avatar
Philip Müller committed
        "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz"
Philip Müller's avatar
Philip Müller committed
        # the main kernel config files
Helmut Stult's avatar
Helmut Stult committed
        'config' 'config.aufs'
Philip Müller's avatar
Philip Müller committed
        # AUFS Patches
        "aufs5.x-rcN-${_aufs}.patch"
        'aufs5-base.patch'
        'aufs5-kbuild.patch'
        'aufs5-loopback.patch'
        'aufs5-mmap.patch'
        'aufs5-standalone.patch'
        'tmpfs-idr.patch'
        'vfs-ino.patch'
        # ARCH Patches
        '0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-CLONE_NEWUSER.patch'
Philip Müller's avatar
Philip Müller committed
        '0001-pci-edr-log-only-ACPI_NOTIFY_DISCONNECT_RECOVER-events.patch'
Philip Müller's avatar
Philip Müller committed
        # MANJARO Patches
Philip Müller's avatar
Philip Müller committed
        '0001-i2c-nuvoton-nc677x-hwmon-driver.patch'
Philip Müller's avatar
Philip Müller committed
        '0001-iomap-iomap_bmap-should-accept-unwritten-maps.patch'
Helmut Stult's avatar
Helmut Stult committed
        '0001-futex.patch'
Philip Müller's avatar
Philip Müller committed
        '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 P50 multiple fans
        '0005-thinkpad_acpi_dual_fan_control.patch::https://github.com/dvhart/linux-pdx86/commit/26c16f9d956f269bbc32e034e3ec11c4831137de.patch'
Helmut Stult's avatar
Helmut Stult committed
         # Lenovo + AMD
        '0001-nonupstream-navi10-vfio-reset.patch'
Helmut Stult's avatar
Helmut Stult committed
        '0001-lenovo-wmi1.patch'
        '0001-lenovo-wmi2.patch'
Helmut Stult's avatar
Helmut Stult committed
        '0002-pinctrl-amd.patch'
Philip Müller's avatar
Philip Müller committed
        # 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'
Helmut Stult's avatar
Helmut Stult committed
        '0013-bootsplash.patch')
Helmut Stult's avatar
Helmut Stult committed
sha256sums=('de8163bb62f822d84f7a3983574ec460060bf013a78ff79cd7c979ff1ec1d7e0'
Helmut Stult's avatar
Helmut Stult committed
            'a92ea94be7ac53f256610be9b4f04d3fc8d6e58ed29c0724708806a2d6f64796'
            '85d520b3c4d605749003f6d155c5710453c4f596024730e3f19f14f0bfe5f861'
Philip Müller's avatar
Philip Müller committed
            'b44d81446d8b53d5637287c30ae3eb64cae0078c3fbc45fcf1081dd6699818b5'
Helmut Stult's avatar
Helmut Stult committed
            '4554b519718527b24800fefc7a250ab707875a75ebfbe56b9080b7bf6079ce02'
Helmut Stult's avatar
Helmut Stult committed
            'a320441bd4540eaf6ed10bbcfb9714bd6d358852aacf0da63330c40a1ad3732c'
            '2ccc807cc6f0fc21f8e23e2e9fd080eb1bc12c3450779e7025ebeaeee2ecffb4'
            '842d2cb05d5796479654634a3cc6623513cefbfdf135a1471dbbfa994166ec14'
            '499d25d110f9867e6aa3a9eb085005d7e59795ab4e0023d6fce21e7b8c21f383'
            '3e45b6d925fc7490ce6597b7d353dd7a8e0681dd192e241f8c6491341673e30d'
Helmut Stult's avatar
Helmut Stult committed
            '9e7ce0431a786444e95e05dafde2d75387fb75d0709dcc807915d638879701cd'
Helmut Stult's avatar
Helmut Stult committed
            '20abad2643c635210c925c3ce3a12eb31f813819d6e661c6d99d9cc3163fbef7'
Philip Müller's avatar
Philip Müller committed
            '7685d526bbdbfa795986591a70071c960ff572f56d3501774861728a9df8664c'
Philip Müller's avatar
Philip Müller committed
            'd1aba2b46e810374e49296760959da48e58d88c36e377479a54e7636e1ba7dc0'
Philip Müller's avatar
Philip Müller committed
            '0556859a8168c8f7da9af8e2059d33216d9e5378d2cac70ca54c5ff843fa5add'
Philip Müller's avatar
Philip Müller committed
            '95745075edd597caa92b369cfbcd11a04c9e3c88c0c987c70114924e1e01df5c'
Helmut Stult's avatar
Helmut Stult committed
            '78dde51123a21ec5efe9c420b309d03263001dafd8684f71c167f02e3f504f9e'
Philip Müller's avatar
Philip Müller committed
            '98202b8ad70d02d86603294bae967874fa7b18704b5c7b867568b0fd33a08921'
            '5cbbf3db9ea3205e9b89fe3049bea6dd626181db0cb0dc461e4cf5a400c68dd6'
            'c7dbec875d0c1d6782c037a1dcefff2e5bdb5fc9dffac1beea07dd8c1bdef1d7'
            '77746aea71ffb06c685e7769b49c78e29af9b2e28209cd245e95d9cbb0dba3c9'
            'f93707e75ec6be5f289605f913e59d4f3514524a1aab3368f49bf6789723d443'
Helmut Stult's avatar
Helmut Stult committed
            'f1eec160ce5df5c2ea58d4e4fd44a6b1013863c6b3bf649414cd18c89ae500fa'
Helmut Stult's avatar
Helmut Stult committed
            '7d2af76b8dae73946379b967a493b927d76a68bb524b275b7c445bab90995687'
            '1d58ef2991c625f6f0eb33b4cb8303932f53f1c4694e42bae24c9cd36d2ad013'
Philip Müller's avatar
Philip Müller committed
            '427fd41ac742110d413f01daba66d5cd023b8e63fdc63242fcc96f589e66867f'
Philip Müller's avatar
Philip Müller committed
            'a504f6cf84094e08eaa3cc5b28440261797bf4f06f04993ee46a20628ff2b53c'
            'e096b127a5208f56d368d2cb938933454d7200d70c86b763aa22c38e0ddb8717'
            '8c1c880f2caa9c7ae43281a35410203887ea8eae750fe8d360d0c8bf80fcc6e0'
            '1144d51e5eb980fceeec16004f3645ed04a60fac9e0c7cf88a15c5c1e7a4b89e'
            'dd4b69def2efacf4a6c442202ad5cb93d492c03886d7c61de87696e5a83e2846'
            '028b07f0c954f70ca37237b62e04103e81f7c658bb8bd65d7d3c2ace301297dc'
            'c8b0cb231659d33c3cfaed4b1f8d7c8305ab170bdd4c77fce85270d7b6a68000'
            '8dbb5ab3cb99e48d97d4e2f2e3df5d0de66f3721b4f7fd94a708089f53245c77'
            'a7aefeacf22c600fafd9e040a985a913643095db7272c296b77a0a651c6a140a'
            'e9f22cbb542591087d2d66dc6dc912b1434330ba3cd13d2df741d869a2c31e89'
            '27471eee564ca3149dd271b0817719b5565a9594dc4d884fe3dc51a5f03832bc'
            '60e295601e4fb33d9bf65f198c54c7eb07c0d1e91e2ad1e0dd6cd6e142cb266d'
Helmut Stult's avatar
Helmut Stult committed
            '035ea4b2a7621054f4560471f45336b981538a40172d8f17285910d4e0e0b3ef')
Philip Müller's avatar
Philip Müller committed
prepare() {
  cd "${srcdir}/linux-${_basekernel}"

  # add upstream patch
Philip Müller's avatar
Philip Müller committed
  msg "add upstream patch"
Philip Müller's avatar
Philip Müller committed
  patch -p1 -i "${srcdir}/patch-${pkgver}"
Philip Müller's avatar
Philip Müller committed

  # add latest fixes from stable queue, if needed
  # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  # enable only if you have "gen-stable-queue-patch.sh" executed before
  #patch -Np1 -i "${srcdir}/prepatch-${_basekernel}.patch"

  # disable USER_NS for non-root users by default
Helmut Stult's avatar
Helmut Stult committed
  msg2 "PATCH: 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-CLONE_NEWUSER"
Helmut Stult's avatar
Helmut Stult committed
  patch -Np1 -i "${srcdir}/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-CLONE_NEWUSER.patch"
Helmut Stult's avatar
Helmut Stult committed

Philip Müller's avatar
Philip Müller committed
  # other fixes by Arch
Helmut Stult's avatar
Helmut Stult committed
  msg "add fixes by Arch"
  msg2 "0001-pci-edr-log-only-ACPI_NOTIFY_DISCONNECT_RECOVER-events"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0001-pci-edr-log-only-ACPI_NOTIFY_DISCONNECT_RECOVER-events.patch"
Helmut Stult's avatar
Helmut Stult committed

Philip Müller's avatar
Philip Müller committed
  # add patches for snapd
  # https://gitlab.com/apparmor/apparmor-kernel/tree/5.2-outoftree
Helmut Stult's avatar
Helmut Stult committed
  msg "add patches for snapd"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0001-apparmor-patch-to-provide-compatibility-with-v2-net-rules"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0001-apparmor-patch-to-provide-compatibility-with-v2-net-rules.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0002-apparmor-af_unix-mediation"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0002-apparmor-af_unix-mediation.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0003-apparmor-fix-use-after-free-in-sk_peer_label"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0003-apparmor-fix-use-after-free-in-sk_peer_label.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0004-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0004-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch"
Helmut Stult's avatar
Helmut Stult committed

Helmut Stult's avatar
Helmut Stult committed
  msg "nuvoton hwmon driver patch"
  # https://twitter.com/vskye11/status/1216240051639791616
  patch -Np1 -i '../0001-i2c-nuvoton-nc677x-hwmon-driver.patch'

  # Lenovo + AMD
  msg "Lenovo + AMD"

  msg2 "navi10-vfio reset patch"
Philip Müller's avatar
Philip Müller committed
  # TODO: remove when AMD properly fixes it!
  # INFO: this is a hack and won't be upstreamed
  # https://forum.level1techs.com/t/145666/86
  # https://forum.manjaro.org/t/107820/11
  patch -Np1 -i "${srcdir}/0001-nonupstream-navi10-vfio-reset.patch"

Helmut Stult's avatar
Helmut Stult committed
  msg2 "0001-lenovo-wmi1"
  patch -Np1 -i '../0001-lenovo-wmi1.patch'
  msg2 "0001-lenovo-wmi2"
  patch -Np1 -i '../0001-lenovo-wmi2.patch'
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0002-pinctrl-amd"
  patch -Np1 -i '../0002-pinctrl-amd.patch'
Helmut Stult's avatar
Helmut Stult committed

  # handling of multiple fans on Lenovo P50
  # https://github.com/vmatare/thinkfan/issues/58
Helmut Stult's avatar
Helmut Stult committed
  msg "handling of multiple fans on Lenovo P50"
  msg2 "PATCH: Thinkpad dual fan control"
  patch -Np1 -i "${srcdir}/0005-thinkpad_acpi_dual_fan_control.patch"
Helmut Stult's avatar
Helmut Stult committed

Philip Müller's avatar
Philip Müller committed
  # https://bugzilla.kernel.org/show_bug.cgi?id=207585
Helmut Stult's avatar
Helmut Stult committed
  msg "handling of multiple fans on Lenovo P50"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0001-iomap-iomap_bmap-should-accept-unwritten-maps.patch"

Helmut Stult's avatar
Helmut Stult committed
  # futex patch, https://lore.kernel.org/lkml/20200612185122.327860-1-andrealmeid@collabora.com/
  msg2 "0001-futex.patch"
  patch -Np1 -i "${srcdir}/0001-futex.patch"

Philip Müller's avatar
Philip Müller committed
  # Add bootsplash - http://lkml.iu.edu/hypermail/linux/kernel/1710.3/01542.html
Helmut Stult's avatar
Helmut Stult committed
  msg "Add bootsplash"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0001-bootsplash."
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0001-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0002-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0002-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0003-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0003-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0004-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0004-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0005-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0005-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0006-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0006-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0007-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0007-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0008-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0008-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0009-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0009-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0010-bootsplash."
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0010-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0011-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0011-bootsplash.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0012-bootsplash"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/0012-bootsplash.patch"
  # use git-apply to add binary files
Helmut Stult's avatar
Helmut Stult committed
  msg2 "0013-bootsplash"
Philip Müller's avatar
Philip Müller committed
  git apply -p1 < "${srcdir}/0013-bootsplash.patch"

  # add aufs5 support
Helmut Stult's avatar
Helmut Stult committed
  msg "add aufs5 support"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "aufs5.x-rcN-${_aufs}"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/aufs5.x-rcN-${_aufs}.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "aufs5-base"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/aufs5-base.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "aufs5-kbuild"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/aufs5-kbuild.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "aufs5-loopback"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/aufs5-loopback.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "aufs5-mmap"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/aufs5-mmap.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "aufs5-standalone"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/aufs5-standalone.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "tmpfs-idr"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/tmpfs-idr.patch"
Helmut Stult's avatar
Helmut Stult committed
  msg2 "vfs-ino"
Philip Müller's avatar
Philip Müller committed
  patch -Np1 -i "${srcdir}/vfs-ino.patch"

Helmut Stult's avatar
Helmut Stult committed
  cat "${srcdir}/config" > ./.config
Philip Müller's avatar
Philip Müller committed

  cat "${srcdir}/config.aufs" >> ./.config

  if [ "${_kernelname}" != "" ]; then
    sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
    sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
  fi

Helmut Stult's avatar
Helmut Stult committed
  msg "set extraversion to pkgrel"
Philip Müller's avatar
Philip Müller committed
  sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile

Helmut Stult's avatar
Helmut Stult committed
  msg "don't run depmod on 'make install'"
  # We'll do this ourselves in packaging
Philip Müller's avatar
Philip Müller committed
  sed -i '2iexit 0' scripts/depmod.sh

Helmut Stult's avatar
Helmut Stult committed
  msg "get kernel version"
Philip Müller's avatar
Philip Müller committed
  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
  # ... or manually edit .config

Helmut Stult's avatar
Helmut Stult committed
  msg "rewrite configuration"
Philip Müller's avatar
Philip Müller committed
  yes "" | make config >/dev/null
}

build() {
  cd "${srcdir}/linux-${_basekernel}"

Helmut Stult's avatar
Helmut Stult committed
  msg "build"
Philip Müller's avatar
Philip Müller committed
  make ${MAKEFLAGS} LOCALVERSION= bzImage modules
}

package_linux57() {
  pkgdesc="The ${pkgbase/linux/Linux} kernel and modules"
  depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=27')
  optdepends=('crda: to set the correct wireless channels of your country')
  provides=("linux=${pkgver}" VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
Philip Müller's avatar
Philip Müller committed

  cd "${srcdir}/linux-${_basekernel}"

  KARCH=x86

  # get kernel version
  _kernver="$(make LOCALVERSION= kernelrelease)"

  mkdir -p "${pkgdir}"/{boot,usr/lib/modules}
Bernhard Landauer's avatar
Bernhard Landauer committed
  make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 modules_install
Philip Müller's avatar
Philip Müller committed

  # 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"

  # 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"

  # add kernel version
Helmut Stult's avatar
Helmut Stult committed
  echo "${pkgver}-${pkgrel}-MANJARO x64" > "${pkgdir}/boot/${pkgbase}-${CARCH}.kver"
Philip Müller's avatar
Philip Müller committed

  # make room for external modules
  local _extramodules="extramodules-${_basekernel}${_kernelname:--MANJARO}"
  ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules"

  # add real version for building modules and running depmod from hook
  echo "${_kernver}" |
    install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version"

  # 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
}

package_linux57-headers() {
  pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel"
  provides=("linux-headers=$pkgver")

  cd "${srcdir}/linux-${_basekernel}"
  local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"

  install -Dt "${_builddir}" -m644 Makefile .config Module.symvers
  install -Dt "${_builddir}/kernel" -m644 kernel/Makefile

  mkdir "${_builddir}/.tmp_versions"

  cp -t "${_builddir}" -a include scripts

  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"

  cp -t "${_builddir}/arch/${KARCH}" -a "arch/${KARCH}/include"

  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

  # add xfs and shmem for aufs building
  mkdir -p "${_builddir}"/{fs/xfs,mm}

  # copy in Kconfig files
  find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \;

Helmut Stult's avatar
Helmut Stult committed
  # add objtool for external module building and enabled VALIDATION_STACK option
  install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool
Philip Müller's avatar
Philip Müller committed

  # remove unneeded architectures
  local _arch
  for _arch in "${_builddir}"/arch/*/; do
    [[ ${_arch} == */x86/ ]] && continue
    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 ;;
    esac
    /usr/bin/strip ${_strip} "${_binary}"
  done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null)
}