# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.19.59 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 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"/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 \ 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 fcd7e470599aa251b4a64b77c9e6353405086b3f1c01e8bb9e4e7bcb126cef29d772ff796ef313787e03a7cd87107bb64e5a37cc77adafb0d9f2feb01704039e config-vanilla.aarch64 ced3a76bfadddda83aefd1098ab6498aca9e0b9d9077553fd15680f1a1fbbe142d81984f2d0bc652efb603f8c80e885feabf51f5899303d3cc1b065a6033eb9a config-vanilla.armhf ced3a76bfadddda83aefd1098ab6498aca9e0b9d9077553fd15680f1a1fbbe142d81984f2d0bc652efb603f8c80e885feabf51f5899303d3cc1b065a6033eb9a config-vanilla.armv7 8ce7d62513cb2470f97aaadabe050bd35fa6eb2646812c87a98ab13ba72895955d2a869abff24acd7e10c8bad9c8107dffb1c833d2d499ee3313d0b818ca4a54 config-vanilla.x86 e7022fac4671b1534529f9b4ab0049bcb955a0a49c0ebd2f5304c3fb03bf7add254c1ca9145b994a61ba11d92c9d21ce7478265f403fe5f50e7b203b781ae052 config-vanilla.x86_64 79ee9d316663de2c2a0ee35778750ff6616b585a54acb94086aae7e589ea607388ec8490cba597f482ec4ae1c47f4c8a7b31dd950252d47a40c95b84be7916d7 config-vanilla.ppc64le b895832a12eb73be355b6a7fd100aa73fd62c1d5e7d0dcca81fdd889560ebb4c5c979d7a14f13040a784f1bf7f13fd69c9349a2ab5120d24ff0b7e6faa08835a config-vanilla.s390x f8d0c12e8bfe822c82153cbd46882ae02fcb8515ec9888e179d66a67596200caea8678d69eac586aa034e185e2125bb09d6a7c56705d208dbbf4f6613ed5f9ed config-virt.aarch64 ca425dbff83a46ba29948c507e06a6423e17ccf59e394091521f7424fe771bffa27b94a0a1de459999d3db96e235fcaa4eccb28f792ecfd15355cb31155f48b0 config-virt.x86 42f6a192c3391e50d72cb42b040880957696ee4443d70d7de8d4470228eed002c455b7b2fab4015dd8a6c76585138f1f425705e0b123bf22f71cac817f6c8085 config-virt.x86_64 b34a7335b098939b275c0abc38efdfe5112310aa6bb7cd3d2a600ab201cd4bc4980a49124f969abf83c02e490dee7f2c5df836bd4b2df7d2c3b3136c114b4d8f patch-4.19.59.xz"