_flavor=postmarketos-stable _hash="7b6fbfd899b4133e4f789843e5967beb139ec4d2" _config="config-${_flavor}.${CARCH}" pkgname=linux-${_flavor} pkgver=5.3.2 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=2 arch="x86_64 armhf armv7 aarch64" pkgdesc="Linux for pmOS supported chipsets (stable)" url="https://kernel.org/" depends="" makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev openssl-dev file bison flex" options="!strip !check !tracedeps" install= source=" https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz config-${_flavor}.armhf config-${_flavor}.armv7 config-${_flavor}.aarch64 config-${_flavor}.x86_64 " if [ "${pkgver%.0}" = "$pkgver" ]; then source="$source https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" fi subpackages="$pkgname-dev" license="GPL2" _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}}" ksrcdir="$srcdir/linux-$_kernver" prepare() { local _patch_failed= cd "$ksrcdir" 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 mkdir -p "$srcdir"/build cp -v "$srcdir"/$_config "$srcdir"/build/.config make -C "$ksrcdir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \ olddefconfig } build() { cd "$srcdir"/build unset LDFLAGS make ARCH="$_carch" CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" \ CFLAGS_MODULE=-fno-pic } package() { cd "$srcdir/build/arch/${_carch}/boot" if [ "$CARCH" == "aarch64" ]; then install -Dm644 "$srcdir/build/arch/${_carch}/boot/Image" \ "$pkgdir/boot/vmlinuz-$_flavor" else install -Dm644 "$srcdir/build/arch/${_carch}/boot/"*zImage \ "$pkgdir/boot/vmlinuz-$_flavor" fi install -D "$srcdir/build/include/config/kernel.release" \ "$pkgdir/usr/share/kernel/$_flavor/kernel.release" cd "$srcdir"/build local _install case "$CARCH" in aarch64*|arm*) _install="modules_install dtbs_install" ;; *) _install="modules_install" ;; esac make -j1 $_install \ ARCH="$_carch" \ INSTALL_MOD_PATH="$pkgdir" \ INSTALL_DTBS_PATH="$pkgdir/usr/share/dtb" } dev() { # copy the only the parts that we really need for build 3rd party # kernel modules and install those as /usr/src/linux-headers, # similar to what ubuntu does # # this way you don't need to install the 300-400 kernel sources to # build a tiny kernel module # pkgdesc="Headers and script for third party modules for postmarketos kernel" depends="gmp-dev bash perl" 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 "$dir"/.config make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \ olddefconfig prepare modules_prepare scripts # needed for 3rd party modules # https://bugzilla.kernel.org/show_bug.cgi?id=11143 case "$CARCH" in ppc*) (cd "$dir" && make arch/powerpc/lib/crtsavres.o);; esac # remove the stuff that points to real sources. we want 3rd party # modules to believe this is the sources 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" cp -a scripts include "$dir" find $(find arch -name include -type d -print) -type f \ | cpio -pdm "$dir" install -Dm644 "$srcdir"/build/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="6b5edef47c319a3fa7f6c20a3e0903a5acd89ec75e32dc5f99adcb60c9fe118ea312722d9c3d27e2e3900afa2455afb86e83a8b6bb131009bc79ddbe6fb0595d linux-5.3.tar.xz 028a3a112f8e7ef7c990348de17d86d53411c4fa283508813c592e1211d09c476b953a0a2faeefeb3c4214e2dcdc48545033ba435dc0511acd82650142ec9b87 config-postmarketos-stable.armhf bcf13a0f0b1d5e5633e63a92f1e1b93b87c5e3a51cd2433b61484a5426a8b1ea790554e5df774919dab6d1cc8c97a216802e1279e1e2101bf37eb1b0b8386699 config-postmarketos-stable.armv7 7672989b7fe4b89a1399f8f335e6660180e657e94b37d1a26e0eb9dc12e5f98e32736fa9438f99b76dc5fccccb07258d8300a066971f1063bce481532b1f4807 config-postmarketos-stable.aarch64 06367b22c7e9c91dce2f4410e14db7a89c934d8cbc0e73e6f49eaabfa0476b4c60fc5361510a20cb05224d7bc7d8f1882a400d1b6642ed98b1e3d16aad2b1c90 config-postmarketos-stable.x86_64 3528b4355ebbf1a1cbc4ac7efd7cdd5b5dddb28c30e182e8c0f3119c61a97d6bc1fb07ec8f2cf0a78067b098c27535bc006485428c76d6c8fb653f215218dff3 patch-5.3.2.xz"