188 lines
6 KiB
Text
188 lines
6 KiB
Text
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
|
|
|
|
_flavor=zero-gravitas
|
|
pkgname=linux-$_flavor
|
|
pkgver=5.4.70
|
|
_rmver=1.3.3
|
|
pkgrel=0
|
|
pkgdesc="Linux $_flavor 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"
|
|
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-dev:_dev:$CBUILD_ARCH $pkgname-doc"
|
|
_flavors="$_flavor" # don't target zero-sugar yet
|
|
builddir="$srcdir"/linux-RM1XX_${pkgver}_v$_rmver
|
|
arch="all !armhf !riscv64"
|
|
license="GPL-2.0-only"
|
|
|
|
_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" > "$_builddir"/localversion-alpine
|
|
|
|
msg "Configuring $_flavor kernel ($_arch)"
|
|
make -C "$builddir" \
|
|
O="$_builddir" \
|
|
ARCH="$(_kernelarch $_arch)" \
|
|
${_flavor}_defconfig
|
|
}
|
|
|
|
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 $_flavor "$pkgdir"
|
|
|
|
# copy files for linux-$_flavor-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="$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 "$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"/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="
|
|
80ab274ca3d30935d9913490662f17499c1ceedb438fe171554097d25ffc1cf85ee53f0c1642e94c0b833fdfb17636cd554bf685e4a6f5dac20cf122c1a25447 RM1XX_5.4.70_v1.3.3.tar.gz
|
|
0f47278c5bfafb939e46224fbf16f9491e3cc560ac128dcf430a1f6cf9064fb1c5bf5db1a3076c35d30c004aec525a7d6616a647564f197bb29c57701c1db982 enable-automatic-partial-refreshing.patch
|
|
301dbb765bc2759cb8bd13d200d2c8818e3b43848c0c72574926b3da698d938298a0f4a4165cf00c4c9a27c5aa88532723607ffd51388d895828ee27fa89e7b5 enable-sdhc1.patch
|
|
1275b8d5b0c9edcd30db63325c8cda23bad7322ffeb8bfdde69a1208e9d7ae7025058e54b2b03e961ec80ded8f98e018dbfa280ae013b8c2da2204614094b8c6 iwd-crypto.patch
|
|
"
|