installer: tolerate missing tty in offline finalizer

This commit is contained in:
Ryan Hughes
2026-06-04 18:35:01 -04:00
parent e67128e4c9
commit 96a020f756
4 changed files with 54 additions and 13 deletions
+15 -10
View File
@@ -47,19 +47,24 @@ install)
# exists, with /mnt taking precedence (only present in the ISO context, and
# there it's the right one).
ARCHINSTALL_LOG="/var/log/archinstall/install.log"
if [[ -s /mnt/var/log/omarchy-install.log ]]; then
OMARCHY_LOG="/mnt/var/log/omarchy-install.log"
else
OMARCHY_LOG="/var/log/omarchy-install.log"
fi
LIVE_OMARCHY_LOG="/var/log/omarchy-install.log"
TARGET_OMARCHY_LOG="/mnt/var/log/omarchy-install.log"
cat "$SYSTEM_INFO" >"$TEMP_LOG"
[[ -s $ARCHINSTALL_LOG ]] && cat "$ARCHINSTALL_LOG" >>"$TEMP_LOG"
if [[ -s $OMARCHY_LOG ]]; then
printf '\n========================================\nOMARCHY INSTALL LOG (%s)\n========================================\n\n' "$OMARCHY_LOG" >>"$TEMP_LOG"
cat "$OMARCHY_LOG" >>"$TEMP_LOG"
else
echo "Warning: omarchy install log not found (looked at /mnt/var/log/ and /var/log/)" >&2
if [[ -s $LIVE_OMARCHY_LOG ]]; then
printf '\n========================================\nOMARCHY INSTALL LOG (%s)\n========================================\n\n' "$LIVE_OMARCHY_LOG" >>"$TEMP_LOG"
cat "$LIVE_OMARCHY_LOG" >>"$TEMP_LOG"
fi
if [[ -s $TARGET_OMARCHY_LOG ]] && ! cmp -s "$LIVE_OMARCHY_LOG" "$TARGET_OMARCHY_LOG" 2>/dev/null; then
printf '\n========================================\nTARGET OMARCHY INSTALL LOG (%s)\n========================================\n\n' "$TARGET_OMARCHY_LOG" >>"$TEMP_LOG"
cat "$TARGET_OMARCHY_LOG" >>"$TEMP_LOG"
fi
if [[ ! -s $LIVE_OMARCHY_LOG && ! -s $TARGET_OMARCHY_LOG ]]; then
echo "Warning: omarchy install log not found (looked at /var/log and /mnt/var/log)" >&2
fi
if [[ ! -s $TEMP_LOG ]]; then
+1 -2
View File
@@ -89,7 +89,6 @@ catch_errors() {
stop_log_output
if [[ -n ${OMARCHY_CHROOT_FINALIZER:-} ]]; then
show_cursor
{
echo "Omarchy installation stopped inside offline finalizer."
echo "This command halted with exit code $exit_code:"
@@ -168,7 +167,7 @@ exit_handler() {
catch_errors "$exit_code"
else
stop_log_output
show_cursor
[[ -n ${OMARCHY_CHROOT_FINALIZER:-} ]] || show_cursor
fi
}
+1 -1
View File
@@ -5,7 +5,7 @@ fi
# Get terminal size from /dev/tty (works in all scenarios: direct, sourced, or piped)
if [[ -e /dev/tty ]]; then
TERM_SIZE=$(stty size 2>/dev/null </dev/tty)
TERM_SIZE=$(stty size 2>/dev/null </dev/tty || true)
if [[ -n $TERM_SIZE ]]; then
export TERM_HEIGHT=$(echo "$TERM_SIZE" | cut -d' ' -f1)
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Ensure the offline/chroot finalizer can source helpers with no controlling tty.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
output="$({
setsid -w bash -c '
set -eEo pipefail
export OMARCHY_INSTALL="$1/install"
export OMARCHY_PATH="${OMARCHY_TEST_OMARCHY_PATH:-/usr/share/omarchy}"
export OMARCHY_INSTALL_MODE=offline
export OMARCHY_CHROOT_FINALIZER=1
export HOME="$(mktemp -d)"
export USER=ryan
source "$OMARCHY_INSTALL/helpers/mode.sh"
detect_install_mode
export_legacy_mode_flags
source "$OMARCHY_INSTALL/helpers/all.sh"
echo helpers-loaded
' bash "$ROOT" </dev/null
} 2>&1)"
printf '%s\n' "$output"
if [[ $output != *helpers-loaded* ]]; then
echo "expected helpers-loaded marker" >&2
exit 1
fi
if [[ $output == *$'\033[?25h'* ]]; then
echo "offline finalizer helper bootstrap leaked cursor escape" >&2
exit 1
fi
echo "offline finalizer bootstrap test passed"