Compare commits

...
Author SHA1 Message Date
Caleb Connolly 5cb1d710e1 DONTMERGE: boot-deploy: feat/multiple-kernels
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 05:11:14 +01:00
Caleb Connolly 7cda3728d8 WIP: linux-next: keep old versions on upgrade
Add pre and post-upgrade scripts which keep the old kernel, modules,
dtbs, and release file.

This allows for the kernel package to be upgraded while preserving the
old version, so if the upgrade causes a regression the user can switch
back.

This will need to be heavily refactored, documented and made generic.

Most likely the upgrade scripts will be moved to some -dev package and
the kernel package APKBUILD will simply source a script to create the
pre/post-upgrade scripts.

For this to work, the kernel release directory
(/usr/share/kernel/something/) has to follow the format
<flavour>-<pkgver>-r<pkgrel> since the scripts rely on this to map the
package version to the kernel suffix.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 05:07:11 +01:00
Caleb Connolly dd9811a545 postmarketos-mkinitfs: run for each kernel release
Rather than running mkinitfs once (and assume there is only one kernel
version installed) run it for each release.

This depends on https://gitlab.postmarketos.org/postmarketOS/postmarketos-mkinitfs/-/merge_requests/59
as well as
https://gitlab.postmarketos.org/postmarketOS/boot-deploy/-/merge_requests/74

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 04:59:40 +01:00
Caleb Connolly 505b29b104 linux-next: use _outdir
Recent changes to the kernels build infrastructure (currently just in
next?) break some unintentional assumptions in pmbootstrap build
--envkernel.

Specifically, that we used to mount the .output directory as the "src"
directory and rely on the fact that the kernel lets you run make from
here. But this doesn't work anymore because the Makefile points to an
absolute path on the host.

For now this is half fix half workaround.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 03:09:44 +01:00
5 changed files with 94 additions and 14 deletions

No files matched your search

+14 -9
View File
@@ -3,7 +3,7 @@
pkgname=linux-next
pkgver=6.12_git20241115
pkgrel=3
pkgrel=4
_nextver="${pkgver#*_git}"
pkgdesc="Linux next kernel"
arch="aarch64"
@@ -13,6 +13,7 @@ url="https://kernel.org"
license="GPL-2.0-only"
# FIXME: kconfigcheck isn't supported since we use fragments
options="!strip !check !tracedeps pmb:cross-native"
install="$pkgname.pre-upgrade $pkgname.post-upgrade"
source="
https://gitlab.com/linux-kernel/linux-next/-/archive/next-$_nextver/linux-next-next-$_nextver.tar.gz
devices.config
@@ -32,6 +33,7 @@ makedepends="
zstd
"
builddir="$srcdir/linux-next-next-$_nextver"
_outdir=".output"
prepare() {
default_prepare
@@ -40,32 +42,35 @@ prepare() {
# Generate .config
unset LDFLAGS
make ARCH="$_carch" CC="${CC:-gcc}" \
make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-next-$_nextver" \
defconfig pmos.config devices.config
}
build() {
unset LDFLAGS
make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
make O="$_outdir" V=1 ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}
package() {
install -Dm644 "$builddir/arch/$_carch/boot/vmlinuz.efi" \
"$pkgdir/boot/linux.efi"
release="$(cat "$builddir/$_outdir"/include/config/kernel.release)"
install -Dm644 "$builddir/$_outdir/arch/$_carch/boot/vmlinuz.efi" \
"$pkgdir/boot/linux-${release}.efi"
make modules_install dtbs_install \
make O="$_outdir" modules_install dtbs_install \
ARCH="$_carch" \
INSTALL_PATH="$pkgdir"/boot/ \
INSTALL_MOD_PATH="$pkgdir" \
INSTALL_MOD_STRIP=1 \
INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs-"${release}"
rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source
install -D "$builddir"/include/config/kernel.release \
"$pkgdir"/usr/share/kernel/next-"$_nextver"/kernel.release
# The kernel directory MUST be in the format of:
# /usr/share/kernel/<flavor>-<pkgver>-r<pkgrel>/
install -D "$builddir/$_outdir"/include/config/kernel.release \
"$pkgdir"/usr/share/kernel/next-"$pkgver"-r"$pkgrel"/kernel.release
}
sha512sums="
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
. /usr/share/misc/source_deviceinfo
new=$1
old=$2
release="$(cat /usr/share/kernel/next-$old.tmp/kernel.release)"
new_release="$(cat /usr/share/kernel/next-$new/kernel.release)"
cmd="mv"
if [ "$release" = "$new_release" ]; then
echo "Kernel release is the same, not preserving old kernel"
cmd="rm"
fi
# Backup the old kernel so apk doesn't remove it
backup="/usr/share/kernel/next-$old /lib/modules/$release /boot/linux-$release.efi /boot/dtbs-$release"
for i in $backup; do
if [ -e $i.tmp ]; then
case $cmd in
mv)
echo "Restoring $i"
mv $i.tmp $i
;;
rm)
rm -r $i.tmp
;;
esac
fi
done
if [ -z "$deviceinfo_dtb" ]; then
echo "No DTB specified, moving latest DTBs to /boot/dtbs"
mv /boot/dtbs-$new_release /boot/dtbs
fi
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh -e
new=$1
old=$2
release="$(cat /usr/share/kernel/next-$old/kernel.release)"
# Backup the old kernel so apk doesn't remove it
backup="/usr/share/kernel/next-$old /lib/modules/$release /boot/linux-$release.efi"
# If a specific DTB is configured then it will be loader by absolute path and versioned
# per kernel release. If not, we assume it will be auto-detected by dtbloader. In which
# case there is no way to know the version, so we just move the latest DTBs to /boot/dtbs
# in the post-upgrade script. So the current kernel version we're upgrading FROM will either
# have dtbs in /boot/dtbs-$release or /boot/dtbs.
if [ -d "/boot/dtbs" ]; then
backup="$backup /boot/dtbs"
else
backup="$backup /boot/dtbs-$release"
fi
for i in $backup; do
if [ -e $i ]; then
echo "Moving $i to $i.tmp"
mv $i $i.tmp
fi
done
+4 -3
View File
@@ -1,14 +1,15 @@
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=boot-deploy
pkgver=0.18
pkgver=999.18
pkgrel=2
pkgdesc="tool for finalizing and deploying boot related files"
url="https://gitlab.com/postmarketos/boot-deploy"
arch="noarch"
license="GPL-2.0-or-later"
_commit="e3d496d3bb88668fd53f293d311add788d83b64b"
source="
os-customization
https://gitlab.postmarketos.org/postmarketOS/boot-deploy/-/archive/$pkgver/boot-deploy-$pkgver.tar.gz
https://gitlab.postmarketos.org/postmarketOS/boot-deploy/-/archive/$_commit/boot-deploy-$_commit.tar.gz
"
check() {
@@ -28,5 +29,5 @@ package() {
}
sha512sums="
a243975b9850d9933e0f917f7eb38fc4a76ea658c3dcc56f035f60ee6c62d6740c1107143b8210bdc0231d4c9b6b2003e458120985604eb09649322d359ae89f os-customization
e4b059c149a96f896804c7971107f738852bf1dfadd5832e4e2b3ebf2bf00f05570bd45f0f2bea69f54755fbf6bffc9091a1d6baed7b1537679afef5c44a5fd0 boot-deploy-0.18.tar.gz
11d5b2033aa789cc52fe9214cdb2083449438b67d64f2a12ca340791adb968e570d0848c794b3056937e57e35a6378562dcae200992dab1a88592241a7560121 boot-deploy-e3d496d3bb88668fd53f293d311add788d83b64b.tar.gz
"
@@ -3,6 +3,18 @@
# initramfs to go unnoticed, it may lead to the device not booting anymore.
# Only invoke mkinitfs if the deviceinfo exists in the rootfs
if [ -f /usr/share/deviceinfo/deviceinfo ]; then
/usr/sbin/mkinitfs
if ! [ -f /usr/share/deviceinfo/deviceinfo ]; then
exit 0
fi
for release in $(find /usr/share/kernel -type f -name kernel.release); do
releases="$releases $release"
/usr/sbin/mkinitfs -k "$(cat "$release")"
done
# Remove the now-defunct initramfs/kernel files without the version suffix
for file in /boot/initramfs /boot/linux.efi /boot/vmlinuz; do
if [ -f "$file" ]; then
rm "$file"
fi
done