# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.19.73 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=0 pkgdesc="Linux vanilla kernel" url="http://kernel.org" depends="mkinitfs" _depends_dev="perl gmp-dev elfutils-dev bash flex bison" makedepends="$_depends_dev sed installkernel bc linux-headers linux-firmware-any openssl-dev" options="!strip" _config=${config:-config-vanilla.${CARCH}} install= source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz config-vanilla.aarch64 config-vanilla.armhf config-vanilla.armv7 config-vanilla.x86 config-vanilla.x86_64 config-vanilla.ppc64le config-vanilla.s390x config-virt.aarch64 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" _carch=${CARCH} case "$_carch" in aarch64*) _carch="arm64" ;; arm*) _carch="arm" ;; mips*) _carch="mips" ;; 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 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* oldconfig } oldconfig() { for i in $_flavors; do local _config=config-$i.${CARCH} local _builddir="$srcdir"/build-$i.$CARCH mkdir -p "$_builddir" echo "-$pkgrel-$i" > "$_builddir"/localversion-alpine \ || return 1 cp "$srcdir"/$_config "$_builddir"/.config make -C "$srcdir"/linux-$_kernver \ O="$_builddir" \ ARCH="$_carch" HOSTCC="$HOSTCC" \ listnewconfig oldconfig done } build() { unset LDFLAGS for i in $_flavors; do cd "$srcdir"/build-$i.$CARCH make ARCH="$_carch" CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" done } _package() { local _buildflavor="$1" _outdir="$2" local _abi_release=${pkgver}-${pkgrel}-${_buildflavor} cd "$srcdir"/build-$_buildflavor.$CARCH mkdir -p "$_outdir"/boot "$_outdir"/lib/modules local _install case "$CARCH" in arm*) local _dtbdir="$_outdir"/boot/dtbs/${_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 \ ARCH="$_carch" \ 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-any" _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" ARCH="$_carch" HOSTCC="$HOSTCC" \ 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.$CARCH/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="ab67cc746b375a8b135e8b23e35e1d6787930d19b3c26b2679787d62951cbdbc3bb66f8ededeb9b890e5008b2459397f9018f1a6772fdef67780b06a4cb9f6f4 linux-4.19.tar.xz c1c96c7de2c2509aa6ee8d8c05d59f0af3d1cdc641e093985d37b7476c35ab5afcdcd83f6f06288ae412e076890fcaf5fb816a67e04d87d2b2b618d5f3a853b2 config-vanilla.aarch64 4f708552ed42bb982cd395962276091a18bbdc639f018c2a87574d6d1e44f438671ea3c9f8ecdf72933d315889a476715b28ba1d2a306c8c164a9b0a457a3881 config-vanilla.armhf 4f708552ed42bb982cd395962276091a18bbdc639f018c2a87574d6d1e44f438671ea3c9f8ecdf72933d315889a476715b28ba1d2a306c8c164a9b0a457a3881 config-vanilla.armv7 2c333d996a75ba95ef68977629b2abece352ea93b043d7f76f3e24e7f3df17beae75f582ad7f34873646296953349f327d45a11cd07870b463499cdf5b596d1a config-vanilla.x86 4dbf56ebb1a9c776eca7c05cefb3108dbe03ba8b86c7772bfa4d15d5c52375ea6aaf6cb183419f6ea272e714683ef8ddb1e11c57b06aa7da4c454b542f9c9aa4 config-vanilla.x86_64 adcd21d10e01bc65722f3d5ea070836838e1fac4d76d3a3fa98f607a51dd42598be5a12a95e36dc8fc3f1eec70d0b600270788f5fe17b5c0b6f17b519c52d91b config-vanilla.ppc64le f9000892f65a26c704580ed87d72cc9c10531604ffd49fae10efadc4d9301efc84988abdfdb8fcd62367516b8471bb59c9b287ec81f3cba021f06992ba532950 config-vanilla.s390x 9eab9df75a19a09e504bfff833135cfb6502578a85b66c6db5a7a00890ce5c72640d4d07a6a925e5d48b39645f1928d344e6e4f8456fc0d7127f11eae896aac4 config-virt.aarch64 9ecfaadeda368ad1858bbdfafe75b5dcc741e1c17501fe96120e16c4305b918305d95279af6b9c3fb1c9ca052213ed62ba46409db42967bd61f8f3461d6126ae config-virt.x86 0751b7e1f0e37a0a97a0602887ca3492f7d2f5ded9771eeec1b1a9ce4471c4e01095c7fe117c6dc37419563a48328559b53cd3026677bb5954f853711c27ce27 config-virt.x86_64 42dd2524442f40094b3bd6d5c3b2c41efe25c785eeda92f12a51d6be8f2420a4b2725ed5c1a73c878522a1a44ad9f86fc0b86671e4b7a30640b4d14735f71cf3 patch-4.19.73.xz"