ports/main/linux/APKBUILD

264 lines
5.5 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=3
patchver=2
_configs="
config-full.x86_64
config-slim.x86_64
config-rockpro64.aarch64
config-bananapi-m2z.armhf
"
_patches="
"
pkgver="$majorver.$minorver"
pkgrel=0
if [ "$patchver" != 0 ]; then
_patches="
$_patches
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
linux-firmware-any
openssl-dev>3
mawk
diffutils
findutils
zstd
pahole
python3
"
pkgdesc="Linux Kernel - Metapackage"
url="https://www.kernel.org"
license="GPL-2.0"
options="!strip"
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 -Ru${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}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
# Build out-of-tree builder
msg "Building $_kflavour-dev for $CARCH"
cd "$_kdir_dev"
make syncconfig \
ARCH="$_carch"
make prepare \
ARCH="$_carch"
make modules_prepare \
ARCH="$_carch"
make scripts \
ARCH="$_carch"
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 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"
mkdir -p "$_builddir"
ln -sf "/usr/src/linux-headers-$_kabi" "$_builddir"/build
}
sha512sums="
067d6d8ba4bd17ed3147b921c79ad7ed4f223df80364831cfccc852118e63e5a90730c385f85a2e501934abdf0df1d4e6e8219c5bc7a4d1b47d9703f22c3a4e0 linux-6.3.tar.gz
f1b9af242acde1d9cc6995879cad1c2343611c9849fe78bdfbbceef07ab86683dfef04c58cb6eef3ac7823f30fe4dd2d1c0b806d4673098efb21bb24a53480ca patch.xz
fcff404de4f54f483a53ecd81c9f9cd3e42c837dcfda1b6bb426298f33075378b562087fc97833fe7804dcd28edfd0e5c54d9d4c244013364f9d1f9bd3b59616 config-full.x86_64
32d1da2d0d42e585294bf1e7a701229a249d51e505cced5aeb7818ce4865cb4402f5cc0b084b77630dab5e87ef19dce01bb0533e28f11f0df888befba54c1b0d config-slim.x86_64
954cc9e6dd83ab92a781d8c0ce7237a07b6d8aa798c2b135185e9faafb4b3b5d40eb091ed7db96924f74b57d2a9115f1a50e283fe5f6286dbf9688d70241db65 config-rockpro64.aarch64
4e917f33e350be88d14f271cd0ef07029114940bf99ad7e711cb8371835577561efc6c9005e3288df2b34e2a0bb9dbc393ed3e885862ee900a3a160fd147a3a8 config-bananapi-m2z.armhf
"