From b34f53629d7d3885c948cf7eb4a055ff54eee707 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Wed, 20 May 2026 21:36:31 -0400 Subject: [PATCH] Validate --local-source paths before any sudo work Also includes the build-iso.sh cleanup that I prepared earlier but forgot to stage (replacing the inline ugly $(...) conditional pipe with a normal if/then-fi block). --- bin/omarchy-iso-make | 15 ++++++++++----- builder/build-iso.sh | 16 +++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/bin/omarchy-iso-make b/bin/omarchy-iso-make index 4189ce9..c91cfcd 100755 --- a/bin/omarchy-iso-make +++ b/bin/omarchy-iso-make @@ -49,6 +49,14 @@ while [[ $# -gt 0 ]]; do esac done +# Validate local-source paths up front (before any sudo / network work). +if [[ -n $LOCAL_INSTALLER_PATH ]]; then + [[ -d $LOCAL_INSTALLER_PATH ]] || { echo "Error: installer checkout not found at $LOCAL_INSTALLER_PATH" >&2; exit 1; } + [[ -d $LOCAL_PKGS_PATH ]] || { echo "Error: pkgs checkout not found at $LOCAL_PKGS_PATH" >&2; exit 1; } + LOCAL_INSTALLER_PATH=$(realpath "$LOCAL_INSTALLER_PATH") + LOCAL_PKGS_PATH=$(realpath "$LOCAL_PKGS_PATH") +fi + # Clear out old packages sudo rm -rf /var/cache/pacman/pkg/* @@ -80,12 +88,9 @@ DOCKER_ARGS=( -v "$BUILD_ROOT/configs:/configs:ro" ) -# Mount the local checkouts when --local-source was passed. +# Mount the local checkouts when --local-source was passed (paths already +# validated/resolved above). if [[ -n $LOCAL_INSTALLER_PATH ]]; then - [[ -d $LOCAL_INSTALLER_PATH ]] || { echo "Error: installer checkout not found at $LOCAL_INSTALLER_PATH" >&2; exit 1; } - [[ -d $LOCAL_PKGS_PATH ]] || { echo "Error: pkgs checkout not found at $LOCAL_PKGS_PATH" >&2; exit 1; } - LOCAL_INSTALLER_PATH=$(realpath "$LOCAL_INSTALLER_PATH") - LOCAL_PKGS_PATH=$(realpath "$LOCAL_PKGS_PATH") DOCKER_ARGS+=( -v "$LOCAL_INSTALLER_PATH:/omarchy-installer:ro" -v "$LOCAL_PKGS_PATH:/omarchy-pkgs:ro" diff --git a/builder/build-iso.sh b/builder/build-iso.sh index 826447b..17c9b40 100755 --- a/builder/build-iso.sh +++ b/builder/build-iso.sh @@ -72,20 +72,26 @@ else base_pkg_lists=(/tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-base.packages /tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-other.packages) fi +# Collect every package we want available in the offline mirror. declare -a all_packages mapfile -t all_packages < <( { cat "$build_cache_dir/packages.x86_64" grep -hv '^#\|^$' "${base_pkg_lists[@]}" grep -hv '^#\|^$' /builder/archinstall.packages - # Always include the omarchy meta-package set so the target install can - # find omarchy-installer in the offline mirror. + # Always include the omarchy meta-packages so the target install can find + # omarchy-installer in the offline mirror. printf 'omarchy\nomarchy-settings\nomarchy-installer\nomarchy-limine\n' - } | - $([[ -n ${LOCAL_OMARCHY_BUILD:-} ]] && echo "grep -vE ^(omarchy|omarchy-settings|omarchy-installer|omarchy-limine)$" || echo cat) | - sort -u + } | sort -u ) +# With --local-source we already built the four omarchy* packages directly +# into the mirror; strip them from the pacman -Syw list so it doesn't try to +# fetch the published versions on top. +if [[ -n ${LOCAL_OMARCHY_BUILD:-} ]]; then + all_packages=($(printf '%s\n' "${all_packages[@]}" | grep -vE '^(omarchy|omarchy-settings|omarchy-installer|omarchy-limine)$')) +fi + mkdir -p /tmp/offlinedb pacman --config /configs/pacman-online-${OMARCHY_MIRROR}.conf --noconfirm -Syw \ "${all_packages[@]}" --cachedir "$offline_mirror_dir/" --dbpath /tmp/offlinedb --needed