diff --git a/packages/omamobile-omarchy/lib/update-bin/omarchy-migrate b/packages/omamobile-omarchy/lib/update-bin/omarchy-migrate index 164f0de87..b8fe26421 100755 --- a/packages/omamobile-omarchy/lib/update-bin/omarchy-migrate +++ b/packages/omamobile-omarchy/lib/update-bin/omarchy-migrate @@ -14,14 +14,31 @@ # notice doesn't keep offering it) and listed in # ~/.local/state/omamobile/update/held-migrations; after a review, # omamobile-update run-migration runs it. OMAMOBILE_HOLD_MIGRATIONS=0 -# holds nothing. +# holds none of the generic desktop matches. Named mobile migrations and +# mobile-critical PAM/input/video matches remain held until reviewed/run +# individually. real=${OMAMOBILE_REAL_BIN:-/usr/bin}/omarchy-migrate case ${1:-} in --pending | --check | -h | --help) exec "$real" "$@" ;; esac -pattern='limine|mkinitcpio|initcpio|efibootmgr|sbctl|snapper|grub-|bootctl|fwupd|/boot/|plymouth-set-default-theme|dracut|linux-omarchy|nvidia|gum (confirm|choose|input|write|filter|file)|(install|cp|mv) [^|;&]*[[:space:]]"?/etc/pacman\.conf"?[[:space:]]*($|[;&|])|omarchy-refresh-pacman' -if [[ ${OMAMOBILE_HOLD_MIGRATIONS:-1} == 1 ]]; then +pattern='limine|mkinitcpio|initcpio|efibootmgr|sbctl|snapper|grub-|bootctl|fwupd|/boot/|plymouth-set-default-theme|dracut|linux-omarchy|nvidia|gum (confirm|choose|input|write|filter|file)|(install|cp|mv) [^|;&]*[[:space:]]"?/etc/pacman\.conf"?[[:space:]]*($|[;&|])|omarchy-refresh-pacman|owedvideo|fcitx|omarchy-apply-lock|/etc/pam\.d/|system-sleep/fprintd' +# These releases contain concrete unreviewed phone regressions; a broad +# generic-hold override must not silently enable them. +mobile_pattern='omarchy-hyprland-titlebars|owedvideo|fcitx|omarchy-apply-lock|/etc/pam\.d/|system-sleep/fprintd' +mobile_hold_reason() { + case $1 in + 1791403310.sh) echo 'installs titlebars pinned to a different Hyprland build' ;; + 1789764927.sh) echo 'starts owedvideo (unreviewed mobile video pipeline)' ;; + 1791367434.sh) echo 'replaces input method with Fcitx defaults' ;; + 1792648436.sh) echo 'deletes notification history/images (backup and review required)' ;; + 1791125650.sh) echo 'changes fprintd resume/stop lifecycle (preserve mobile PAM/claim policy)' ;; + esac +} +# Only an explicit 0 disables generic holds; malformed values stay safe. +hold_generic=1 +[[ ${OMAMOBILE_HOLD_MIGRATIONS:-1} == 0 ]] && hold_generic=0 +{ omarchy_path=${OMARCHY_PATH:-/usr/share/omarchy} state=${OMARCHY_MIGRATION_STATE:-$HOME/.local/state/omarchy/migrations} held=$HOME/.local/state/omamobile/update/held-migrations @@ -29,7 +46,14 @@ if [[ ${OMAMOBILE_HOLD_MIGRATIONS:-1} == 1 ]]; then [[ -f $file ]] || continue name=${file##*/} [[ -f $state/$name ]] && continue - match=$(grep -m1 -oE "$pattern" "$file" || true) + match=$(mobile_hold_reason "$name") + reason=$match + if [[ -z $match ]]; then + match=$(grep -m1 -oE "$mobile_pattern" "$file" || true) + fi + if [[ -z $match && $hold_generic == 1 ]]; then + match=$(grep -m1 -oE "$pattern" "$file" || true) + fi [[ -n $match ]] || continue match=${match%%$'\n'*} title=$(sed -n '1s/^echo "\(.*\)"$/\1/p' "$file") @@ -37,14 +61,15 @@ if [[ ${OMAMOBILE_HOLD_MIGRATIONS:-1} == 1 ]]; then touch "$state/$name" printf '%s\t%s\t%s\n' "$name" "$match" "${title:-}" >>"$held" [[ -n ${OMAMOBILE_UPDATE_DIR:-} ]] && printf '%s\t%s\t%s\n' "$name" "$match" "${title:-}" >>"$OMAMOBILE_UPDATE_DIR/held" - echo "Holding migration ${name%.sh}${title:+ ($title)}: it mentions $match." + [[ -n $reason ]] || reason="mentions $match" + echo "Holding migration ${name%.sh}${title:+ ($title)}: $reason." if [[ $match == *pacman* ]]; then echo " Don't run it by hand: it would put [omarchy] above [omamobile] again." else echo " Review it, then: omamobile-update run-migration $name" fi done -fi +} rc=0 "$real" "$@" || rc=$? diff --git a/packages/omamobile-omarchy/test/all b/packages/omamobile-omarchy/test/all index c1f63713f..dbd0f43c8 100755 --- a/packages/omamobile-omarchy/test/all +++ b/packages/omamobile-omarchy/test/all @@ -100,3 +100,5 @@ if [[ -n ${OMAMOBILE_NOTIFY_TEST:-} ]]; then || fail "inline reply (test/notifications-reply)" pass "inline reply end to end" fi + +python3 -I test/migration-mobile-holds.py || fail "mobile-critical migration holds" diff --git a/packages/omamobile-omarchy/test/migration-mobile-holds.py b/packages/omamobile-omarchy/test/migration-mobile-holds.py new file mode 100644 index 000000000..ade8915f3 --- /dev/null +++ b/packages/omamobile-omarchy/test/migration-mobile-holds.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Run the real wrapper against inert migrations; no package manager is run.""" +import os +from pathlib import Path +import shutil +import subprocess +import tempfile + +PACKAGE = Path(__file__).resolve().parent.parent +NAMED = ['1789764927', '1791367434', '1792648436', '1791125650', '1791403310'] +SEMANTIC = ['9999999999', '9999999997'] + +with tempfile.TemporaryDirectory(prefix='omamobile-migration-holds-') as tmp: + root = Path(tmp) + home = root / 'home' + real = root / 'real' + real.mkdir() + tree = root / 'omarchy' + migrations = tree / 'migrations' + migrations.mkdir(parents=True) + for name in NAMED: + (migrations / f'{name}.sh').write_text('echo "Named migration"\ntrue\n') + (migrations / '9999999999.sh').write_text('omarchy-apply-lock\n') + (migrations / '9999999997.sh').write_text('omarchy-pkg-add omarchy-hyprland-titlebars\n') + (migrations / '9999999998.sh').write_text('echo "Harmless fixture"\ntrue\n') + (migrations / '9999999996.sh').write_text('mkinitcpio -P\n') + + marker = root / 'real-called' + runner = real / 'omarchy-migrate' + runner.write_text( + '#!/bin/bash\nset -eu\n' + f'touch "{marker}"\n' + 'for name in ' + ' '.join(NAMED + SEMANTIC) + '; do\n' + ' test -f "$HOME/.local/state/omarchy/migrations/$name.sh" || ' + '{ echo "UNHELD:$name" >&2; exit 90; }\n' + 'done\n' + ) + runner.chmod(0o755) + conf = root / 'pacman.conf' + conf.write_text('[options]\n[omamobile]\n[omarchy]\n[core]\n') + pam = root / 'pam' + pam.mkdir() + password = pam / 'omarchy-lock-password' + fingerprint = pam / 'omarchy-lock-fingerprint' + password.write_text('custom PIN stack unchanged\n') + fingerprint.write_text('auth required pam_fprintd.so max-tries=1\n') + before = (password.read_bytes(), fingerprint.read_bytes()) + + for flag in ['1', '0', '', '2', 'false', 'unexpected']: + shutil.rmtree(home, ignore_errors=True) + marker.unlink(missing_ok=True) + env = dict( + os.environ, + HOME=str(home), + OMARCHY_PATH=str(tree), + OMAMOBILE_REAL_BIN=str(real), + OMAMOBILE_PACMAN_CONF=str(conf), + OMAMOBILE_HOLD_MIGRATIONS=flag, + ) + result = subprocess.run( + ['bash', str(PACKAGE / 'lib/update-bin/omarchy-migrate')], + env=env, capture_output=True, text=True, check=True, + ) + state = home / '.local/state/omarchy/migrations' + held = home / '.local/state/omamobile/update/held-migrations' + text = held.read_text() + for name in NAMED + SEMANTIC: + assert (state / f'{name}.sh').is_file(), name + assert f'{name}.sh\t' in text, name + assert marker.exists() + assert (password.read_bytes(), fingerprint.read_bytes()) == before + assert not (state / '9999999998.sh').exists() + assert (state / '9999999996.sh').exists() == (flag != '0') + assert 'it mentions starts' not in result.stdout + assert 'installs titlebars pinned to a different Hyprland build.' in result.stdout + print(f'PASS: named/semantic holds and safe flag normalization ({flag!r})') diff --git a/packages/omamobile-omarchy/test/update.sh b/packages/omamobile-omarchy/test/update.sh index f0aad3820..668b8f6f4 100755 --- a/packages/omamobile-omarchy/test/update.sh +++ b/packages/omamobile-omarchy/test/update.sh @@ -118,7 +118,18 @@ touch "$HOME/.local/state/omarchy/migrations/1700000000.sh" echo "omarchy 4.0.4-2 -> 4.0.5-1" >"$t/updates" printf 'omarchy 4.0.5-1\nmesa 26.1-1\n' >"$t/plan" echo '{"result": "ok", "applied": ["0003-x.patch"], "upstream": ["0000-y.patch"], "omarchy": "omarchy 4.0.5-1"}' >"$t/patch-status.json" -U=$PKG/bin/omamobile-update +# Mock host disk capacity inside the fixture interpreter, not through a new +# production bypass flag. The runtime's 10 GiB rule stays unchanged. +export OMAMOBILE_UPDATE_REAL_SOURCE=$PKG/bin/omamobile-update +cat >"$t/update-fixture.py" <<'PYCODE' +import os, runpy, sys +scope = runpy.run_path(os.environ["OMAMOBILE_UPDATE_REAL_SOURCE"], run_name="update_fixture") +scope["check"].__globals__["free_bytes"] = lambda: 20 * 1024 ** 3 +globals().update({k: v for k, v in scope.items() if not k.startswith("__")}) +if __name__ == "__main__": + sys.exit(scope["main"](sys.argv[1:])) +PYCODE +U=$t/update-fixture.py wait_done() { for _ in $(seq 150); do grep -cP '^state\tdone' "$XDG_RUNTIME_DIR/omamobile-update/events" >/dev/null 2>&1 && return 0; sleep 0.1; done diff --git a/packages/omamobile-omarchy/version b/packages/omamobile-omarchy/version index 50140e353..9dd179330 100644 --- a/packages/omamobile-omarchy/version +++ b/packages/omamobile-omarchy/version @@ -1 +1 @@ -0.1.33 +0.1.34