# Maintainer: Natanael Copa _flavor=mox pkgname=linux-${_flavor} provides=linux-lts pkgver=5.10.63 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=1 pkgdesc="Linux Mox kernel" url="https://www.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 diffutils findutils" options="!strip" _config=${config:-config-mox.${CARCH}} install= source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz 0002-powerpc-config-defang-gcc-check-for-stack-protector-.patch 0007-pci-hotplug-declare-IDT-bridge-as-hotpluggabl-bridge.patch 0008-pci-spr2803-quirk-to-fix-class-ID.patch ampere-mt-jade.patch config-mox.aarch64 " 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="aarch64" 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 # secfixes: # 5.10.4-r0: # - CVE-2020-29568 # - CVE-2020-29569 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" \ listnewconfig oldconfig done } build() { unset LDFLAGS export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" 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} export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" cd "$srcdir"/build-$_buildflavor.$CARCH # modules_install seems to regenerate a defect Modules.symvers on s390x. Work # around it by backing it up and restore it after modules_install cp Module.symvers Module.symvers.backup mkdir -p "$_outdir"/boot "$_outdir"/lib/modules local _install case "$CARCH" in arm*|aarch64) _install="zinstall dtbs_install";; *) _install=install;; esac make -j1 modules_install $_install \ ARCH="$_carch" \ INSTALL_MOD_PATH="$_outdir" \ INSTALL_PATH="$_outdir"/boot \ INSTALL_DTBS_PATH="$_outdir/boot/dtbs-$_buildflavor" cp Module.symvers.backup Module.symvers rm -f "$_outdir"/lib/modules/${_abi_release}/build \ "$_outdir"/lib/modules/${_abi_release}/source rm -rf "$_outdir"/lib/firmware install -D -m644 include/config/kernel.release \ "$_outdir"/usr/share/kernel/$_buildflavor/kernel.release } # main flavor installs in $pkgdir package() { depends="$depends linux-firmware-any" _package mox "$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} export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" # 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 make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" \ syncconfig 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' -o -name 'Platform' \) \ -print | cpio -pdm "$dir" cp -a scripts include "$dir" 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=" 95bc137d0cf9148da6a9d1f1a878698dc27b40f68e22c597544010a6c591ce1b256f083489d3ff45ff77753289b535135590194d88ef9f007d0ddab3d74de70e linux-5.10.tar.xz d19365fe94431008768c96a2c88955652f70b6df6677457ee55ee95246a64fdd2c6fed9b3bef37c29075178294a7fc91f148ead636382530ebfa822be4ad8c2f 0002-powerpc-config-defang-gcc-check-for-stack-protector-.patch ca5aafac37e0b5f3fcbaf801e12f98beb58ffaf1d8c88f76caff22b059831869b4094e7fdcb6d6860422d6b2d036e072caff460e1feb84bd04d10740ad56265b 0007-pci-hotplug-declare-IDT-bridge-as-hotpluggabl-bridge.patch cbe85cf34e8420c91d2276c2d2aa0ab5023af68e57a1fa613f073f16a76766c67f585eda71c28f232bd0625e0dc8275a9eddc95f49409205dc0dbcc28c9fac1c 0008-pci-spr2803-quirk-to-fix-class-ID.patch 16b2d5b0255b37075ba894fc797673d633395907ce0b93400c5a8bd05b512b5cd040b91000fa41f9240d42afc664a69206597d1e3f754a1aa64b9be21a67f5c6 ampere-mt-jade.patch 8c626e2d3a6d5de06418ca526b663e51e45e0b06781906f2a411f0e68abd5f32317324c2da6da8eb8b9cede5888d98d9dbb7b8c5ff16737b7de1c40cb55f8ecf config-mox.aarch64 742a73defb64dda8a016cbbe05004dd2ec52d9615b5c7a21ec136b4089ce567b5f199cb56f66d5fb2524aa23c1f62ee22e7bef668852edbb946067412c653289 patch-5.10.63.xz "