From 89e4cd346fb3a7e06837580bb98c66ef36f4b475 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Fri, 3 Apr 2026 12:34:24 -0700 Subject: [PATCH] main/postmarketos-duranium: add script to set image channel This adds a script that can be used to set the "channel" for images to "staging" or "main." "Staging" will come from a separate pipeline in the duranium mkosi config repo, it may build images with patches or whatever for testing, and won't be available to users running the "main" channel. Signed-off-by: Clayton Craft Part-of: --- main/postmarketos-duranium/APKBUILD | 2 + .../rootfs-usr-bin-duranium-set-channel | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 main/postmarketos-duranium/rootfs-usr-bin-duranium-set-channel diff --git a/main/postmarketos-duranium/APKBUILD b/main/postmarketos-duranium/APKBUILD index af68f3a43..cdc07dcf8 100644 --- a/main/postmarketos-duranium/APKBUILD +++ b/main/postmarketos-duranium/APKBUILD @@ -52,6 +52,7 @@ _source644=" " _source755=" + usr/bin/duranium-set-channel etc/profile.d/99-local-bin.sh usr/libexec/duranium/first-boot usr/libexec/duranium/mount-subpartitions @@ -157,6 +158,7 @@ fa1c3dd727fd20d16d18695d58dd10ec335d64ece00152346c84ae750ed5ade8faf5ba11747135d7 7d98cb314472d7db64599c8abfc2e21ef6437b0c5bf407f0c21a42ec2f14f660fb3aef64c99a13aada124a822a85d8e4a6674838d1fe07719774331121d5414b rootfs-usr-lib-tmpfiles.d-var.conf ede57bf8696dce4ee295dc2a1dfe31dec415e7ce994600ce3bf7386ac1ad63797a6c5a88434ca0cc854cdad6618647845126b1f8757c48f83ce308d394b8c68d rootfs-usr-lib-udev-rules.d-90-udisks-ignore-verity-hack.rules 7f2b98edc7b485129ea862c5c852422e8996ffe0a2bdae3160b6c94667b4e345a1792164e3143d58cb1a51c3c6981381ad7610d709aba210bb61a0c883455476 rootfs-usr-share-duranium-f0rmz-firstboot.conf +619368ffc9dd1fd9c0f662c0bb8f407a6514c8b12611511d715f705874e3be24201b5046e631c476bd70d661ca45576df8fb10aa86cf11a7de9a79289b7a7806 rootfs-usr-bin-duranium-set-channel 765797421f9123cdcf85e1496d01884cce1c8c304d15369b7eee32a8fc5abcd860dc5856c0d493f1cd3c6ad2a0ccdc4d6ba7d2ae356f0fc824dc16cdb84ebf37 rootfs-etc-profile.d-99-local-bin.sh 6661a981a3c2e549f0f1a12d4777f662eb88aa581608529f6e75a5d448b78fcb709812a4291d5708da840ba72d6cbf48375485d3ecd900d252efd2eb4a9e170c rootfs-usr-libexec-duranium-first-boot bb3ec1693f88a61563876cd069b49351861a31c15b1795702031e5beb4e89cefe302644c1ea9d0bb74746aa97007664c1782857900e2b85dd71182e95efd66ae rootfs-usr-libexec-duranium-mount-subpartitions diff --git a/main/postmarketos-duranium/rootfs-usr-bin-duranium-set-channel b/main/postmarketos-duranium/rootfs-usr-bin-duranium-set-channel new file mode 100644 index 000000000..bb92b7a22 --- /dev/null +++ b/main/postmarketos-duranium/rootfs-usr-bin-duranium-set-channel @@ -0,0 +1,74 @@ +#!/bin/sh +# switch the sysupdate channel between main (production) and staging. +set -eu + +SYSUPDATE_DIR=/usr/lib/sysupdate.d +OVERRIDE_DIR=/etc/sysupdate.d +BASE_URL="https://duranium.postmarketos.org/images/" + +usage() { + echo "Usage: $0 [-h|--help] [main|staging]" + echo "With no arguments, print the current channel." +} + +case "${1:-}" in + -h|--help) + usage + exit 0 + ;; + ""|main|staging) + ;; + *) + usage >&2 + exit 1 + ;; +esac + +get_channel() { + for f in "$OVERRIDE_DIR"/*.transfer; do + [ -f "$f" ] || continue + if grep -q '/images/staging/' "$f"; then + echo "staging" + return + fi + done + echo "main" +} + +if [ -z "${1:-}" ]; then + get_channel + exit 0 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo "error: changing channel requires root" >&2 + exit 1 +fi + +channel="$1" + +if [ "$channel" = "main" ]; then + for f in "$OVERRIDE_DIR"/*.transfer; do + [ -f "$f" ] || continue + if grep -q '/images/staging/' "$f"; then + rm "$f" + fi + done + echo "Switched to main" + exit 0 +fi + +# staging +mkdir -p "$OVERRIDE_DIR" +for transfer in "$SYSUPDATE_DIR"/*.transfer; do + [ -f "$transfer" ] || continue + + grep -q "^Path=.*$BASE_URL" "$transfer" || continue + + name=$(basename "$transfer") + # NOTE: if there are changes to .transfer files in the image, the changes won't + # make it into the override... + sed 's|/images/|/images/staging/|' "$transfer" > "$OVERRIDE_DIR/$name" +done + +echo "Switched to staging"