mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Add modifications to support Offline ISO (#1621)
* Change lazyvim and asdcontrol to packages * Remove asdcontrol and lazyvim * Add lazyvim setup * Don't trigger rebuild. We already rebuild later. * Add new pacman.conf after install * Update config to keep mirrors in mirrorlist * Add lazyvim setup back * Make webapp installer work with local images * Update tuis to work offline * Update pacman config situation * Extract the reboot segment into its own file * Explainer * Can't return in executed scripts * Add post-install * Extract the reboot segment into its own file * Fix rebase doubling up * Add run wrapper function for feedback * Redirect output to log * Move gnome updates to first-run * Add theme to first-run * Updat to try to get logging working * Create the file and give permissions * Test gsettings * Revert "Test gsettings" This reverts commit 49c27d319407f6c95fcbb4c5a2646e54b50c9ab4. * Stop logging * Add time outputs to end of logs * Rearrange some scripts to cleanup * Cleanup * Add timing to run script * Don't enable multilib for offline * Add prebuild ruby * Try spinner setup * Prevent exit 1 due to grep not matching * Update limine config to work for USB installs as well * Add offline install to env report * Fix grep pipefailure * Update logs exports to work with subshells * Fix backward logic * Attempt to fix logging again * Export chrootable for subshells * Clean up outputs * Move chrootable up * Source chroot instead * Changes for logging * Center up reboot notice * Update fixed paths * Update trap * Revert reverting precompiled ruby due to issues * Revert "Revert reverting precompiled ruby due to issues" This reverts commit c159e7dc51cfdd2fb750c49c66bc4468e1208446. * Remove junk to cleanup fixed paths now that we have relative * Add git branch check to transition beta to main * Log output * Add time output on summary screen * We don't need sudo here * Add ansi helpers to make code cleaner * Add dry-run helpers for testing * Split out some common / reused items * Add log output function * Use gum log to output cleaner * Cleanup * Update trap with options * Fix reboot and pad it * Cleanup * Add dry-run for testing * Use default $PADDING for gum * More styles * Styles and really exit * Update to new format * Add ansi vars * Update log output to prevent flickering * Fix logo exporting * Trap updates * Add exit handler * Prevent double-trapping * Update traps * Consolidate logic * Update reboot to work in chroot * Eliminate double-guard * Attempt to speed up by removing mkinitcpio hooks * Add multilib for nvidia users * Add back wireless-regdom * Remove dryrun items * Fix to be offline * Set fonts for plymouth to solve freetype2 issue * Required -y to run * Update omarchy-refresh-plymouth to account for limine changes * Update omarchy-refresh-plymouth to account for limine changes (#1575) * Required -y to run * Update omarchy-refresh-plymouth to account for limine changes --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> * Update modes * Remove direct executions of .sh files * Add variable safety * Add omarchy-upload-log * Add broadcome fix for MBP * Prevent printing on screen when rebooting * Make packages list universal * Rename * Remove retry message * Fix packages target * Add system info to upload * Update variable name * Remove unnecessary executable statuses * Remove gesture default * Add bcm4360 fix to install * Add useful debug info * Add OMARCHY_PATH * Only look locally offline * Rename / rearrange files * Export so they're available to subshells * Update for alternate * Rearrange * Log install time if no arch * Add limine to packages list * Update comments * Update sizing method * Update mode switcher * Move icons to be embedded in installer * Set install mode to online * shebang and sudo * Remove deleted branch check * Elim banners * Elim verbosity * Rename LOG_FILE * Multilib on by default * Flip to positive * Switch to gnome-theme.sh for first run * Elim ansi-codes helper * Move guard up to be the first thing that's hit * Extract a couple of functions * Trim * Trim * Move back to trap * Update to single gum file * Just show total * Pulled function to a helper * Extract explaining function * Use complete conditional flows where possible * Reference variable close to its use * Use modern bash conditional syntax * Comment before function * Use a simpler shared exit headline Doesn't matter how we stopped, just that we did * CRs * Keep constants together * Style on comment * Explain QR Code * Modern bash conditional and use lowercase for all local variables * Use bash calculation syntax for numbers * Use calculation syntax where possible * cleanup was not intention revealing enough imo * Spacing * Retry won't produce something different in offline mode * Not needed * Use modern bash conditional style * String-wrapping not needed in [[ ]] * Might as well use constants for all of these * Don't need the wrapping * Move the output saving into where we're working with it * Not needed as long as we just source this * Gum is a helper * Slim down logging setup * Reflect broader scope of work * Everything should live in file * Simpler * Ordering * Style * Better separation of concerns * Stop pretending these are meant to run directly * Move all packaging execution together * No longer used in an offline centric setup * None of these are directly executable any more either * Modern bash conditional * Better name * Explain what's going on * Use modern bash conditional * Use modern bash styule * No need for bashing --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: DoppioJP <jakub@doppio.jp>
This commit is contained in:
11
install/helpers/chroot.sh
Normal file
11
install/helpers/chroot.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
# Starting the installer with OMARCHY_CHROOT_INSTALL=1 will put it into chroot mode
|
||||
chrootable_systemctl_enable() {
|
||||
if [ -n "${OMARCHY_CHROOT_INSTALL:-}" ]; then
|
||||
sudo systemctl enable $1
|
||||
else
|
||||
sudo systemctl enable --now $1
|
||||
fi
|
||||
}
|
||||
|
||||
# Export the function so it's available in subshells
|
||||
export -f chrootable_systemctl_enable
|
||||
159
install/helpers/errors.sh
Normal file
159
install/helpers/errors.sh
Normal file
@@ -0,0 +1,159 @@
|
||||
# Directs user to Omarchy Discord
|
||||
QR_CODE='
|
||||
█▀▀▀▀▀█ ▄ ▄ ▀▄▄▄█ █▀▀▀▀▀█
|
||||
█ ███ █ ▄▄▄▄▀▄▀▄▀ █ ███ █
|
||||
█ ▀▀▀ █ ▄█ ▄█▄▄▀ █ ▀▀▀ █
|
||||
▀▀▀▀▀▀▀ ▀▄█ █ █ █ ▀▀▀▀▀▀▀
|
||||
▀▀█▀▀▄▀▀▀▀▄█▀▀█ ▀ █ ▀ █
|
||||
█▄█ ▄▄▀▄▄ ▀ ▄ ▀█▄▄▄▄ ▀ ▀█
|
||||
▄ ▄▀█ ▀▄▀▀▀▄ ▄█▀▄█▀▄▀▄▀█▀
|
||||
█ ▄▄█▄▀▄█ ▄▄▄ ▀ ▄▀██▀ ▀█
|
||||
▀ ▀ ▀ █ ▀▄ ▀▀█▀▀▀█▄▀
|
||||
█▀▀▀▀▀█ ▀█ ▄▀▀ █ ▀ █▄▀██
|
||||
█ ███ █ █▀▄▄▀ █▀███▀█▄██▄
|
||||
█ ▀▀▀ █ ██ ▀ █▄█ ▄▄▄█▀ █
|
||||
▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀ ▀ ▀▀▀▀▀▀'
|
||||
|
||||
# Track if we're already handling an error to prevent double-trapping
|
||||
ERROR_HANDLING=false
|
||||
|
||||
# Cursor is usually hidden while we install
|
||||
show_cursor() {
|
||||
printf "\033[?25h"
|
||||
}
|
||||
|
||||
# Display truncated log lines from the install log
|
||||
show_log_tail() {
|
||||
if [[ -f $OMARCHY_INSTALL_LOG_FILE ]]; then
|
||||
local log_lines=$(($TERM_HEIGHT - $LOGO_HEIGHT - 35))
|
||||
local max_line_width=$((LOGO_WIDTH - 4))
|
||||
|
||||
tail -n $log_lines "$OMARCHY_INSTALL_LOG_FILE" | while IFS= read -r line; do
|
||||
if ((${#line} > max_line_width)); then
|
||||
local truncated_line="${line:0:$max_line_width}..."
|
||||
else
|
||||
local truncated_line="$line"
|
||||
fi
|
||||
|
||||
gum style "$truncated_line"
|
||||
done
|
||||
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Display the failed command or script name
|
||||
show_failed_script_or_command() {
|
||||
if [[ -n ${CURRENT_SCRIPT:-} ]]; then
|
||||
gum style "Failed script: $CURRENT_SCRIPT"
|
||||
else
|
||||
# Truncate long command lines to fit the display
|
||||
local cmd="$BASH_COMMAND"
|
||||
local max_cmd_width=$((LOGO_WIDTH - 4))
|
||||
|
||||
if ((${#cmd} > max_cmd_width)); then
|
||||
cmd="${cmd:0:$max_cmd_width}..."
|
||||
fi
|
||||
|
||||
gum style "$cmd"
|
||||
fi
|
||||
}
|
||||
|
||||
# Save original stdout and stderr for trap to use
|
||||
save_original_outputs() {
|
||||
exec 3>&1 4>&2
|
||||
}
|
||||
|
||||
# Restore stdout and stderr to original (saved in FD 3 and 4)
|
||||
# This ensures output goes to screen, not log file
|
||||
restore_outputs() {
|
||||
if [ -e /proc/self/fd/3 ] && [ -e /proc/self/fd/4 ]; then
|
||||
exec 1>&3 2>&4
|
||||
fi
|
||||
}
|
||||
|
||||
# Error handler
|
||||
catch_errors() {
|
||||
# Prevent recursive error handling
|
||||
if [[ $ERROR_HANDLING == true ]]; then
|
||||
return
|
||||
else
|
||||
ERROR_HANDLING=true
|
||||
fi
|
||||
|
||||
# Store exit code immediately before it gets overwritten
|
||||
local exit_code=$?
|
||||
|
||||
stop_log_output
|
||||
restore_outputs
|
||||
|
||||
clear_logo
|
||||
show_cursor
|
||||
|
||||
gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Omarchy installation stopped!"
|
||||
show_log_tail
|
||||
|
||||
gum style "This command halted with exit code $exit_code:"
|
||||
show_failed_script_or_command
|
||||
|
||||
gum style "$QR_CODE"
|
||||
echo
|
||||
gum style "Get help from the community via QR code or at https://discord.gg/tXFUdasqhY"
|
||||
|
||||
# Offer options menu
|
||||
while true; do
|
||||
options=()
|
||||
|
||||
# If online install, show retry first
|
||||
if [[ ${OMARCHY_INSTALL_MODE:-offline} == "online" ]]; then
|
||||
options+=("Retry installation")
|
||||
fi
|
||||
|
||||
# Add upload option if internet is available
|
||||
if ping -c 1 -W 1 1.1.1.1 >/dev/null 2>&1; then
|
||||
options+=("Upload log for support")
|
||||
fi
|
||||
|
||||
# Add remaining options
|
||||
options+=("View full log")
|
||||
options+=("Exit")
|
||||
|
||||
choice=$(gum choose "${options[@]}" --header "What would you like to do?" --height 6 --padding "1 $PADDING_LEFT")
|
||||
|
||||
case "$choice" in
|
||||
"Retry installation")
|
||||
bash ~/.local/share/omarchy/install.sh
|
||||
break
|
||||
;;
|
||||
"View full log")
|
||||
less "$OMARCHY_INSTALL_LOG_FILE"
|
||||
;;
|
||||
"Upload log for support")
|
||||
omarchy-upload-install-log
|
||||
;;
|
||||
"Exit" | "")
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Exit handler - ensures cleanup happens on any exit
|
||||
exit_handler() {
|
||||
local exit_code=$?
|
||||
|
||||
# Only run if we're exiting with an error and haven't already handled it
|
||||
if [[ $exit_code -ne 0 && $ERROR_HANDLING != true ]]; then
|
||||
catch_errors
|
||||
else
|
||||
stop_log_output
|
||||
show_cursor
|
||||
fi
|
||||
}
|
||||
|
||||
# Set up traps
|
||||
trap catch_errors ERR INT TERM
|
||||
trap exit_handler EXIT
|
||||
|
||||
# Save original outputs in case we trap
|
||||
save_original_outputs
|
||||
18
install/helpers/gum.sh
Normal file
18
install/helpers/gum.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
# Ensure we have gum available
|
||||
if ! command -v gum &>/dev/null; then
|
||||
sudo pacman -S --needed --noconfirm gum
|
||||
fi
|
||||
|
||||
# Tokyo Night theme for gum confirm
|
||||
export GUM_CONFIRM_PROMPT_FOREGROUND="6" # Cyan for prompt
|
||||
export GUM_CONFIRM_SELECTED_FOREGROUND="0" # Black text on selected
|
||||
export GUM_CONFIRM_SELECTED_BACKGROUND="2" # Green background for selected
|
||||
export GUM_CONFIRM_UNSELECTED_FOREGROUND="7" # White for unselected
|
||||
export GUM_CONFIRM_UNSELECTED_BACKGROUND="0" # Black background for unselected
|
||||
export PADDING="0 0 0 $PADDING_LEFT" # Gum Style
|
||||
export GUM_CHOOSE_PADDING="$PADDING"
|
||||
export GUM_FILTER_PADDING="$PADDING"
|
||||
export GUM_INPUT_PADDING="$PADDING"
|
||||
export GUM_SPIN_PADDING="$PADDING"
|
||||
export GUM_TABLE_PADDING="$PADDING"
|
||||
export GUM_CONFIRM_PADDING="$PADDING"
|
||||
20
install/helpers/layout.sh
Normal file
20
install/helpers/layout.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
# 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)
|
||||
|
||||
if [ -n "$TERM_SIZE" ]; then
|
||||
export TERM_HEIGHT=$(echo "$TERM_SIZE" | cut -d' ' -f1)
|
||||
export TERM_WIDTH=$(echo "$TERM_SIZE" | cut -d' ' -f2)
|
||||
else
|
||||
# Fallback to reasonable defaults if stty fails
|
||||
export TERM_WIDTH=80
|
||||
export TERM_HEIGHT=24
|
||||
fi
|
||||
else
|
||||
# No terminal available (e.g., non-interactive environment)
|
||||
export TERM_WIDTH=80
|
||||
export TERM_HEIGHT=24
|
||||
fi
|
||||
|
||||
export PADDING_LEFT=$((($TERM_WIDTH - $LOGO_WIDTH) / 2))
|
||||
export PADDING_LEFT_SPACES=$(printf "%*s" $PADDING_LEFT "")
|
||||
134
install/helpers/logging.sh
Normal file
134
install/helpers/logging.sh
Normal file
@@ -0,0 +1,134 @@
|
||||
start_log_output() {
|
||||
local ANSI_SAVE_CURSOR="\033[s"
|
||||
local ANSI_RESTORE_CURSOR="\033[u"
|
||||
local ANSI_CLEAR_LINE="\033[2K"
|
||||
local ANSI_HIDE_CURSOR="\033[?25l"
|
||||
local ANSI_RESET="\033[0m"
|
||||
local ANSI_GRAY="\033[90m"
|
||||
|
||||
# Save cursor position and hide cursor
|
||||
printf $ANSI_SAVE_CURSOR
|
||||
printf $ANSI_HIDE_CURSOR
|
||||
|
||||
(
|
||||
local log_lines=20
|
||||
local max_line_width=$((LOGO_WIDTH - 4))
|
||||
|
||||
while true; do
|
||||
# Read the last N lines into an array
|
||||
mapfile -t current_lines < <(tail -n $log_lines "$OMARCHY_INSTALL_LOG_FILE" 2>/dev/null)
|
||||
|
||||
# Build complete output buffer with escape sequences
|
||||
output=""
|
||||
for ((i = 0; i < log_lines; i++)); do
|
||||
line="${current_lines[i]:-}"
|
||||
|
||||
# Truncate if needed
|
||||
if [ ${#line} -gt $max_line_width ]; then
|
||||
line="${line:0:$max_line_width}..."
|
||||
fi
|
||||
|
||||
# Add clear line escape and formatted output for each line
|
||||
if [ -n "$line" ]; then
|
||||
output+="${ANSI_CLEAR_LINE}${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
|
||||
else
|
||||
output+="${ANSI_CLEAR_LINE}${PADDING_LEFT_SPACES}\n"
|
||||
fi
|
||||
done
|
||||
|
||||
printf "${ANSI_RESTORE_CURSOR}%b" "$output"
|
||||
|
||||
sleep 0.1
|
||||
done
|
||||
) &
|
||||
monitor_pid=$!
|
||||
}
|
||||
|
||||
stop_log_output() {
|
||||
if [ -n "${monitor_pid:-}" ]; then
|
||||
kill $monitor_pid 2>/dev/null || true
|
||||
wait $monitor_pid 2>/dev/null || true
|
||||
unset monitor_pid
|
||||
fi
|
||||
}
|
||||
|
||||
start_install_log() {
|
||||
sudo touch "$OMARCHY_INSTALL_LOG_FILE"
|
||||
sudo chmod 666 "$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
export OMARCHY_START_TIME=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
echo "=== Omarchy Installation Started: $OMARCHY_START_TIME ===" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
start_log_output
|
||||
}
|
||||
|
||||
stop_install_log() {
|
||||
stop_log_output
|
||||
show_cursor
|
||||
|
||||
if [[ -n ${OMARCHY_INSTALL_LOG_FILE:-} ]]; then
|
||||
OMARCHY_END_TIME=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo "=== Omarchy Installation Completed: $OMARCHY_END_TIME ===" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
echo "" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
echo "=== Installation Time Summary ===" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
if [ -f "/var/log/archinstall/install.log" ]; then
|
||||
ARCHINSTALL_START=$(grep -m1 '^\[' /var/log/archinstall/install.log 2>/dev/null | sed 's/^\[\([^]]*\)\].*/\1/' || true)
|
||||
ARCHINSTALL_END=$(grep 'Installation completed without any errors' /var/log/archinstall/install.log 2>/dev/null | sed 's/^\[\([^]]*\)\].*/\1/' || true)
|
||||
|
||||
if [ -n "$ARCHINSTALL_START" ] && [ -n "$ARCHINSTALL_END" ]; then
|
||||
ARCH_START_EPOCH=$(date -d "$ARCHINSTALL_START" +%s)
|
||||
ARCH_END_EPOCH=$(date -d "$ARCHINSTALL_END" +%s)
|
||||
ARCH_DURATION=$((ARCH_END_EPOCH - ARCH_START_EPOCH))
|
||||
|
||||
ARCH_MINS=$((ARCH_DURATION / 60))
|
||||
ARCH_SECS=$((ARCH_DURATION % 60))
|
||||
|
||||
echo "Archinstall: ${ARCH_MINS}m ${ARCH_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$OMARCHY_START_TIME" ]; then
|
||||
OMARCHY_START_EPOCH=$(date -d "$OMARCHY_START_TIME" +%s)
|
||||
OMARCHY_END_EPOCH=$(date -d "$OMARCHY_END_TIME" +%s)
|
||||
OMARCHY_DURATION=$((OMARCHY_END_EPOCH - OMARCHY_START_EPOCH))
|
||||
|
||||
OMARCHY_MINS=$((OMARCHY_DURATION / 60))
|
||||
OMARCHY_SECS=$((OMARCHY_DURATION % 60))
|
||||
|
||||
echo "Omarchy: ${OMARCHY_MINS}m ${OMARCHY_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
if [ -n "$ARCH_DURATION" ]; then
|
||||
TOTAL_DURATION=$((ARCH_DURATION + OMARCHY_DURATION))
|
||||
TOTAL_MINS=$((TOTAL_DURATION / 60))
|
||||
TOTAL_SECS=$((TOTAL_DURATION % 60))
|
||||
echo "Total: ${TOTAL_MINS}m ${TOTAL_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
fi
|
||||
fi
|
||||
echo "=================================" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
echo "Rebooting system..." >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
run_logged() {
|
||||
local script="$1"
|
||||
|
||||
export CURRENT_SCRIPT="$script"
|
||||
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting: $script" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
# Use bash -c to create a clean subshell
|
||||
bash -c "source '$script'" </dev/null >>"$OMARCHY_INSTALL_LOG_FILE" 2>&1
|
||||
|
||||
local exit_code=$?
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Completed: $script" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
unset CURRENT_SCRIPT
|
||||
else
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Failed: $script (exit code: $exit_code)" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
fi
|
||||
|
||||
return $exit_code
|
||||
}
|
||||
8
install/helpers/logo.sh
Normal file
8
install/helpers/logo.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
export LOGO_PATH="$OMARCHY_PATH/logo.txt"
|
||||
export LOGO_WIDTH=$(awk '{ if (length > max) max = length } END { print max+0 }' "$LOGO_PATH" 2>/dev/null || echo 0)
|
||||
export LOGO_HEIGHT=$(wc -l <"$LOGO_PATH" 2>/dev/null || echo 0)
|
||||
|
||||
clear_logo() {
|
||||
printf "\033[H\033[2J" # Clear screen and move cursor to top-left
|
||||
gum style --foreground 2 --padding "1 0 0 $PADDING_LEFT" "$(<"$LOGO_PATH")"
|
||||
}
|
||||
Reference in New Issue
Block a user