Skip to content
Merged
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
20 changes: 19 additions & 1 deletion packages/omamobile-omarchy/bin/omamobile-update
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ directory of stand-ins first on PATH (/usr/lib/omamobile-omarchy/update-bin):
omarchy-migrate (boot-related migrations held), sudo
(non-interactive from the sheet)

Before anything is downloaded it refuses: below 30% battery unless charging,
It never runs as root (Omarchy records its migrations per user, and root's
record is empty). Before anything is downloaded it refuses: below 30%
battery unless charging,
when /etc/pacman.conf doesn't list [omamobile] first and [omarchy] before
Arch Linux ARM's repositories, when [omarchy] isn't Omarchy's stable
channel, and when the update would install another distribution's kernel,
Expand Down Expand Up @@ -106,6 +108,8 @@ PATCH_STATUS = os.environ.get("OMAMOBILE_PATCH_STATUS", "/var/lib/omamobile/omar
NOTIFY = os.environ.get("OMAMOBILE_NOTIFY", "omarchy-notification-send")
OMARCHY_PATH = os.environ.get("OMARCHY_PATH") or "/usr/share/omarchy"
MIN_BATTERY = int(os.environ.get("OMAMOBILE_MIN_BATTERY", "30"))
# Tests stand in for root here; nothing else should set it.
EUID = int(os.environ.get("OMAMOBILE_UPDATE_TEST_EUID") or os.geteuid())
MIN_FREE = 10 * 1024 ** 3 # omarchy-update-requires-free-space's limit
UNIT = "omamobile-update"
RELEASE_NOTES = "https://github.com/basecamp/omarchy/releases/latest"
Expand Down Expand Up @@ -770,6 +774,10 @@ def inner(args):
omarchy_line = next((l for l in lines if l.split()[0] in ("omarchy", "omarchy-dev")), "")
print("%d package(s) to update%s" % (len(targets) or len(lines), "; " + omarchy_line if omarchy_line else ""),
flush=True)
# Omarchy's scripts read OMARCHY_PATH under set -u (omarchy-update-dev:
# "unbound variable"). A session gets it from Omarchy's env-bootstrap;
# a root login over SSH or a TTY doesn't, so pass the default on.
env.setdefault("OMARCHY_PATH", OMARCHY_PATH)
env.update(PATH=SHIMS + ":" + env.get("PATH", "/usr/bin"), OMARCHY_UPDATE_LOGGED="1", OMAMOBILE_UPDATE="1",
OMAMOBILE_UPDATE_DIR=RUNTIME, OMAMOBILE_SUDO=SUDO, OMAMOBILE_UPDATE_STARTED=str(int(time.time())))
return subprocess.run([OMARCHY_UPDATE, "-y"], env=env).returncode
Expand Down Expand Up @@ -926,6 +934,16 @@ def main(argv):
for b in result["blockers"]:
print("Blocked: " + b)
return 0 if result["ok"] else 1
if cmd in ("run", "start", "__inner", "run-migration") and EUID == 0:
# Omarchy keeps the migrations it has run in the caller's home
# (~/.local/state/omarchy/migrations). Root's list is empty, so an
# update as root (a root login over SSH, as on 2026-11-09) ran every
# migration again as root: one swapped quickshell for an older
# quickshell-git, others wrote root's own configs.
print("omamobile-update: not as root. Run \"omarchy update\" as the phone's user, in a terminal on "
"the phone or from Settings: Omarchy records its migrations per user, and root's record is "
"empty, so every migration would run again as root.", file=sys.stderr)
return 5
if cmd == "run":
return run(args)
if cmd == "__inner":
Expand Down
20 changes: 20 additions & 0 deletions packages/omamobile-omarchy/test/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ EOF
cat >"$fake/omarchy-update" <<EOF
#!/bin/bash
echo "omarchy-update \$* OMARCHY_UPDATE_LOGGED=\$OMARCHY_UPDATE_LOGGED OMAMOBILE_UPDATE=\$OMAMOBILE_UPDATE" >>"$calls"
echo "omarchy-update OMARCHY_PATH=\${OMARCHY_PATH-unset}" >>"$calls"
for c in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-migrate omarchy-update-restart sudo; do
echo "resolve \$c \$(command -v \$c)" >>"$calls"
done
Expand Down Expand Up @@ -408,4 +409,23 @@ echo "omarchy 4.0.4-2 -> 4.0.5-1" >"$t/available"
python3 -I "$U" notify-check >/dev/null; python3 -I "$U" notify-check >/dev/null
ok "notify-check: one toast per release, opening the sheet" '[[ $(grep -c "^notify" "$calls") == 1 ]] && grep -c "summon omamobile.update" "$calls" >/dev/null'

# A root login over SSH (or a TTY) has no Omarchy session environment, and
# Omarchy's update scripts read OMARCHY_PATH under set -u: it still arrives
: >"$calls"
rc=0; out=$(printf '1234\n' | env -u OMARCHY_PATH python3 -I "$U" start) || rc=$?
ok "no OMARCHY_PATH in the environment: the update starts (exit 0, '$out')" '[[ $rc == 0 && $out == started ]]'
wait_done
ok "no OMARCHY_PATH in the environment: omarchy-update still gets Omarchy's (omarchy-update-dev)" 'grep -c "^omarchy-update OMARCHY_PATH=/usr/share/omarchy$" "$calls" >/dev/null'

# As root (a root login over SSH, 2026-11-09) Omarchy's per-user migration
# record is empty and every migration ran again as root: refused, nothing runs
: >"$calls"
for c in run start run-migration; do
rc=0; out=$(printf '1234\n' | OMAMOBILE_UPDATE_TEST_EUID=0 python3 -I "$U" $c 2>&1) || rc=$?
ok "as root: $c refused (exit 5) and says why" '[[ $rc == 5 && $out == *"not as root"* ]]'
done
ok "as root: nothing reached omarchy-update or sudo" '[[ ! -s $calls ]]'
rc=0; OMAMOBILE_UPDATE_TEST_EUID=0 python3 -I "$U" check --json >/dev/null || rc=$?
ok "as root: check still answers (read-only, exit $rc)" '[[ $rc == 0 || $rc == 1 ]]'

exit $((failures > 0))
2 changes: 1 addition & 1 deletion packages/omamobile-omarchy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.37
0.1.38