pmaports/main/lk2nd/APKBUILD
Alexey Minnekhanov 1b869ed064
main/lk2nd: new package (MR 2570)
Package secondary LK bootloader for some Qualcomm devices
(for now: msm8916, msm8974, msm8226).

Bootloader binary is built from source in x86_64 chroot.
Two targets are built in a sequence. Then package is split
into 2 subpackages, each of them installs `/boot/lk2nd.img`.
So the end result is - lk2nd-msm8916 and lk2nd-msm8974 can't
be installed at the same time.

Device- packages then can depend on specific subpackage of this
package and have proxy-bootloader image ready to use in /boot.

This can improve user experience with installing postmarketOS on
several devices using only pmbootstrap tool.
At the very least, pmbootstrap can suggest user to flash lk2nd
immediately after `pmbootstrap install` or even offer some kind
of `pmbootstrap flasher` integration.

This will also open possibilities to automatically update and flash
lk2nd using package manager, it we ever want this.
2021-10-07 08:28:22 +02:00

68 lines
2 KiB
Text

# Maintainer: Alexey Minnekhanov <alexeymin@postmarketos.org>
pkgname=lk2nd
pkgver=0.10.0
pkgrel=0
pkgdesc="Secondary little kernel (lk) bootloader for several Qualcomm devices"
arch="armv7 aarch64"
url="https://github.com/msm8916-mainline/lk2nd"
license="MIT"
makedepends="dtc dtc-dev gcc-arm-none-eabi python3 py3-libfdt"
source="$pkgname-$pkgver.tar.gz::https://github.com/msm8916-mainline/lk2nd/archive/refs/tags/$pkgver.tar.gz"
options="!check !archcheck !tracedeps !strip pmb:cross-native"
# This APKBUILD builds bare metal executable; options are very specific!
# * there are no tests (how do you even test the bootloader?);
# * binaries are "arch-independent"; aarch64 build also produces armv7 binary,
# because ARM CPUs boot in 32-bit mode;
# * there are no depends for bootloader, it's a kernel and OS in one binary;
# * stripping of unused sections is done in lk2nd's own ld script.
subpackages="
$pkgname-msm8916
$pkgname-msm8974
$pkgname-msm8226
"
build() {
# This builds baremetal executable; distro-specific compiler flags
# and optimizations can't be set by build system.
unset CFLAGS
unset CXXFLAGS
unset CPPFLAGS
unset LDFLAGS
unset CROSS_COMPILE
unset CC
unset CXX
# ccache and crossdirect "gcc"s are in PATH, get rid of them too,
# redefine PATH to be bare minimum
unset PATH
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
make TOOLCHAIN_PREFIX=arm-none-eabi- msm8916-secondary
make TOOLCHAIN_PREFIX=arm-none-eabi- msm8974-secondary
make TOOLCHAIN_PREFIX=arm-none-eabi- msm8226-secondary
}
package() {
# main package is empty
mkdir -p "$pkgdir"
}
msm8916() {
install -Dm644 "$builddir"/build-msm8916-secondary/lk2nd.img -t \
"$subpkgdir"/boot
}
msm8974() {
install -Dm644 "$builddir"/build-msm8974-secondary/lk2nd.img -t \
"$subpkgdir"/boot
}
msm8226() {
install -Dm644 "$builddir"/build-msm8226-secondary/lk2nd-appended-dtb.img \
-t "$subpkgdir"/boot
}
sha512sums="
d4c880b4cb9563a8b99aefe4bace1efaec13975fa89af2756dbba656363bd9ef83140b22fb28ad29d299eb8fe715c2f6adb829bfc7c3c4894ab6976b85a72123 lk2nd-0.10.0.tar.gz
"