Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions packages/omamobile-omarchy/lib/update-bin/omarchy-migrate
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,62 @@
# notice doesn't keep offering it) and listed in
# ~/.local/state/omamobile/update/held-migrations; after a review,
# omamobile-update run-migration <name> 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
for file in "$omarchy_path"/migrations/*.sh; do
[[ -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")
mkdir -p "$state" "${held%/*}"
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=$?

Expand Down
2 changes: 2 additions & 0 deletions packages/omamobile-omarchy/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -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"
77 changes: 77 additions & 0 deletions packages/omamobile-omarchy/test/migration-mobile-holds.py
Original file line number Diff line number Diff line change
@@ -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})')
13 changes: 12 additions & 1 deletion packages/omamobile-omarchy/test/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-omarchy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.33
0.1.34