main/postmarketos-ui-os-installer: add custom install/deploy mode

This adds support for having a custom install/deploy, where if
`/etc/os-installer/deploy.sh` exists then pmbootstrap generates an
image, exports it, then calls deploy.sh with the path to the image it
created, and does NOT call pmbootstrap install with --disk. deploy.sh
comes from device packages that need to implement custom image
deployment stuff, when using --disk is not appropriate.

If deploy.sh doesn't exist then the standard install (using --disk) will
take place.

Signed-off-by: Clayton Craft <craftyguy@postmarketos.org>
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7112>
This commit is contained in:
Clayton Craft 2025-09-14 17:50:29 -07:00 committed by The Friendly Merge Bot
parent 52f23a780c
commit 923c4ab36e
No known key found for this signature in database
2 changed files with 35 additions and 13 deletions

View file

@ -1,7 +1,7 @@
# Reference: https://postmarketos.org/uipkg
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-ui-os-installer
pkgver=8
pkgver=9
pkgrel=0
pkgdesc="UI for installing postmarketOS"
url="https://gitlab.gnome.org/p3732/os-installer"
@ -104,5 +104,5 @@ df78c6460836c50f1b3a379cd46e6c50168673f5a4f97083eedbb81de7c8f7a363f3ec4b3840252c
d06026fd8cf2229257fb26b8a7f14ca6e3b7e3ad61b99c5795910f1a8de2a319c21f43cd192534529a5f565b7cf8c8ea8968667133bfeabe1b42ed5fafa81c92 rootfs-etc-os-installer-desktops-kde.png
fefe277cd20c1f0b2d09f3646dbf8c771fa769a779860b6399efcdd63af83664e2cd431224a389f2df68c277dfd3d1e473924c377ba9d1ff3674d36ec5b0ebb2 rootfs-etc-os-installer-desktops-xfce.png
0dbf065c3410414021db4317103b87c1ca792d00418454bcc0d3784997a8bc8a1343fd974e3d8815bed952ea10eea7dfeda55e430a01d9b7bd765872e5ba04bd rootfs-etc-os-installer-desktops-console.png
91999cac84cf66a3116ef4c1ac827727cb9e4a2ddefe17bd872b27583c4c8abd6dc6b62ae07ef9b1ddb00b8f00275a334b580b38516224b45a11dc9cc3f9c32c rootfs-usr-bin-pmos_setup.sh
11ec5185fe20301320ad02d710cd6e8d92d872eb1e5d886ee72a2ceb36a42a5c64ca2fe8a1ae736df0ec6079a9546b3d1a68bf1fd2587f0c80046bc5fa90be50 rootfs-usr-bin-pmos_setup.sh
"

View file

@ -4,19 +4,19 @@ set -eu
pmb="pmbootstrap -y"
# TODO: allow selecting device in the UI somehow?
# For now get it from deviceinfo...
# shellcheck disable=SC1091
. /usr/share/misc/source_deviceinfo
if [ -z "$deviceinfo_codename" ]; then
echo "unable to get device info"
exit 1
fi
do_prepare() {
yes '' | $pmb init --shallow-initial-clone
# TODO: allow selecting device in the UI somehow?
# For now get it from deviceinfo...
# shellcheck disable=SC1091
. /usr/share/misc/source_deviceinfo
if [ -z "$deviceinfo_codename" ]; then
echo "unable to get device info"
exit 1
fi
$pmb config device "$deviceinfo_codename"
}
@ -55,7 +55,29 @@ do_configure() {
if [ -n "$OSI_ENCRYPTION_PIN" ]; then
fde_args="--fde"
fi
PMB_FDE_PASSWORD="$OSI_ENCRYPTION_PIN" $pmb install --password "$OSI_USER_PASSWORD" --disk "$OSI_DEVICE_PATH" $fde_args
# There are two install "modes":
#
# 1) (default) pmbootstrap generates an image and writes it directly to the
# selected storage using the --disk option
#
# 2) if `deploy.sh` exists then pmbootstrap generates an image, exports it,
# then calls deploy.sh with the path to the image it created, and does NOT
# call pmbootstrap install with --disk. deploy.sh comes from device packages
# that need to implement custom image deployment stuff, when using --disk
# is not appropriate
# Note: -f because if the file is accidentally not executable then it would be
# better to fail than to run install --disk
if [ -f /etc/os-installer/deploy.sh ]; then
# Image-only install, then deploy.sh
PMB_FDE_PASSWORD="$OSI_ENCRYPTION_PIN" $pmb install --password "$OSI_USER_PASSWORD" $fde_args
$pmb export --no-install
/etc/os-installer/deploy.sh "/tmp/postmarketOS-export/${deviceinfo_codename}.img"
else
# Standard install
PMB_FDE_PASSWORD="$OSI_ENCRYPTION_PIN" $pmb install --password "$OSI_USER_PASSWORD" --disk "$OSI_DEVICE_PATH" $fde_args
fi
}
step="$(basename "$0")"