# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.14.15 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=1 pkgdesc="Linux vanilla kernel" url="http://kernel.org" depends="mkinitfs linux-firmware" _depends_dev="perl gmp-dev elfutils-dev bash" makedepends="$_depends_dev sed installkernel bc linux-headers" 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 config-virt.x86 config-virt.x86_64 " subpackages="$pkgname-dev:_dev:$CBUILD_ARCH" _flavors= for _i in $source; do case $_i in config-*.$CARCH) _f=${_i%.$CARCH} _f=${_f#config-} _flavors="$_flavors ${_f}" if [ "linux-$_f" != "$pkgname" ]; then subpackages="$subpackages linux-${_f}::$CBUILD_ARCH linux-${_f}-dev:_dev:$CBUILD_ARCH" fi ;; esac done if [ "${pkgver%.0}" = "$pkgver" ]; then source="$source https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" fi arch="all" license="GPL-2.0" _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 # remove localversion from patch if any rm -f localversion* for i in $_flavors; do local _config=config-$i.${CARCH} local _builddir="$srcdir"/build-$i mkdir -p "$_builddir" echo "-$pkgrel-$i" > "$srcdir"/build-$i/localversion-alpine \ || return 1 cp "$srcdir"/$_config "$_builddir"/.config || return 1 make -C "$srcdir"/linux-$_kernver \ O="$_builddir" \ HOSTCC="${CC:-gcc}" \ silentoldconfig || return 1 done } build() { unset LDFLAGS for i in $_flavors; do cd "$srcdir"/build-$i make CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \ || return 1 done } _package() { local _buildflavor="$1" _outdir="$2" local _abi_release=${pkgver}-${pkgrel}-${_buildflavor} cd "$srcdir"/build-$_buildflavor || return 1 mkdir -p "$_outdir"/boot "$_outdir"/lib/modules local _install case "$CARCH" in arm*) local _dtbdir="$_outdir"/usr/lib/linux-${_abi_release} mkdir -p "$_dtbdir" for i in arch/arm/boot/dts/*.dtb ; do install -m644 "$i" "$_dtbdir" done _install=zinstall ;; *) _install=install ;; esac make -j1 modules_install $_install \ INSTALL_MOD_PATH="$_outdir" \ INSTALL_PATH="$_outdir"/boot \ || return 1 rm -f "$_outdir"/lib/modules/${_abi_release}/build \ "$_outdir"/lib/modules/${_abi_release}/source rm -rf "$_outdir"/lib/firmware install -D include/config/kernel.release \ "$_outdir"/usr/share/kernel/$_buildflavor/kernel.release } # main flavor installs in $pkgdir package() { depends="$depends linux-firmware" _package vanilla "$pkgdir" } # subflavors install in $subpkgdir virt() { _package virt "$subpkgdir" } _dev() { local _flavor=$(echo $subpkgname | sed -E 's/(^linux-|-dev$)//g') local _abi_release=${pkgver}-${pkgrel}-$_flavor # 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 $_flavor kernel" depends="$_depends_dev" 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-$_flavor.${CARCH} "$dir"/.config echo "-$pkgrel-$_flavor" > "$dir"/localversion-alpine \ || return 1 make -j1 -C "$srcdir"/linux-$_kernver O="$dir" HOSTCC="${CC:-gcc}" \ silentoldconfig prepare modules_prepare scripts # 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" || return 1 find $(find arch -name include -type d -print) -type f \ | cpio -pdm "$dir" install -Dm644 "$srcdir"/build-$_flavor/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="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz 5373728be2b507c3db5e042e1d768740df7965078868afdc46418b1adc4cae3d8f9f1aedb59975a0f2acf8754340499354fcf97c503397a5d9886ccc9689b782 0001-HID-apple-fix-Fn-key-Magic-Keyboard-on-bluetooth.patch 795c53f3fd8ec005eee312e6fc2c2182fe4148f803dd09ec633305a9226bf805535cae0c43322bf4c350d0a6ccd681bd69198a293f05c50ab0ed28522bc52d95 config-vanilla.aarch64 b6e5472541e8f54147ce2668eae47f5a893fc78179b32617aaa385b0efdb029349866f14fc5ea6a67e58d2ed57d963c82a091617972264c84f0e14cab303d25a config-vanilla.armhf c07b6455377216450059341e8635e02755f1135c87434739d2fdadb861619dfc469cd30be69cc8b8164796eadb17e77bf5f73412189667c5a52ecd3b142d78fd config-vanilla.x86 1fefd73285f3f2472cd44240a82bf2c820ef26e0e616454b362aff339f2af8ec872834178f1daf9ca6021c7a1444793e80457828c27c878e9e087480bc2446c1 config-vanilla.x86_64 6e83541be1fee860f40671046e9d863ade5bc2dd93f8d4f5b36611007a9edf9d3e73569afbde74ce9bc723f3839a85cdce3146960275af5063d3fc0836fe00fe config-vanilla.ppc 22393cebb707d8fdd5d7ee9d8c1091bafe7e0c0b7337c831f94e6055cc163bc775c10487143db388d4bbd690570caf0526525a9c20b3a5d830fc076553682d97 config-vanilla.ppc64le 0520c1b756640b54f2d4ec67e8ee88b5c2af6eb96678401f6117a2a2132660ce1a33e4623b309b2bbb1092e28f4b54d679a37403a173d5f88e3db383beee66c0 config-vanilla.s390x 4121b95b3c1fd6cd0d3a3d7c3732fa379f0b4994d2518d3d8ced6632123d5653dd009aed6f06695750678f94513796ad61770881a84b1e974b573cad16a79d5f config-virt.x86 b2f04b735cc124b6ab918e7dd3f69a279c727943e166c48e2a3341503e26e0ee191ba9245f2a83fc3262636ba1104f34cd8851dcdd8a1790aef601c5ecf69cbc config-virt.x86_64 faf165072fcff9f6f8cec76f0c35cf422afc453dfa2fc9ab5bc918eb177ebefd1e305f2c994a90c9dff073151762d79359789d118307ba15f53a020426c291a8 patch-4.14.15.xz"