ayaports/user/linux-rm/APKBUILD
2023-04-22 02:16:22 +00:00

182 lines
5.6 KiB
Text

# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_flavor=rm
pkgname=linux-${_flavor}
pkgver=5.4.70
pkgrel=1
_rmver=1.3.3
pkgdesc="Linux rm 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 lzop"
options="!strip"
_config=${config:-config-lts.${CARCH}}
source="
https://github.com/reMarkable/linux/archive/refs/tags/RM1XX_${pkgver}_v$_rmver.tar.gz
enable-automatic-partial-refreshing.patch
enable-sdhc1.patch
iwd-crypto.patch
"
subpackages="$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-RM1XX_${pkgver}_v$_rmver
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
_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"
}
prepare() {
default_prepare
make zero-gravitas_defconfig \
ARCH="$(_kernelarch $CARCH)" \
CC="${CC:-gcc}" \
AWK="${AWK:-mawk}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
}
build() {
unset LDFLAGS
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
msg "Building $_flavor kernel"
make ARCH="$(_kernelarch $CARCH)" \
CC="${CC:-gcc}" \
AWK="${AWK:-mawk}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
}
# main flavor installs in $pkgdir
package() {
depends="$depends linux-firmware-any"
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
local _abi_release="$(make -s kernelrelease)"
mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
make -j1 modules_install zinstall dtbs_install \
ARCH="$(_kernelarch $CARCH)" \
INSTALL_MOD_PATH="$pkgdir" \
INSTALL_MOD_STRIP=1 \
INSTALL_PATH="$pkgdir"/boot \
INSTALL_DTBS_PATH="$pkgdir/boot/dtbs-rm"
rm -f "$pkgdir"/lib/modules/"$_abi_release"/build \
"$pkgdir"/lib/modules/"$_abi_release"/source
rm -rf "$pkgdir"/lib/firmware
install -D -m644 include/config/kernel.release \
"$pkgdir"/usr/share/kernel/$_buildflavor/kernel.release
# copy files for linux-lts-doc sub package
mkdir -p "$pkgdir"/usr/share/doc
cp -r "$builddir"/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
}
_dev() {
local _flavor=$(echo $subpkgname | sed -E 's/(^linux-|-dev$)//g')
local _builddir="$builddir"
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 \
"$dir"/
make -j1 -C "$builddir" \
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 "$builddir"
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"/$builddir/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="
80ab274ca3d30935d9913490662f17499c1ceedb438fe171554097d25ffc1cf85ee53f0c1642e94c0b833fdfb17636cd554bf685e4a6f5dac20cf122c1a25447 RM1XX_5.4.70_v1.3.3.tar.gz
0f47278c5bfafb939e46224fbf16f9491e3cc560ac128dcf430a1f6cf9064fb1c5bf5db1a3076c35d30c004aec525a7d6616a647564f197bb29c57701c1db982 enable-automatic-partial-refreshing.patch
301dbb765bc2759cb8bd13d200d2c8818e3b43848c0c72574926b3da698d938298a0f4a4165cf00c4c9a27c5aa88532723607ffd51388d895828ee27fa89e7b5 enable-sdhc1.patch
1275b8d5b0c9edcd30db63325c8cda23bad7322ffeb8bfdde69a1208e9d7ae7025058e54b2b03e961ec80ded8f98e018dbfa280ae013b8c2da2204614094b8c6 iwd-crypto.patch
"