# Maintainer: Gabor Pali pkgname=linux-lts pkgver=6.1.54 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=0 pkgdesc="Linux LTS kernel" url="https://www.kernel.org" depends= _depends_dev="perl gmp-dev mpc1-dev mpfr-dev elfutils-dev bash flex bison zstd" makedepends="$_depends_dev sed installkernel bc linux-headers linux-firmware-any openssl-dev>3 mawk diffutils findutils zstd pahole>=1.25 python3" options="!strip" install= source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz awk.patch config-lts.x86_64 " subpackages="$pkgname-dev:_dev:$CBUILD_ARCH" builddir="$srcdir"/linux-"$_kernver" if [ "${pkgver%.0}" = "$pkgver" ]; then source="$source https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" fi arch="x86_64" license="GPL-2.0-only" prepare() { if [ "$_kernver" != "$pkgver" ]; then msg "Applying patch-$pkgver.xz" unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N fi default_prepare # remove localversion from patch if any rm -f localversion* } _prepareconfig() { local _config="config-lts.x86_64" local _builddir="$srcdir"/build-lts.x86_64 mkdir -p "$_builddir" echo "-$pkgrel-lts" > "$_builddir"/localversion-alpine cp "$srcdir"/"$_config" "$_builddir"/.config msg "Configuring the kernel" make -C "$srcdir"/linux-"$_kernver" \ O="$_builddir" \ ARCH=x86_64 \ olddefconfig } build() { unset LDFLAGS # for some reason these sometimes leak into the kernel build, # -Werror=format-security breaks some stuff unset CFLAGS CPPFLAGS CXXFLAGS export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" _prepareconfig msg "Building the kernel" cd "$srcdir"/build-lts.x86_64 make ARCH="x86_64" \ CC="${CC:-gcc}" \ AWK="${AWK:-mawk}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" } package() { local _outdir="$pkgdir" export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" cd "$srcdir"/build-lts.x86_64 local _abi_release="$(make -s kernelrelease)" # 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 make modules_install install \ ARCH="x86_64" \ INSTALL_MOD_PATH="$_outdir" \ INSTALL_MOD_STRIP=1 \ INSTALL_PATH="$_outdir"/boot \ INSTALL_DTBS_PATH="$_outdir/boot/dtbs-lts" cp Module.symvers.backup Module.symvers rm -f "$_outdir"/lib/modules/"$_abi_release"/build \ "$_outdir"/lib/modules/"$_abi_release"/source \ "$_outdir"/boot/System.map-lts \ "$_outdir"/boot/config-lts rm -rf "$_outdir"/lib/firmware } _dev() { local _builddir="$srcdir"/build-lts.x86_64 local _abi_release="$(make -C "$_builddir" -s kernelrelease)" # 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 lts 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 -a "$_builddir"/.config "$_builddir"/localversion-alpine \ "$dir"/ make -C "$srcdir"/linux-"$_kernver" \ O="$dir" \ ARCH="x86_64" \ AWK="${AWK:-mawk}" \ 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 arch/x86 -name include -type d -print | while IFS='' read -r folder; do find "$folder" -type f done | sort -u | cpio -pdm "$dir" install -Dm644 "$srcdir"/build-lts.$CARCH/Module.symvers \ "$dir"/Module.symvers # remove unneeded things msg "Removing documentation..." rm -rf "$dir"/Documentation find "$dir" -type f -name '*.o' -printf 'Removing %P\n' -delete mkdir -p "$subpkgdir"/lib/modules/"$_abi_release" ln -sf /usr/src/linux-headers-"$_abi_release" \ "$subpkgdir"/lib/modules/"$_abi_release"/build } sha512sums=" 6ed2a73c2699d0810e54753715635736fc370288ad5ce95c594f2379959b0e418665cd71bc512a0273fe226fe90074d8b10d14c209080a6466498417a4fdda68 linux-6.1.tar.xz 3816cfc8dd14d1c5ced05bbf19b099472c9bbbd1abced32cbb4b6b5baecfaa28c345e4e522648837d98e5bc7c311810cae9160f4c91019bb857a3857076b8e0e awk.patch 005a39a389103fb4515ee8d8cb74092afaf7a1c2d871189fe7296aba4e272485afa574aa9fde5f9d35e97fda3e5930556ad68d83726b5a26e0c0df9fa35c84d4 config-lts.x86_64 adf488c3d4ef31d011501f91474d9863fc95f402dc2dca5a07a8a9a38101775916d8442962a64e6353152f10e79410bc7a6b2a2eb84e9be993ca2c2334fbb5f9 patch-6.1.54.xz "