# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.9.71 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=0 pkgdesc="Linux vanilla kernel" url="http://kernel.org" depends="mkinitfs linux-firmware" makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev" options="!strip" _config=${config:-config-vanilla.${CARCH}} install= source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz 0001-HID-apple-fix-Fn-key-Magic-Keyboard-on-bluetooth.patch config-vanilla.aarch64 config-vanilla.armhf config-vanilla.x86 config-vanilla.x86_64 config-vanilla.ppc config-vanilla.ppc64le config-vanilla.s390x " if [ "${pkgver%.0}" = "$pkgver" ]; then source="$source https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" fi subpackages="$pkgname-dev::$CBUILD_ARCH" arch="all" license="GPL2" _abi_release=${pkgver} _carch=${CARCH} case "$_carch" in aarch64*) _carch="arm64" ;; arm*) _carch="arm" ;; ppc*) _carch="powerpc" ;; s390*) _carch="s390" ;; esac HOSTCC="${CC:-gcc}" HOSTCC="${HOSTCC#${CROSS_COMPILE}}" prepare() { local _patch_failed= cd "$srcdir"/linux-$_kernver if [ "$_kernver" != "$pkgver" ]; then msg "Applying patch-$pkgver.xz" unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N || return 1 fi # first apply patches in specified order for i in $source; do case $i in *.patch) msg "Applying $i..." if ! patch -s -p1 -N -i "$srcdir"/$i; then echo $i >>failed _patch_failed=1 fi ;; esac done if ! [ -z "$_patch_failed" ]; then error "The following patches failed:" cat failed return 1 fi mkdir -p "$srcdir"/build cp "$srcdir"/$_config "$srcdir"/build/.config || return 1 make -C "$srcdir"/linux-$_kernver O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \ silentoldconfig } # this is so we can do: 'abuild menuconfig' to reconfigure kernel menuconfig() { cd "$srcdir"/build || return 1 make ARCH="$_carch" menuconfig cp .config "$startdir"/$_config } build() { cd "$srcdir"/build unset LDFLAGS make ARCH="$_carch" CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \ || return 1 } package() { cd "$srcdir"/build mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules local _install case "$CARCH" in aarch64*|arm*) _install="zinstall dtbs_install" ;; *) _install="install" ;; esac make -j1 modules_install firmware_install $_install \ ARCH="$_carch" \ INSTALL_MOD_PATH="$pkgdir" \ INSTALL_PATH="$pkgdir"/boot \ INSTALL_DTBS_PATH="$pkgdir"/usr/lib/linux-${_abi_release} \ || return 1 rm -f "$pkgdir"/lib/modules/${_abi_release}/build \ "$pkgdir"/lib/modules/${_abi_release}/source rm -rf "$pkgdir"/lib/firmware install -D include/config/kernel.release \ "$pkgdir"/usr/share/kernel/$_flavor/kernel.release } dev() { # copy the only the parts that we really need for build 3rd party # kernel modules and install those as /usr/src/linux-headers, # simlar to what ubuntu does # # this way you dont need to install the 300-400 kernel sources to # build a tiny kernel module # pkgdesc="Headers and script for third party modules for grsec kernel" depends="gmp-dev bash perl" local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release} # first we import config, run prepare to set up for building # external modules, and create the scripts mkdir -p "$dir" cp "$srcdir"/$_config "$dir"/.config make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \ silentoldconfig prepare modules_prepare scripts # needed for 3rd party modules # https://bugzilla.kernel.org/show_bug.cgi?id=11143 case "$CARCH" in ppc*) (cd "$dir" && make arch/powerpc/lib/crtsavres.o);; esac # remove the stuff that points to real sources. we want 3rd party # modules to believe this is the soruces rm "$dir"/Makefile "$dir"/source # copy the needed stuff from real sources # # this is taken from ubuntu kernel build script # http://kernel.ubuntu.com/git/ubuntu/ubuntu-zesty.git/tree/debian/rules.d/3-binary-indep.mk cd "$srcdir"/linux-$_kernver find . -path './include/*' -prune \ -o -path './scripts/*' -prune -o -type f \ \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \ -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \ -print | cpio -pdm "$dir" || return 1 cp -a scripts include "$dir" find $(find arch -name include -type d -print) -type f \ | cpio -pdm "$dir" install -Dm644 "$srcdir"/build/Module.symvers \ "$dir"/Module.symvers mkdir -p "$subpkgdir"/lib/modules/${_abi_release} ln -sf /usr/src/linux-headers-${_abi_release} \ "$subpkgdir"/lib/modules/${_abi_release}/build } sha512sums="bf67ff812cc3cb7e5059e82cc5db0d9a7c5637f7ed9a42e4730c715bf7047c81ed3a571225f92a33ef0b6d65f35595bc32d773356646df2627da55e9bc7f1f1a linux-4.9.tar.xz 5373728be2b507c3db5e042e1d768740df7965078868afdc46418b1adc4cae3d8f9f1aedb59975a0f2acf8754340499354fcf97c503397a5d9886ccc9689b782 0001-HID-apple-fix-Fn-key-Magic-Keyboard-on-bluetooth.patch d552c5ab3b128cb1b4185aaa3ed27cd92070c2ba5f414747730c1915da432d1f930f81543737b902771967b02da8b41374d8b39518e5443aeaadeaa28153ae36 config-vanilla.aarch64 8db3d9029dffc972d881ffdccbb6afcc02cdb5ccf6a571634e1c1b72552617903ee3e1c87b8971ef1c7143c0ddfcb8e1f21b45c68afeef88d5ff36bb768c8c96 config-vanilla.armhf 6e1d79ebd2113e02881aec39eb4d243761d78be9c736b0ce5ddf1721e65d411a17c866c9f5f9a253e46017d6e7c0b93b7220233780e46e18e29de705f2e543f7 config-vanilla.x86 0a283ad25b8e0242e9904c8737d2fef9919faf8f4aa9bb3ffc65a9e144ba5d2e37dddf17b68cd9d717d73993b340634361b9a1354bb01207f2f668c73addc751 config-vanilla.x86_64 ee565e219530bcfaf5cade2622432cfb83743bdbbfc388781901461f19ca553b7fdee3c81ce6b34225ef78a209eb60088630284fcbb0430947aad77a5d8a0865 config-vanilla.ppc faf5216f916946025041c5b8ffacce2586c88c7d796c17fb9762a8a58986dce7e923a7eb7a413cbd830afef022b18c40b25f4dcd4c9c81253c9aa3e98001b2b0 config-vanilla.ppc64le 26969c1ed93cb88a8b12330a2984954d6c20ef973ef619cf92c0543ab075f4e3342c7d6275ccecd475c5b6129ccfdd6054b41f504bd82e14eb9cefbd74aa1b90 config-vanilla.s390x 99f089156ceea6367ee21390d8faaa02e81662430ec284c17fa1b3e91ba57d55c0df511614c6dda2443902eecad8a258e197327f4b9bd678487b8904f1553a31 patch-4.9.71.xz"