This commit is contained in:
build@apk-groulx 2023-04-22 06:56:08 +00:00
parent fe9075d246
commit bea9886d19

View file

@ -1,322 +0,0 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_flavor=lts
pkgname=linux-$_flavor
pkgver=6.1.21
case $pkgver in
*.*.*) _kernver=${pkgver%.*};;
*.*) _kernver=$pkgver;;
esac
pkgrel=0
pkgdesc="Linux lts kernel"
url="https://www.kernel.org"
depends="initramfs-generator"
_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 python3"
options="!strip"
_config=${config:-config-lts.${CARCH}}
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
0001-powerpc-config-defang-gcc-check-for-stack-protector-.patch
0001-x86-Compress-vmlinux-with-zstd-19-instead-of-22.patch
0001-kexec-add-kexec_load_disabled-boot-option.patch
awk.patch
ppc-notext.patch
0001-tty-Move-sysctl-setup-into-core-tty-logic.patch
0002-tty-Allow-TIOCSTI-to-be-disabled.patch
0003-tty-Move-TIOCSTI-toggle-variable-before-kerndoc.patch
lts.aarch64.config
lts.armv7.config
lts.x86.config
lts.x86_64.config
lts.ppc64le.config
lts.s390x.config
virt.aarch64.config
virt.armv7.config
virt.ppc64le.config
virt.x86.config
virt.x86_64.config
"
subpackages="$pkgname-dev:_dev:$CBUILD_ARCH $pkgname-doc"
for _i in $source; do
case $_i in
*.$CARCH.config)
_f=${_i%."$CARCH".config}
_flavors="$_flavors $_f"
if [ "linux-$_f" != "$pkgname" ]; then
subpackages="$subpackages linux-$_f::$CBUILD_ARCH linux-$_f-dev:_dev:$CBUILD_ARCH"
fi
;;
esac
done
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="all !armhf !riscv64"
license="GPL-2.0-only"
# secfixes:
# 5.10.4-r0:
# - CVE-2020-29568
# - CVE-2020-29569
# 5.15.74-r0:
# - CVE-2022-41674
# - CVE-2022-42719
# - CVE-2022-42720
# - CVE-2022-42721
# - CVE-2022-42722
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*
}
_kernelarch() {
local arch="$1"
case "$arch" in
aarch64*) arch="arm64" ;;
arm*) arch="arm" ;;
mips*) arch="mips" ;;
ppc*) arch="powerpc" ;;
s390*) arch="s390" ;;
esac
echo "$arch"
}
_prepareconfig() {
local _flavor="$1"
local _arch="$2"
local _config=$_flavor.$_arch.config
local _builddir="$srcdir"/build-$_flavor.$_arch
mkdir -p "$_builddir"
echo "-$pkgrel-$_flavor" > "$_builddir"/localversion-alpine
cp "$srcdir"/$_config "$_builddir"/.config
msg "Configuring $_flavor kernel ($_arch)"
make -C "$srcdir"/linux-$_kernver \
O="$_builddir" \
ARCH="$(_kernelarch $_arch)" \
olddefconfig
}
listconfigs() {
for i in $source; do
case "$i" in
*.config) echo $i;;
esac
done
}
prepareconfigs() {
for _config in $(listconfigs); do
local _flavor=${_config%%.*}
local _arch=${_config%.config}
_arch=${_arch#*.}
local _builddir="$srcdir"/build-$_flavor.$_arch
_prepareconfig "$_flavor" "$_arch"
done
}
# this is supposed to be run before version is bumped so we can compare
# what new kernel config knobs are introduced
prepareupdate() {
clean && fetch && unpack && prepare && deps
prepareconfigs
rm -r "$srcdir"/linux-$_kernver
}
updateconfigs() {
if ! [ -d "$srcdir"/linux-$_kernver ]; then
deps && fetch && unpack && prepare
fi
for _config in $(listconfigs); do
local _flavor=${_config%%.*}
local _arch=${_config%.config}
_arch=${_arch#*.}
local _builddir="$srcdir"/build-$_flavor.$_arch
mkdir -p "$_builddir"
echo "-$pkgrel-$_flavor" > "$_builddir"/localversion-alpine
local actions="listnewconfig oldconfig"
if ! [ -f "$_builddir"/.config ]; then
cp "$srcdir"/$_config "$_builddir"/.config
actions="olddefconfig"
env | grep ^CONFIG_ >> "$_builddir"/.config || true
fi
make -j1 -C "$srcdir"/linux-$_kernver \
O="$_builddir" \
ARCH="$(_kernelarch $_arch)" \
$actions savedefconfig
cp "$_builddir"/defconfig "$startdir"/$_config
done
}
build() {
unset LDFLAGS
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
for i in $_flavors; do
_prepareconfig "$i" "$CARCH"
done
for i in $_flavors; do
msg "Building $i kernel"
cd "$srcdir"/build-$i.$CARCH
make ARCH="$(_kernelarch $CARCH)" \
CC="${CC:-gcc}" \
AWK="${AWK:-mawk}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
done
}
_package() {
local _buildflavor="$1" _outdir="$2"
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
cd "$srcdir"/build-$_buildflavor.$CARCH
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
local _install
case "$CARCH" in
arm*|aarch64) _install="zinstall dtbs_install";;
*) _install=install;;
esac
make -j1 modules_install $_install \
ARCH="$(_kernelarch $CARCH)" \
INSTALL_MOD_PATH="$_outdir" \
INSTALL_MOD_STRIP=1 \
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 lts "$pkgdir"
# copy files for linux-lts-doc sub package
mkdir -p "$pkgdir"/usr/share/doc
cp -r "$srcdir"/linux-"$_kernver"/Documentation \
"$pkgdir"/usr/share/doc/linux-doc-"$pkgver"/
# remove files that aren't part of the documentation itself
for nondoc in \
.gitignore conf.py docutils.conf \
dontdiff Kconfig Makefile
do
rm "$pkgdir"/usr/share/doc/linux-doc-"$pkgver"/"$nondoc"
done
# create /usr/share/doc/linux-doc symlink
cd "$pkgdir"/usr/share/doc; ln -s linux-doc-"$pkgver" linux-doc
}
# subflavors install in $subpkgdir
virt() {
_package virt "$subpkgdir"
}
_dev() {
local _flavor=$(echo $subpkgname | sed -E 's/(^linux-|-dev$)//g')
local _builddir="$srcdir"/build-$_flavor.$CARCH
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 $_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 -a "$_builddir"/.config "$_builddir"/localversion-alpine \
"$dir"/
make -j1 -C "$srcdir"/linux-$_kernver \
O="$dir" \
ARCH="$(_kernelarch $CARCH)" \
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 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' -o -name 'Platform' \) \
-print | cpio -pdm "$dir"
cp -a scripts include "$dir"
find arch -name include -type d -print | while IFS='' read -r folder; do
find "$folder" -type f | cpio -pdm "$dir"
done
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="
6ed2a73c2699d0810e54753715635736fc370288ad5ce95c594f2379959b0e418665cd71bc512a0273fe226fe90074d8b10d14c209080a6466498417a4fdda68 linux-6.1.tar.xz
a6c826e8c3884550fbe1dee3771b201b3395b073369f7fbfb5dc4aa5501e848b0bbc3a5ad80d932a6a50cbe0cfd579c75662f0c43ef79a38c1c6848db395c4c8 0001-powerpc-config-defang-gcc-check-for-stack-protector-.patch
55f732c01e10948b283eb1cc77ce3f1169428251075f8f5dd3100d8fda1f08b6b3850969b84b42a52468d4f7c7ec7b49d01f0dff3c20c30f2e9ac0c07071b9d3 0001-x86-Compress-vmlinux-with-zstd-19-instead-of-22.patch
5464cf4b2e251972091cc9d5138291a94298737e98ec24829829203fc879593b440a7cd1ca08e6d01debaab2887976cb5d38fae2fbe5149cef1735d5d73bb086 0001-kexec-add-kexec_load_disabled-boot-option.patch
15fca2343b57dcab247c5ad86175ae638bace41a803984170a4aca4f3ec70edf6399ce5c6de82ae0dfabd3430a7a7567941718806b6d5d56515ecc7d55b2a800 awk.patch
c74488940244ba032e741c370767467cfab93b89077b5dfccfed39b658f381e0995527e6c61de53b1c112b04ba647bfccf00f2e05c0637d3c703680a508821cc ppc-notext.patch
f8582538a8482656138a0ae56b67a6d3cec09ff8d82a3f790ffa3fa7c37d0ae24a04f01f0ae1aec09838f86490907995c2568be7841a3821f0e64704f60153e5 0001-tty-Move-sysctl-setup-into-core-tty-logic.patch
0bfd2c138e997f25f821cd518263ad515fc303bbde37bcdb7dd651d30316c77652fec6fedb195102b8476b92b1e7269c143dad5df6431db49c4318375ad2e802 0002-tty-Allow-TIOCSTI-to-be-disabled.patch
8b245ec672a56dae7ce82f488880f6f3c0b65776177db663a29f26de752bf2cefe6b677e2cedbebd85e98d6f6e3d66b9f198a0d7a6042a20191b5ca8f4a749e7 0003-tty-Move-TIOCSTI-toggle-variable-before-kerndoc.patch
8499d68e567c35f733c01bc35340d4babb43700d42c2d3f84f4d234aa78c10ddcaec33533c13614cc12eb20d974fc91a52c52cfffb5b75d6efe0b2d5f7a31293 lts.aarch64.config
becd5c8ec55da666c013a1548a7aae7009ee18fef767cb878ea0480251d62522b49fb7fb75451adfbb6d06e244c32de5bfb2af88db6d545a40ee165ba4ed8a47 lts.armv7.config
8e2271e6198864ac039877b420a69a4bfa3a7ec8213cfa8ff6796180732fdb582cfcd5a05908344c5e5b9e6ab61b2962274f336810c1d2f126f0c2d2d9a0824a lts.x86.config
3feab39771808bb421fab9d238257c6fd45bc45150075c592bf83ce4900e87221db12700423998c570f1b93cf7390490842e41ab243b6136426662316233a611 lts.x86_64.config
2c484ef587fcc68a48572ccb17b73353a40bf000d579ae2945b3ae298e88d97797305aa87a6bb6f58d3ee22bf99746eb5853f811c1b5a14b7b2824f1024f29dd lts.ppc64le.config
51ce99e899d5ec8bb6bbd894dae27c409d0c7f532e2f9556cfc42957fd4487f6776d25e261e6ce2e7da784a668db2574d59840fc39de04e99f15c39ad870eb36 lts.s390x.config
2fa0ed20c5374b0fe8122795f2fa67ad9905ce245ecc043315cf76013c4ec1fd96350bafd9c6b0bd28963e3a47035f31e36df67a4286555f661ed539409e7d74 virt.aarch64.config
88a4f7146ed9444befe2c8813658ad6f19d2deaacdc5d74d794c6a8d7931496b593af206a69676bf21c018e26de2b844edef67da11c70adac23ced36ec108d9d virt.armv7.config
6d165244130b33a5a0fe302117a930c743bd4b2c31bb900c39128dc72973d989579343cb6d48fd0fae4d63379a5d82051bf66edecb5a3dbc1484e519b8cdf137 virt.ppc64le.config
978a3f9b1005de7ef45f2b67316ad63ff539b4e8bd7fdad550dfcc46cf2e99b2b7c0a523578078f3fcf05e5f2e566b743acb3194408d79b75d663f8d9ea21f14 virt.x86.config
a92b01eb06360c8f4d5c993ebd611336d351eeabeb7f944fffc9636ce43f509882d811b7984b0c728fb5db6d78f8bc7bebc8f8009ebcf731cafafd65d7e3682d virt.x86_64.config
d30131ff594cc029068722c6bf82e59fbe923e240c50e9916f41d58f25adc9d23cbcfabaf9078328dd1047e93b0c5a4dbe9b15efa87a3d29a90defab69a04eb5 patch-6.1.21.xz
"