Defer channel switch reboot until after update
This commit is contained in:
+10
-1
@@ -46,6 +46,7 @@ link_dev_checkout() {
|
||||
|
||||
dev_checkout=""
|
||||
channel="$1"
|
||||
leaving_dev=0
|
||||
|
||||
case "$channel" in
|
||||
stable)
|
||||
@@ -74,13 +75,21 @@ case "$channel" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -z $dev_checkout && $OMARCHY_PATH != "/usr/share/omarchy" ]]; then
|
||||
leaving_dev=1
|
||||
fi
|
||||
|
||||
omarchy-refresh-pacman "$pacman_channel"
|
||||
# --ask 4 accepts omarchy <-> omarchy-dev replacement prompts without file overwrites.
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -S --needed --noconfirm --ask 4 "${packages[@]}"
|
||||
|
||||
if [[ -z $dev_checkout ]]; then
|
||||
omarchy-dev-unlink
|
||||
omarchy-dev-unlink --no-reboot
|
||||
export OMARCHY_PATH=/usr/share/omarchy
|
||||
|
||||
if (( leaving_dev )); then
|
||||
omarchy-state set reboot-required
|
||||
fi
|
||||
fi
|
||||
|
||||
omarchy-update -y
|
||||
|
||||
+27
-6
@@ -2,6 +2,7 @@
|
||||
|
||||
# omarchy:summary=Restore Omarchy to the package install after reboot
|
||||
# omarchy:group=dev
|
||||
# omarchy:args=[--no-reboot]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
@@ -10,16 +11,36 @@ if (( EUID == 0 )); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then
|
||||
cat <<USAGE
|
||||
Usage: omarchy dev unlink
|
||||
prompt_reboot=1
|
||||
|
||||
if (( $# > 1 )); then
|
||||
echo "Usage: omarchy dev unlink [--no-reboot]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${1:-}" in
|
||||
"")
|
||||
;;
|
||||
--no-reboot)
|
||||
prompt_reboot=0
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<USAGE
|
||||
Usage: omarchy dev unlink [--no-reboot]
|
||||
|
||||
Writes /etc/omarchy.conf so OMARCHY_PATH resolves to /usr/share/omarchy
|
||||
after reboot. This intentionally does not rewrite the running Hyprland,
|
||||
systemd, shell, or app-launcher environment; reboot to make every layer agree.
|
||||
|
||||
Use --no-reboot when another command will handle the reboot prompt.
|
||||
USAGE
|
||||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Usage: omarchy dev unlink [--no-reboot]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
default_target="/usr/share/omarchy"
|
||||
|
||||
@@ -28,6 +49,6 @@ printf 'export OMARCHY_PATH="%s"\n' "$default_target" | sudo tee /etc/omarchy.co
|
||||
echo "Pointed Omarchy at $default_target"
|
||||
echo
|
||||
|
||||
if gum confirm "Reboot now to activate?"; then
|
||||
if (( prompt_reboot )) && gum confirm "Reboot now to activate?"; then
|
||||
omarchy-system-reboot
|
||||
fi
|
||||
|
||||
@@ -37,6 +37,12 @@ for arg in "$@"; do printf "\t%s" "$arg" >>"$OMARCHY_CHANNEL_TEST_LOG"; done
|
||||
printf "\n" >>"$OMARCHY_CHANNEL_TEST_LOG"
|
||||
'
|
||||
|
||||
write_stub omarchy-state '#!/bin/bash
|
||||
printf "state" >>"$OMARCHY_CHANNEL_TEST_LOG"
|
||||
for arg in "$@"; do printf "\t%s" "$arg" >>"$OMARCHY_CHANNEL_TEST_LOG"; done
|
||||
printf "\n" >>"$OMARCHY_CHANNEL_TEST_LOG"
|
||||
'
|
||||
|
||||
write_stub omarchy-update '#!/bin/bash
|
||||
printf "update" >>"$OMARCHY_CHANNEL_TEST_LOG"
|
||||
for arg in "$@"; do printf "\t%s" "$arg" >>"$OMARCHY_CHANNEL_TEST_LOG"; done
|
||||
@@ -83,7 +89,7 @@ esac
|
||||
run_channel() {
|
||||
: >"$log_file"
|
||||
OMARCHY_CHANNEL_TEST_LOG="$log_file" \
|
||||
OMARCHY_PATH="$ROOT" \
|
||||
OMARCHY_PATH="${OMARCHY_TEST_PATH:-/usr/share/omarchy}" \
|
||||
HOME="$test_tmp/home" \
|
||||
PATH="$stub_bin:$ROOT/bin:$PATH" \
|
||||
"$ROOT/bin/omarchy-channel-set" "$@"
|
||||
@@ -100,20 +106,28 @@ assert_log_line() {
|
||||
run_channel stable
|
||||
assert_log_line $'refresh\tstable' "stable refreshes the stable pacman channel"
|
||||
assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy\tomarchy-settings' "stable installs stable Omarchy packages"
|
||||
assert_log_line 'unlink' "stable restores the package-backed Omarchy path"
|
||||
assert_log_line $'unlink\t--no-reboot' "stable restores the package-backed Omarchy path without an early reboot prompt"
|
||||
assert_log_line $'update\t-y' "stable runs the normal update pipeline"
|
||||
if grep -q $'^state\tset\treboot-required$' "$log_file"; then
|
||||
fail "stable does not require reboot when already package-backed" "$(cat "$log_file")"
|
||||
fi
|
||||
pass "stable does not require reboot when already package-backed"
|
||||
|
||||
run_channel rc
|
||||
assert_log_line $'refresh\trc' "rc refreshes the rc pacman channel"
|
||||
assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy\tomarchy-settings' "rc installs rc Omarchy packages"
|
||||
assert_log_line 'unlink' "rc restores the package-backed Omarchy path"
|
||||
assert_log_line $'unlink\t--no-reboot' "rc restores the package-backed Omarchy path without an early reboot prompt"
|
||||
assert_log_line $'update\t-y' "rc runs the normal update pipeline"
|
||||
|
||||
run_channel edge
|
||||
OMARCHY_TEST_PATH="$ROOT" run_channel edge
|
||||
assert_log_line $'refresh\tedge' "edge refreshes the edge pacman channel"
|
||||
assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "edge installs development Omarchy packages"
|
||||
assert_log_line 'unlink' "edge remains package-backed"
|
||||
assert_log_line $'unlink\t--no-reboot' "edge unlinks dev without an early reboot prompt"
|
||||
assert_log_line $'state\tset\treboot-required' "edge marks reboot required when leaving dev"
|
||||
assert_log_line $'update\t-y' "edge runs the normal update pipeline"
|
||||
[[ $(grep -E '^(unlink|state|update)' "$log_file") == $'unlink\t--no-reboot\nstate\tset\treboot-required\nupdate\t-y' ]] ||
|
||||
fail "edge defers the reboot prompt until the update restart stage" "$(cat "$log_file")"
|
||||
pass "edge defers the reboot prompt until the update restart stage"
|
||||
|
||||
checkout="$test_tmp/home/omarchy"
|
||||
mkdir -p "$checkout"
|
||||
@@ -135,8 +149,9 @@ assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--no
|
||||
assert_log_line $'git\tclone\thttps://github.com/basecamp/omarchy.git\t'"$checkout" "dev clones the source checkout to ~/omarchy"
|
||||
assert_log_line $'link\t'"$checkout" "dev links ~/omarchy"
|
||||
|
||||
run_channel stable
|
||||
assert_log_line 'unlink' "switching from dev to stable unlinks the source checkout"
|
||||
OMARCHY_TEST_PATH="$checkout" run_channel stable
|
||||
assert_log_line $'unlink\t--no-reboot' "switching from dev to stable unlinks without an early reboot prompt"
|
||||
assert_log_line $'state\tset\treboot-required' "switching from dev to stable marks reboot required"
|
||||
|
||||
run_channel dev
|
||||
if grep -q $'^git\tclone\t' "$log_file"; then
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
test_tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$test_tmp"' EXIT
|
||||
|
||||
stub_bin="$test_tmp/bin"
|
||||
log_file="$test_tmp/dev-unlink.log"
|
||||
conf_file="$test_tmp/omarchy.conf"
|
||||
mkdir -p "$stub_bin" "$test_tmp/home"
|
||||
|
||||
cat >"$stub_bin/sudo" <<'SH'
|
||||
#!/bin/bash
|
||||
|
||||
printf 'sudo' >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
for arg in "$@"; do
|
||||
printf '\t%s' "$arg" >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
done
|
||||
printf '\n' >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
|
||||
if [[ $1 == "tee" ]]; then
|
||||
cat >"$OMARCHY_DEV_UNLINK_TEST_CONF"
|
||||
fi
|
||||
SH
|
||||
chmod +x "$stub_bin/sudo"
|
||||
|
||||
cat >"$stub_bin/gum" <<'SH'
|
||||
#!/bin/bash
|
||||
|
||||
printf 'gum' >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
for arg in "$@"; do
|
||||
printf '\t%s' "$arg" >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
done
|
||||
printf '\n' >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
SH
|
||||
chmod +x "$stub_bin/gum"
|
||||
|
||||
cat >"$stub_bin/omarchy-system-reboot" <<'SH'
|
||||
#!/bin/bash
|
||||
|
||||
printf 'reboot\n' >>"$OMARCHY_DEV_UNLINK_TEST_LOG"
|
||||
SH
|
||||
chmod +x "$stub_bin/omarchy-system-reboot"
|
||||
|
||||
run_unlink() {
|
||||
HOME="$test_tmp/home" \
|
||||
OMARCHY_DEV_UNLINK_TEST_LOG="$log_file" \
|
||||
OMARCHY_DEV_UNLINK_TEST_CONF="$conf_file" \
|
||||
PATH="$stub_bin:$PATH" \
|
||||
"$ROOT/bin/omarchy-dev-unlink" "$@"
|
||||
}
|
||||
|
||||
: >"$log_file"
|
||||
run_unlink --no-reboot
|
||||
|
||||
grep -Fx $'sudo\ttee\t/etc/omarchy.conf' "$log_file" >/dev/null ||
|
||||
fail "dev unlink writes the package path without rebooting" "$(cat "$log_file")"
|
||||
[[ $(<"$conf_file") == 'export OMARCHY_PATH="/usr/share/omarchy"' ]] ||
|
||||
fail "dev unlink writes the package path guard" "$(<"$conf_file")"
|
||||
if grep -Eq '^(gum|reboot)' "$log_file"; then
|
||||
fail "dev unlink --no-reboot skips the reboot prompt" "$(cat "$log_file")"
|
||||
fi
|
||||
pass "dev unlink --no-reboot skips the reboot prompt"
|
||||
|
||||
: >"$log_file"
|
||||
run_unlink
|
||||
|
||||
grep -Fx $'gum\tconfirm\tReboot now to activate?' "$log_file" >/dev/null ||
|
||||
fail "interactive dev unlink still prompts for reboot" "$(cat "$log_file")"
|
||||
grep -Fx 'reboot' "$log_file" >/dev/null ||
|
||||
fail "interactive dev unlink still reboots after confirmation" "$(cat "$log_file")"
|
||||
pass "interactive dev unlink keeps its reboot prompt"
|
||||
|
||||
if run_unlink --invalid >"$test_tmp/invalid.out" 2>"$test_tmp/invalid.err"; then
|
||||
fail "dev unlink rejects unknown arguments"
|
||||
fi
|
||||
grep -F 'Usage: omarchy dev unlink [--no-reboot]' "$test_tmp/invalid.err" >/dev/null ||
|
||||
fail "dev unlink explains valid arguments" "$(cat "$test_tmp/invalid.err")"
|
||||
pass "dev unlink rejects unknown arguments"
|
||||
Reference in New Issue
Block a user