diff --git a/docs/RELEASES.md b/docs/RELEASES.md index 2937eaa4d..c02f81bc0 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -66,6 +66,7 @@ Bring-up tools (`*-stage`, `display-hz`, `usbc-deadman`) stay per plan: they pok | `COMPATIBLE` | `google,gs201-cheetah` | First DT root compatible; firmware names and the device check at install time use it | | `PACKAGE` | `omamobile-device-cheetah` | The device's package (and, for now, where the initramfs C helpers' sources live) | | `ROOTFS_PACKAGES` | `omamobile-audio omamobile-sensors omamobile-gnss omamobile-fingerprint omamobile-modem omamobile-modem-sit omamobile-mmd` | Optional. The board's own packages that `tools/build-rootfs` installs on top of the shared `rootfs/packages.omamobile`: ones tuned to this phone, which another device's image must not pull in. The modem stack (the runtime, the radio service and the ModemManager bridge) rides here, never in the shared list: it comes with the device that runs it | +| `ROOTFS_DIST_PACKAGES` | (unset) | Optional distribution packages installed from Arch Linux ARM or Omarchy repositories and recorded on the image's `MANIFEST`. Runtime packages built for Omarchy Mobile belong in `ROOTFS_PACKAGES` or the device package, never here | | `DTB` | `exynos/google/gs201-cheetah.dtb` | Under `arch/arm64/boot/dts` in the kernel build, and under `dtbs/` in the kernel package | | `SOC_IDS` | `b0:0x9855001 a0:0x9855000` | `label:soc_id`. The first is what the DTB is built with; each other entry is a copy with `/soc_id` rewritten. Order is the order in `dtb.img` | | `SOC_COMPATIBLE` | (zuma: `b0-foplp:0x9865:1:0:0 b1-foplp:0x9865:1:1:0`; zumapro: `a1-ipop:0x9875:0:1:1`; gs201 IPOP, the Pixel 7a: `b0-ipop:0x9855:1:0:1`) | For a bootloader that matches the base DTB on `/soc_compatible` instead of `/soc_id` (zuma, zumapro, and gs201's IPOP package). `label:product_id:major:minor:pkg_mode`, one entry per child node: the label, upper-cased with `-` as `_`, is the node name, so each label appears once. The DTB ships once, unchanged; `images` checks that it has a `/soc_compatible` node holding exactly these children. A descriptor names exactly one of `SOC_IDS` and `SOC_COMPATIBLE`, and `tools/install-phone` checks the same | diff --git a/rootfs/build-inside b/rootfs/build-inside index 18eb43d32..311b924a9 100755 --- a/rootfs/build-inside +++ b/rootfs/build-inside @@ -7,10 +7,11 @@ # /modules the kernel modules tarball (read-only) # /target an empty volume: the root file system is assembled here # /out where the raw image and the MANIFEST go -# Environment: VERSION, DEVICE, DEVICE_PACKAGE, ROOTFS_PACKAGES and -# ALLOW_MISSING (both space-separated), KERNEL_PACKAGE (1: the device -# package ships boot files, so linux-omamobile and omamobile-boot-update go -# in and the package's modules replace the tarball), KERNEL_RELEASE, MODULES_SHA256, +# Environment: VERSION, DEVICE, DEVICE_PACKAGE, ROOTFS_PACKAGES, +# ROOTFS_DIST_PACKAGES (space-separated), ALLOW_MISSING (space-separated) and +# KERNEL_PACKAGE (1: device package ships boot files, so linux-omamobile +# and omamobile-boot-update go in and the package modules replace the tarball), +# KERNEL_RELEASE, MODULES_SHA256, # GIT_COMMIT, ALARM_SHA256, OMARCHY_CHANNEL, CHANNEL ([omamobile]: stable, # development or local). set -euo pipefail @@ -32,6 +33,7 @@ pacman -Sy >/dev/null source /src/rootfs/resolve.sh mapfile -t base < <(list /src/rootfs/packages.base) +read -ra distro <<<"${ROOTFS_DIST_PACKAGES:-}" mapfile -t ours < <(list /src/rootfs/packages.omamobile) ours+=("$DEVICE_PACKAGE") read -ra board <<<"${ROOTFS_PACKAGES:-}" @@ -41,10 +43,14 @@ ours+=("${board[@]}") # so pacstrap's run of it leaves everything alone) [[ ${KERNEL_PACKAGE:-0} != 1 ]] || ours+=(omamobile-boot-update linux-omamobile) missing=() skipped_ours=() -resolve_all "${base[@]}" +resolve_all "${base[@]}" "${distro[@]}" ((${#absent_pkgs[@]} == 0)) || printf 'error: not in any repository: %s\n' "${absent_pkgs[*]}" >&2 ((${#unmet_pkgs[@]} == 0)) || printf 'error: in a repository, but pacman cannot meet their dependencies: %s\n%s\n' "${unmet_pkgs[*]}" "$unmet_why" >&2 ((${#absent_pkgs[@]} + ${#unmet_pkgs[@]} == 0)) || exit 1 +for p in "${distro[@]}"; do + repo=$(pacman -Sp -dd --print-format %r "$p" 2>/dev/null | tail -1 || true) + [[ $repo != omamobile ]] || die "$p is an Omarchy Mobile package; list it in ROOTFS_PACKAGES instead" +done # Every package of ours must come from [omamobile], not a same-named one # elsewhere (Mesa, Hyprland, libcamera are in Arch Linux ARM and [omarchy] # too). One allowed to be missing is left to whatever depends on it. @@ -71,7 +77,7 @@ if [[ ${KERNEL_PACKAGE:-0} == 1 && " ${ours_present[*]} " != *" linux-omamobile fi say "Base system and Omarchy (${#base[@]} packages)" -pacstrap -C /etc/pacman.conf -c -M "$T" "${base[@]}" >/var/log/pacstrap-base.log 2>&1 || { tail -40 /var/log/pacstrap-base.log; die "pacstrap failed"; } +pacstrap -C /etc/pacman.conf -c -M "$T" "${base[@]}" "${distro[@]}" >/var/log/pacstrap-base.log 2>&1 || { tail -40 /var/log/pacstrap-base.log; die "pacstrap failed"; } omarchy_list=$T/usr/share/omarchy/install/omarchy-base.packages [[ -f $omarchy_list ]] || die "no $omarchy_list in the omarchy package" @@ -123,6 +129,7 @@ mv "$ml.new" "$ml" && chmod 644 "$ml" [[ $(grep -c '^[[:space:]]*Server' "$ml") == 1 ]] && grep -qxF "Server = $server" "$ml" || die "could not set the [omamobile] channel to $CHANNEL in the mirrorlist" echo " [omamobile] channel: $CHANNEL ($server)" +echo " distribution packages: ${ROOTFS_DIST_PACKAGES:-none}" # The image's sync databases match its pacman.conf. [omamobile]'s index is # the build's own, from file://: kept for the local channel; otherwise # dropped, since pacman's If-Modified-Since refresh would keep it while it is @@ -214,6 +221,7 @@ say "MANIFEST" echo "# Omarchy Mobile root image" echo "version: $VERSION" echo "device: $DEVICE ($DEVICE_PACKAGE${ROOTFS_PACKAGES:+ $ROOTFS_PACKAGES})" + echo "distribution packages: ${ROOTFS_DIST_PACKAGES:-none}" echo "built: $(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "repository commit: $GIT_COMMIT" echo "arch linux arm tarball sha256: $ALARM_SHA256" diff --git a/tests/build-rootfs b/tests/build-rootfs index 445c25528..70c91bd88 100755 --- a/tests/build-rootfs +++ b/tests/build-rootfs @@ -18,7 +18,7 @@ touch "$R/out/repo/aarch64/omamobile.db" "$t/kernel/modules-fixture.tar.zst" "$t echo fixture > "$t/kernel/include/config/kernel.release" for device in first second; do mkdir -p "$R/device/$device" - printf 'PACKAGE=omamobile-device-%s\nCODENAME=%s\nNAME="%s"\nBOOT_IMAGES="boot dtbo"\nUFS_RW="boot_b dtbo_b userdata"\nAVB_FOOTERS="boot:0x4000000"\n' "$device" "$device" "$device" > "$R/device/$device/device.conf" + printf 'PACKAGE=omamobile-device-%s\nCODENAME=%s\nNAME="%s"\nBOOT_IMAGES="boot dtbo"\nUFS_RW="boot_b dtbo_b userdata"\nAVB_FOOTERS="boot:0x4000000"\nROOTFS_DIST_PACKAGES="libsigc++"\n' "$device" "$device" "$device" > "$R/device/$device/device.conf" done cat > "$R/tools/lib/alarm.sh" <<'EOF' alarm_die() { echo "$*" >&2; exit 1; } @@ -34,13 +34,14 @@ cat > "$t/bin/docker" <<'EOF' #!/bin/bash set -euo pipefail [[ $1 == run ]] || exit 0 -work="" device="" channel="" kernel_package="" +work="" device="" channel="" kernel_package="" distro="" while (($#)); do case $1 in -v) [[ $2 != *:/out ]] || work=${2%:/out}; shift ;; -e) [[ $2 != DEVICE=* ]] || device=${2#DEVICE=} [[ $2 != CHANNEL=* ]] || channel=${2#CHANNEL=} - [[ $2 != KERNEL_PACKAGE=* ]] || kernel_package=${2#KERNEL_PACKAGE=}; shift ;; + [[ $2 != KERNEL_PACKAGE=* ]] || kernel_package=${2#KERNEL_PACKAGE=} + [[ $2 != ROOTFS_DIST_PACKAGES=* ]] || distro=${2#ROOTFS_DIST_PACKAGES=}; shift ;; esac shift done @@ -56,7 +57,8 @@ fi [[ ${FAIL_BUILD:-0} != 1 ]] || exit 1 printf '%s\n' "$device" > "$work/rootfs.img" printf '%s\n' "$kernel_package" > "$T/kernel-package.$device" -printf 'device: %s\nomamobile channel: %s\n' "$device" "$channel" > "$work/MANIFEST" +printf '%s\n' "$distro" > "$T/distro.$device" +printf 'device: %s\nomamobile channel: %s\ndistribution packages: %s\n' "$device" "$channel" "${distro:-none}" > "$work/MANIFEST" EOF cat > "$R/tests/rootfs-smoke" <<'EOF' #!/bin/bash @@ -83,6 +85,17 @@ for device in first second; do done echo 'ok - different devices build concurrently; duplicate device/version is locked' +grep -Fx 'distribution packages: libsigc++' "$R/out/omamobile-rootfs-first-fixture-aarch64.MANIFEST" >/dev/null || fail "distribution packages reach the image MANIFEST" +[[ $(cat "$t/distro.first") == libsigc++ ]] || fail "ROOTFS_DIST_PACKAGES reaches the container" +echo 'ok - ROOTFS_DIST_PACKAGES reaches the container and MANIFEST' + +printf 'PACKAGE=omamobile-device-first\nCODENAME=first\nNAME="first"\nBOOT_IMAGES="boot dtbo"\nUFS_RW="boot_b dtbo_b userdata"\nROOTFS_DIST_PACKAGES="fixture;touch %s/injected"\n' "$t" > "$R/device/first/device.conf" +if build first > "$t/bad-packages.log" 2>&1; then fail "shell syntax in ROOTFS_DIST_PACKAGES is rejected"; fi +grep -q 'ROOTFS_DIST_PACKAGES may hold only package names' "$t/bad-packages.log" || { cat "$t/bad-packages.log"; fail "reports rejected distribution package syntax"; } +[[ ! -e $t/injected ]] || fail "distribution package text is never evaluated as shell" +printf 'PACKAGE=omamobile-device-first\nCODENAME=first\nNAME="first"\nBOOT_IMAGES="boot dtbo"\nUFS_RW="boot_b dtbo_b userdata"\nAVB_FOOTERS="boot:0x4000000"\nROOTFS_DIST_PACKAGES="libsigc++"\n' > "$R/device/first/device.conf" +echo 'ok - invalid ROOTFS_DIST_PACKAGES shell characters are rejected without evaluation' + before=$(sha256sum "$R/out/omamobile-rootfs-first-fixture-aarch64.img.zst") if FAIL_BUILD=1 build first > "$t/failed.log" 2>&1; then fail "container failure propagates"; fi if FAIL_SMOKE=1 build first > "$t/failed.log" 2>&1; then fail "smoke failure propagates"; fi diff --git a/tools/build-rootfs b/tools/build-rootfs index b8c0fd06d..3f67d59e3 100755 --- a/tools/build-rootfs +++ b/tools/build-rootfs @@ -109,10 +109,12 @@ conf=device/$DEVICE/device.conf DEVICE_PACKAGE=$(sed -n 's/^PACKAGE=\([a-z0-9-]*\)$/\1/p' "$conf") [[ -n $DEVICE_PACKAGE ]] || alarm_die "$conf has no PACKAGE" ROOTFS_PACKAGES=$(sed -n 's/^ROOTFS_PACKAGES="\(.*\)"$/\1/p' "$conf") +ROOTFS_DIST_PACKAGES=$(sed -n 's/^ROOTFS_DIST_PACKAGES="\(.*\)"$/\1/p' "$conf") # Boot files in the device package: the kernel comes as a package KERNEL_PACKAGE=0 grep -c 'OMAMOBILE_BOOT_FILES' "packages/$DEVICE_PACKAGE/install" >/dev/null 2>&1 && KERNEL_PACKAGE=1 [[ $ROOTFS_PACKAGES =~ ^[a-z0-9\ -]*$ ]] || alarm_die "$conf: ROOTFS_PACKAGES may hold only package names" +[[ $ROOTFS_DIST_PACKAGES =~ ^[a-z0-9@._+\ -]*$ ]] || alarm_die "$conf: ROOTFS_DIST_PACKAGES may hold only package names" repo=$outrel/repo/aarch64 [[ -f $repo/omamobile.db ]] || @@ -149,7 +151,8 @@ docker run --rm --privileged --platform linux/arm64 \ -v "$ROOT:/src:ro" -v "$ROOT/$outrel/repo:/repo:ro" -v "$modules:/modules:ro" \ -v "$volume:/target" -v "$work:/out" -v "$ALARM_CACHE/pkg:/var/cache/pacman/pkg" \ -e VERSION="$VERSION" -e DEVICE="$DEVICE" -e DEVICE_PACKAGE="$DEVICE_PACKAGE" \ - -e ROOTFS_PACKAGES="$ROOTFS_PACKAGES" -e KERNEL_PACKAGE="$KERNEL_PACKAGE" \ + -e ROOTFS_PACKAGES="$ROOTFS_PACKAGES" -e ROOTFS_DIST_PACKAGES="$ROOTFS_DIST_PACKAGES" \ + -e KERNEL_PACKAGE="$KERNEL_PACKAGE" \ -e KERNEL_RELEASE="$release" -e MODULES_SHA256="$(sha256sum < "$modules" | cut -d' ' -f1)" \ -e GIT_COMMIT="$commit" -e ALARM_SHA256="$(sha256sum < "$ALARM_TARBALL" | cut -d' ' -f1)" \ -e OMARCHY_CHANNEL="$OMARCHY_CHANNEL" -e CHANNEL="$CHANNEL" -e ALLOW_MISSING="$ALLOW_MISSING" \