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
17 changes: 17 additions & 0 deletions migrations/1790461245.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
echo "Move this Mac onto Omarchy's official packages with the released omarchy-mac-boot"

# Only this runtime carries it; official Omarchy reaches a Mac through
# 1790347292 and its installed omarchy-mac-boot. A tester's Mac may have no
# omarchy-mac-boot or an unofficial one, and may have run 1790347292 before
# any target existed, so this runs the engine from a verified download of the
# official package. Until that package ships its target, and while preflight
# refuses, it exits 75 and stays pending without holding up the update. The
# work is machine-wide: once it ran, the marker spares every other account.
marker="${OMARCHY_MAC_ACTIVATION_MARKER:-/var/lib/omarchy/migrations/1790461245}"
[[ ! -e $marker ]] || exit 0

platform=$(omarchy-hw-platform)
[[ $platform == "apple-silicon" ]] || exit 0

sudo omarchy-mac-migrate-bootstrap
sudo install -Dm644 /dev/null "$marker"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Activates the Mac migration (ticket 53): Macs move onto Omarchy's stable channel.
format=1
type=repository
channel=stable
6 changes: 4 additions & 2 deletions packages/omarchy-mac/boot/test/mac-migrate-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ echo generic-aarch64 >"$F/platform"
output=$(migrate run 2>&1) || fail "another platform is a no-op" "$output"
grep -q "Not an Apple Silicon Mac" <<<"$output" && [[ ! -e $(state_dir) ]] || fail "another platform is left alone" "$output"
echo apple-silicon >"$F/platform"
rm "$R/etc/omarchy-mac/migration-target"
rm "$R/etc/omarchy-mac/migration-target" "$R/usr/lib/omarchy-mac/boot/migration-target"
output=$(migrate run 2>&1) || fail "no target is a no-op" "$output"
grep -q "No migration target is set" <<<"$output" && [[ ! -e $(state_dir) ]] || fail "without a target nothing runs" "$output"
if OMARCHY_MAC_MIGRATE_ROOT="" "$R/usr/bin/omarchy-mac-migrate" run 2>/dev/null; then fail "a normal user without a fixture root is refused"; fi
Expand Down Expand Up @@ -790,11 +790,13 @@ pass "a repository target (omacom stable later) replaces the same names from [om
[[ -x $R/usr/lib/omarchy/mac-boot/migrate && $(stat -c %a "$R/usr/lib/omarchy/mac-boot/migrate") == 755 ]] ||
fail "the migrate entrypoint is staged for omarchy-lifecycle-dispatch"
[[ -f $R/usr/lib/systemd/system/omarchy-mac-migrate-verify.service ]] || fail "the post-reboot unit is staged"
[[ $(grep -v '^#' "$R/usr/lib/omarchy-mac/boot/migration-target") == $'format=1\ntype=repository\nchannel=stable' ]] ||
fail "the package activates the migration onto Omarchy's stable channel"
for file in migrate-engine.sh migrate-tester.sh migrate-legacy.sh migrate-mx-mac.sh; do
[[ -f $R/usr/lib/omarchy-mac/boot/$file ]] || fail "$file is staged"
done
new_fixture entrypoint
output=$(OMARCHY_MAC_MIGRATE_ROOT=$R MIGRATE_FIXTURE=$F PATH="$stubs:$PATH" "$R/usr/lib/omarchy/mac-boot/migrate" 2>&1) ||
fail "the dispatch entrypoint runs the migration" "$output"
grep -q "Reboot to finish" <<<"$output" || fail "the entrypoint runs omarchy-mac-migrate run" "$output"
pass "the package ships the dispatch entrypoint, the engine and the post-reboot unit"
pass "the package ships the dispatch entrypoint, the engine, the post-reboot unit and the stable target that activates it"
51 changes: 51 additions & 0 deletions test/shell.d/mac-activation-migration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

# The runtime's Mac activation migration runs omarchy-mac-migrate-bootstrap as
# root on Apple Silicon, passes its deferral (75) or failure on, and writes the
# machine-wide marker only once it succeeded.
migration=$ROOT/migrations/1790461245.sh
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/bin"
printf '#!/bin/bash\ncat "$FIXTURE/platform"\n' >"$tmp/bin/omarchy-hw-platform"
printf '#!/bin/bash\necho "bootstrap $*" >>"$FIXTURE/ran"\nexit "$(cat "$FIXTURE/status")"\n' >"$tmp/bin/omarchy-mac-migrate-bootstrap"
cat >"$tmp/bin/sudo" <<'SH'
#!/bin/bash
echo "sudo $*" >>"$FIXTURE/ran"
exec "$@"
SH
chmod 755 "$tmp/bin"/*
marker=$tmp/state/1790461245

run_migration() {
rm -f "$tmp/ran"
FIXTURE=$tmp PATH="$tmp/bin:$PATH" OMARCHY_PATH=$ROOT OMARCHY_MAC_ACTIVATION_MARKER=$marker bash -euo pipefail "$migration"
}

[[ $(stat -c %a "$migration") == 644 ]] || fail "the migration is mode 644"
head -n 1 "$migration" | grep -q '^echo ' || fail "the migration starts with an echo"

echo generic >"$tmp/platform"
echo 0 >"$tmp/status"
run_migration >/dev/null || fail "another platform: the migration completes"
[[ ! -e $tmp/ran && ! -e $marker ]] || fail "another platform: nothing runs" "$(cat "$tmp/ran" 2>/dev/null)"
pass "anything but an Apple Silicon Mac completes the migration and runs nothing"

echo apple-silicon >"$tmp/platform"
for status in 75 1; do
echo "$status" >"$tmp/status"
result=0
run_migration >/dev/null 2>&1 || result=$?
(( result == status )) && [[ ! -e $marker ]] || fail "a bootstrap exiting $status leaves the migration pending with that status" "status $result"
done
echo 0 >"$tmp/status"
run_migration >/dev/null || fail "a Mac: the migration completes once the bootstrap did"
[[ $(sed -n 1,2p "$tmp/ran") == $'sudo omarchy-mac-migrate-bootstrap\nbootstrap ' && -e $marker ]] ||
fail "a Mac: the bootstrap runs as root, then the marker is written" "$(cat "$tmp/ran")"
run_migration >/dev/null || fail "another account: the migration completes"
[[ ! -e $tmp/ran ]] || fail "another account: nothing runs once the Mac migrated" "$(cat "$tmp/ran")"
pass "a Mac runs the bootstrap as root, stays pending while it defers or fails, and other accounts skip it once it ran"
Loading