# Maintainer: Milan P. Stanić _flavor=elm pkgname=linux-${_flavor} # NOTE: this kernel is intended for testing # please resist urge to upgrade it blindly pkgver=5.17.6 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=0 pkgdesc="Linux latest stable kernel for elm chromebooks" url="https://www.kernel.org" _depends_dev="perl gmp-dev bash flex bison" makedepends="$_depends_dev sed installkernel bc linux-headers linux-firmware-any openssl1.1-compat-dev diffutils findutils vboot-utils u-boot-tools dtc" options="!strip !check" _config=${config:-config-elm.${CARCH}} install= #subpackages="$pkgname-dev:_dev:$CBUILD_ARCH" source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz" case $pkgver in *.*.0) source="$source";; *.*.*) source="$source https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" ;; esac source="$source config-elm.aarch64 kernel.its.elm fix-mmc1-speed.patch fix-spi-nor-max-frequency.patch fix-mmc-order.patch mps-ter12x24-font-kernel.patch " arch="aarch64" license="GPL-2.0" _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 _carch=${CARCH} case "$_carch" in aarch64*) _carch="arm64" ;; arm*) _carch="arm" ;; esac prepare() { local _patch_failed= cd "$srcdir"/linux-$_kernver case $pkgver in *.*.0);; *) msg "Applying patch-$pkgver.xz" unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N ;; esac # 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() { _package elm "$pkgdir" local _builddir="$srcdir"/build-$_flavor.$CARCH cd $_builddir cp $srcdir/kernel.its.elm . mkimage -D "-I dts -O dtb -p 2048" -f kernel.its.elm vmlinux.uimg dd if=/dev/zero of=bootloader.bin bs=512 count=1 echo "console=tty1 earlyprintk=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd loglevel=7" > cmdline vbutil_kernel \ --pack $pkgdir/boot/vmlinux.kpart-$pkgver-$pkgrel-$_flavor \ --version 1 \ --vmlinuz vmlinux.uimg \ --arch aarch64 \ --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ --signprivate kernel_data_key.vbprivk \ --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ --config cmdline \ --bootloader bootloader.bin rm cmdline bootloader.bin rm $pkgdir/boot/vmlinuz-elm cd $pkgdir/boot ln -s vmlinux.kpart-$pkgver-$pkgrel-$_flavor vmlinux.kpart } _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=" 89f0a7ca69d20a539d4b612a7028a30a5e98b402e4b6b88516f14237e5da4b626d7929eab8b40fccc90766e8f3bae87e9858a19077ffad20d8204acf18794f5b linux-5.17.tar.xz 294199421db88a203e1ccfa0833d394e7ab444860875327979bd1dda1fcb1c211809728f2e39c1ce20b14754bc9e20183a885d0b74aae92dba58197d09b0590c patch-5.17.6.xz bb41f3f12831661d8efc9c846225ddf7cb0c546de4197898413caf8f5fc06ee468b7e0e31e7a68c54b03f0b57df3513f910e741822313c35006c025a9316dff0 config-elm.aarch64 112af92af4a3f61867ffc20076d057845aa8c9139e58153d0c88f4d7185d9a9628fa79d4edfa8855f095fb70d257bfbd7c4573a7431d4b17706415b411a50775 kernel.its.elm 65c57a6d9a5bd5b6ec8798d1c46091bb72377ed1349b66e9a0a1a50ffa077f044f2bfdd30eab974c9c9774fc62d8dd5020a38432d108fce7f4fc1ed6648ea703 fix-mmc1-speed.patch 9e17fb96b81590da0f9b0917ddd2b9d195bab5cde2a4e7feb19991c50a8ac8e4502445715153ced8666e5b6575137c1d49899bb0ae9ab4505ed8f1ff7e569269 fix-spi-nor-max-frequency.patch 00e7afdab1dc89a6e0426829685d85cebb98fb95cb13a253d01326fd22f78ddf792bbe3b5be4c9bc93784f1fa93f87f604a4b6c6710660319db6f2e35dd09835 fix-mmc-order.patch fcea50a1ba2356d64a9c3ee0b7b7c326654996956d68eb445fafdb4320b4104b6321f768f0ce4ceb5cd4696be3a7332908ba1de7054fb20bf8c97f4234bfa6a4 mps-ter12x24-font-kernel.patch "