build.sh: write pmbootstrap config directly; propagate errors; keep checkout root-owned
Some checks failed
image / image (push) Failing after 1m40s

'pmbootstrap config' demands an existing config file, so write
pmbootstrap_v3.cfg ourselves (INI, aports/device/ui/systemd). Explicit
set -eu because 'sh script' ignores shebang flags - run 3 shipped a
3.5KB 'image' because failures didn't propagate. dist/ is now the only
build-user-owned path, so the tag step's git works again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-08-08 16:30:19 +02:00
commit 9e30e6b4ee
2 changed files with 22 additions and 10 deletions

View file

@ -43,6 +43,7 @@ jobs:
- name: Update rolling 'latest' tag - name: Update rolling 'latest' tag
run: | run: |
git config --global --add safe.directory "$PWD"
git config user.email "ci@catcrafts.net" git config user.email "ci@catcrafts.net"
git config user.name "fp6-img CI" git config user.name "fp6-img CI"
git tag -f latest git tag -f latest

View file

@ -8,6 +8,8 @@
# binfmt registered on the host). Also runnable in any Alpine environment # binfmt registered on the host). Also runnable in any Alpine environment
# with the same privileges. # with the same privileges.
set -eu
KERNEL_REPO=https://forgejo.catcrafts.net/Catcrafts/milos-linux.git KERNEL_REPO=https://forgejo.catcrafts.net/Catcrafts/milos-linux.git
KERNEL_BRANCH=combined-stable KERNEL_BRANCH=combined-stable
PMAPORTS_REPO=https://gitlab.postmarketos.org/postmarketOS/pmaports.git PMAPORTS_REPO=https://gitlab.postmarketos.org/postmarketOS/pmaports.git
@ -16,12 +18,15 @@ cd "$(dirname "$0")"
# pmbootstrap refuses to run as root: install deps, then re-exec as a build # pmbootstrap refuses to run as root: install deps, then re-exec as a build
# user with passwordless sudo (pmbootstrap escalates itself where needed). # user with passwordless sudo (pmbootstrap escalates itself where needed).
# The checkout stays root-owned (later workflow steps need its .git); the
# build user only gets dist/.
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
apk add -q pmbootstrap git sudo apk add -q pmbootstrap git sudo
id build >/dev/null 2>&1 || adduser -D build id build >/dev/null 2>&1 || adduser -D build
echo 'build ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/build echo 'build ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/build
chown -R build "$PWD" rm -rf dist
exec su build -c "sh '$PWD/build.sh'" install -d -o build dist
exec su build -c "sh -eu '$PWD/build.sh'"
fi fi
WORK=${FP6IMG_WORK:-$HOME/fp6img-work} WORK=${FP6IMG_WORK:-$HOME/fp6img-work}
@ -50,13 +55,20 @@ git -C "$WORK/milos-src" archive --prefix=milos-linux/ \
sed -i "s/^_commit=.*/_commit=\"$COMMIT\"/" "$KAPORT/APKBUILD" sed -i "s/^_commit=.*/_commit=\"$COMMIT\"/" "$KAPORT/APKBUILD"
# --- 3. configure pmbootstrap ------------------------------------------------- # --- 3. configure pmbootstrap -------------------------------------------------
pmbootstrap config aports "$WORK/pmaports" # 'pmbootstrap config' refuses to run before a config exists ("run init
pmbootstrap config device fairphone-fp6 # first"), so write the config file directly (INI, [pmbootstrap] section,
pmbootstrap config ui plasma-mobile # keys = pmb.core.Config attributes).
pmbootstrap config systemd always
# Stage 1 builds WITHOUT imsd: its aport sources the v0.3.0 tag, which is not # Stage 1 builds WITHOUT imsd: its aport sources the v0.3.0 tag, which is not
# published yet. When it is: uncomment here and in the checksum step below. # published yet. When it is: add "extra_packages = imsd" and enable the
#pmbootstrap config extra_packages imsd # checksum line below.
mkdir -p "$HOME/.config"
cat > "$HOME/.config/pmbootstrap_v3.cfg" <<EOF
[pmbootstrap]
aports = $WORK/pmaports
device = fairphone-fp6
ui = plasma-mobile
systemd = always
EOF
pmbootstrap checksum linux-postmarketos-qcom-milos pmbootstrap checksum linux-postmarketos-qcom-milos
#pmbootstrap checksum imsd #pmbootstrap checksum imsd
@ -68,8 +80,7 @@ pmbootstrap install --password 147147
# --- 5. collect artifacts ----------------------------------------------------- # --- 5. collect artifacts -----------------------------------------------------
EXPORT=/tmp/postmarketOS-export EXPORT=/tmp/postmarketOS-export
rm -rf "$EXPORT" dist rm -rf "$EXPORT"
mkdir -p dist
pmbootstrap export "$EXPORT" pmbootstrap export "$EXPORT"
cp -L "$EXPORT/boot.img" dist/boot.img cp -L "$EXPORT/boot.img" dist/boot.img
cp -L "$EXPORT/fairphone-fp6.img" dist/fairphone-fp6.img cp -L "$EXPORT/fairphone-fp6.img" dist/fairphone-fp6.img