ports/main/linux/APKBUILD
Alex Denes 118a09852a
Update kernel
- Rebase configs again around upstream alpine configs (forgot to
  savedefconfig based on full config on new version, lost desired
  defaults)
- Fix rockpro64 config
- Remove cap-sys-nice-begone.patch
2024-08-12 06:37:42 +00:00

269 lines
6.0 KiB
Plaintext

# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=linux
majorver=6
minorver=10
patchver=2
_configs="
config-full.x86_64
config-slim.x86_64
config-rockpro64.aarch64
config-bananapi_m2b.armhf
config-bananapi_m2z.armhf
"
# https://github.com/Scrumplex/community-patches/raw/503b977cfe18f0ba367f4dd559f3529ef4834b15/linux61-tkg/cap_sys_nice_begone.mypatch
_patches="
"
pkgver="$majorver.$minorver"
pkgrel=2
if [ "$patchver" != 0 ]; then
_patches="
$_patches
linux-$majorver.$minorver.$patchver.patch.xz::https://cdn.kernel.org/pub/linux/kernel/v$majorver.x/patch-$majorver.$minorver.$patchver.xz
"
pkgver="$pkgver.$patchver"
fi
_kbdir="linux-$majorver.$minorver"
source="
https://cdn.kernel.org/pub/linux/kernel/v$majorver.x/linux-$majorver.$minorver.tar.gz
$_patches
$_configs
"
_kabi= _klocalver= _kconfig= _kbdmain= _kbddev= _kflavour=
_kdir_src="$srcdir/$_kbdir"
arch="noarch"
_depends_dev="
perl
gmp-dev
mpc1-dev
mpfr-dev
elfutils-dev
bash
flex
bison
zstd
"
makedepends="
$_depends_dev
sed
installkernel
bc
linux-headers~$pkgver
linux-firmware-any
openssl-dev
mawk
diffutils
findutils
zstd
pahole
python3
"
pkgdesc="Linux Kernel - Metapackage"
url="https://www.kernel.org"
license="GPL-2.0"
options="!strip !check"
builddir="$_kdir_src"
_carch=${CARCH} # abuild to kernel arch mapping
case "$_carch" in
aarch64*) _carch="arm64" ;;
arm*) _carch="arm" ;;
mips*) _carch="mips" ;;
ppc*) _carch="powerpc" ;;
s390*) _carch="s390" ;;
esac
_archflavors() {
for i in $_configs; do
local _nocfg="${i#config-}"
local _arch="${_nocfg#*.}"
local _flavour="${_nocfg%.*}"
[ "$_arch" == "$CARCH" ] && echo "$_flavour"
done
}
_bvars() {
_kconfig="config-$_kflavour.$CARCH"
_kdir_main="$srcdir/build-$_kflavour.$CARCH"
_kdir_dev="$srcdir/build-$_kflavour-dev.$CARCH"
_ksaf="$_kflavour"
_kabi="$pkgver-$pkgrel-$_ksaf"
_klocalver="-$pkgrel-$_ksaf"
}
_spvars() {
_kflavour="$(echo $subpkgname | cut -d- -f2)"
}
for _kflavour in $(_archflavors); do
_bvars
subpackages="
$subpackages
$pkgname-$_ksaf:_pkg_kernel:$CBUILD_ARCH
$pkgname-$_ksaf-dev:_pkg_extmod:$CBUILD_ARCH
"
done
export KBUILD_BUILD_TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S' -u${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
prepare() {
default_prepare
for _kflavour in $(_archflavors); do
_bvars
for _kbuilddir in "$_kdir_main" "$_kdir_dev"; do
mkdir -p "$_kbuilddir"
echo "$_klocalver" > "$_kbuilddir"/localversion-alpine \
|| return 1
cp "$srcdir"/"$_kconfig" "$_kbuilddir"/.config
make -C "$_kdir_src" \
O="$_kbuilddir" \
ARCH="$_carch" \
olddefconfig
done
done
}
build() {
unset LDFLAGS
for _kflavour in $(_archflavors); do
_bvars
# Build kernel and modules
msg "Building $_kflavour for $CARCH"
cd "$_kdir_main"
make \
ARCH="$_carch" \
CC="${CC:-gcc}" \
AWK="${AWK:-mawk}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
# Build out-of-tree builder
msg "Building $_kflavour-dev for $CARCH"
cd "$_kdir_dev"
make \
ARCH="$_carch" \
AWK="${AWK:-mawk}" \
prepare modules_prepare scripts
done
}
package() {
mkdir -p "$pkgdir"
}
_pkg_kernel() {
_spvars
_bvars
local _install=
case "$CARCH" in
arm*|aarch64) _install="zinstall dtbs_install";;
*) _install=install;;
esac
local _outdir="$subpkgdir"
mkdir -p "$_outdir"/boot "$_outdir"/lib/modules
cd "$_kdir_main"
# Install modules
make modules_install \
ARCH="$_carch" \
INSTALL_MOD_PATH="$_outdir" \
INSTALL_MOD_STRIP=1 \
INSTALL_PATH="$_outdir"/boot
# Install kernel
make $_install \
ARCH="$_carch" \
INSTALL_PATH="$_outdir"/boot \
INSTALL_DTBS_PATH="$_outdir/boot/dtbs-$_ksaf"
# Remove incorrect build-time symlinks
rm -f "$_outdir"/lib/modules/"$_kabi"/build \
"$_outdir"/lib/modules/"$_kabi"/source
rm -rf "$_outdir"/lib/firmware
# Install release file
install -D -m644 include/config/kernel.release \
"$_outdir"/usr/share/kernel/"$_kflavour"/kernel.release
}
_pkg_extmod() {
_spvars
_bvars
depends="$_depends_dev"
local _outdir="$subpkgdir/usr/src/linux-headers-$_kabi" _builddir="$subpkgdir/lib/modules/$_kabi"
mkdir -p "$_outdir"
cd "$_kdir_dev"
msg "Copying kernel out-of-tree build files"
rm Makefile source
cp -a . "$_outdir"
cd "$_kdir_src"
msg "Copying kernel out-of-tree build tree"
cp -a scripts include "$_outdir"
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 "$_outdir"
find ./arch \
-path './arch/*/include/*' \
-type f -print | \
cpio -pdm "$_outdir"
cd "$_kdir_main"
msg "Copying kernel out-of-tree symbol versions"
install -Dm644 Module.symvers \
"$_outdir"/Module.symvers
mkdir -p "$_builddir"
ln -sf "/usr/src/linux-headers-$_kabi" "$_builddir"/build
}
sha512sums="
5e180a7ff5c2034f70ea954d2546c22bbb4d206b846f87d4c37fafe67f202917a20affdbade3b6fcb8b0e623f0331eec80172f0294647654f78ee6a7a995689f linux-6.10.tar.gz
c4556428798f65ac1aaa2e433072319bbafe662b3df72d2b46e95a3e7df257fe6c2cbb3051cbed8bde225c5319fba0e18442bc92ab6163e8e0f99e5f0e5b1a17 linux-6.10.2.patch.xz
d8b237acf294c0c256d4c4b328f1002ae78ab34c06a4694c6111097655548ae4b5d3cbda79446567f9b2ebd259328350419084b7589cf52405e085da9771f5a6 config-full.x86_64
9dd35a8b47d6347104faabaaff37e9f6bce23ffd7afaf1a7e2a1795b8c5a7648fadf9b96ddab3a0b1548b20c15e5ccfac268d608301328b03bc941a4460df23c config-slim.x86_64
14786bd77fad1734d5c1c45beebcb5089b9ec7489f1e46f737cda04c868d16da1388683c5fdeb1c4edb9f5f917f448038f2e7dbe45d0c94adc32660aece06935 config-rockpro64.aarch64
e258b4bbd5a83dbfd070f8011e79fccd025957265f84a69819ced6bda7055f9db55a768ec6bbdc67742e569ee8df21b8d964e137e11a91ec24638fb9cd486f13 config-bananapi_m2b.armhf
e31dd09657439310f0588fcb93215534b6aa5710522f3e06ec8d3e62d9c4bd1544b4bc9e00d2c91c7345aad77e1318e8f11ad1fee030d08c06d6b9dbebecd5ff config-bananapi_m2z.armhf
"