ports/main/linux/APKBUILD

255 lines
5.2 KiB
Plaintext

# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=linux
majorver=5
minorver=19
patchver=9
_configs="
config-full.x86_64
config-slim.x86_64
config-rockpro64.aarch64
"
_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= _kflavor=
_kdir_src="$srcdir/$_kbdir"
arch="noarch"
_depends_dev="
perl
gmp-dev
elfutils-dev
bash
flex
bison
"
makedepends="
$_depends_dev
sed
linux-headers
installkernel
bc
openssl1.1-compat-dev
diffutils
findutils
build-base
"
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-$_kflavor.$CARCH"
_kdir_main="$srcdir/build-$_kflavor.$CARCH"
_kdir_dev="$srcdir/build-$_kflavor-dev.$CARCH"
_ksaf="$_kflavor"
_kabi="$pkgver-$pkgrel-$_ksaf"
_klocalver="-$pkgrel-$_ksaf"
}
_spvars() {
_kflavor="$(echo $subpkgname | cut -d- -f2)"
}
for _kflavor 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 _kflavor 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 _kflavor in $(_archflavors); do
_bvars
# Build kernel and modules
msg "Building $_kflavor for $CARCH"
cd "$_kdir_main"
make \
ARCH="$_carch" \
CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
# Build out-of-tree builder
msg "Building $_kflavor-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/"$_kflavor"/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="
9c018ef5d2b3f861f721a4541e547eb712352e8d6cfd4a6803c5a7ce96ce2a7e7baf1d83f9963f2244e7fae420731d95d198bf222e2b5079da624df0e0c78668 linux-5.19.tar.gz
f05070722545b324cdf5d59288b752c896916301b767fd7323e398ab814f1c1e43e6670e450f8aacf2602b5de54659d0ebec008147135f665016ea43e9671779 patch.xz
0db424b64b50a1ffda7a8591526eb3d4d77b97b74aeee49810ef05730f95622573775026073ce57e43b4389c5c2ba075be42c49b5c3fd5e745d8c6b948a77b62 config-full.x86_64
acc7f183a6773d3de0e10c808cbfadb7b54b6f9fcf891234473adef449f87e04a486ed6ec3fae106d0ff10f0c4bc3224971319aeba03fbcaafb1590e89c5ae84 config-slim.x86_64
14786bd77fad1734d5c1c45beebcb5089b9ec7489f1e46f737cda04c868d16da1388683c5fdeb1c4edb9f5f917f448038f2e7dbe45d0c94adc32660aece06935 config-rockpro64.aarch64
"