From a5ef9f7662144d3add1bfd5f575b413888273069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Wed, 12 Aug 2026 17:34:34 +0000 Subject: [PATCH] report what a section actually installed, not what it was asked for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The summary claimed credit for everything in a section's list, including the packages it had just decided to leave alone — so a run that installed nothing still ended with "Command-line tools: lazydocker lazygit starship fastfetch". The announce above it said "nothing, all present" in the same breath. pkg_install and tools_install now record LAST_INSTALLED and LAST_KEPT, and summarise_last turns those into one honest line: Core packages installed: btop tmux (17 already present) Command-line tools: already present, nothing installed Verified all three shapes — everything present, nothing present, and mixed. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/setup/machine-setup/lib/packages.sh | 23 ++++++++++++++++++++ scripts/setup/machine-setup/lib/tools.sh | 3 +++ scripts/setup/machine-setup/machine-setup.sh | 5 ++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/scripts/setup/machine-setup/lib/packages.sh b/scripts/setup/machine-setup/lib/packages.sh index 09b3d2b2..c5244882 100644 --- a/scripts/setup/machine-setup/lib/packages.sh +++ b/scripts/setup/machine-setup/lib/packages.sh @@ -29,6 +29,13 @@ [[ -n "${MACHINE_SETUP_PACKAGES_LOADED:-}" ]] && return 0 MACHINE_SETUP_PACKAGES_LOADED=1 +# What the last pkg_install/tools_install actually put on the machine, as opposed +# to what it was asked for. Read by the caller to write an honest summary line: +# without it every section reports its whole list as installed, including the +# packages it deliberately left alone. +LAST_INSTALLED=() +LAST_KEPT=() + # ----------------------------------------------------------------------------- # The sections # ----------------------------------------------------------------------------- @@ -152,6 +159,9 @@ pkg_install() { if pkg_is_installed "$pkg"; then present+=("$pkg"); else missing+=("$pkg"); fi done + LAST_INSTALLED=("${missing[@]}") + LAST_KEPT=("${present[@]}") + info "$label — installs what is missing, keeps what you already have" ((${#present[@]})) && echo " already here: ${present[*]}" @@ -163,3 +173,16 @@ pkg_install() { echo " to install: ${missing[*]}" pkg_install_now "${missing[@]}" } + +# One summary line describing what a section actually did, from LAST_INSTALLED +# and LAST_KEPT. Call straight after pkg_install or tools_install. +summarise_last() { + local label="$1" + if ((${#LAST_INSTALLED[@]} == 0)); then + SUMMARY+=("$label: already present, nothing installed") + elif ((${#LAST_KEPT[@]} == 0)); then + SUMMARY+=("$label installed: ${LAST_INSTALLED[*]}") + else + SUMMARY+=("$label installed: ${LAST_INSTALLED[*]} (${#LAST_KEPT[@]} already present)") + fi +} diff --git a/scripts/setup/machine-setup/lib/tools.sh b/scripts/setup/machine-setup/lib/tools.sh index f13874d6..c49df44d 100644 --- a/scripts/setup/machine-setup/lib/tools.sh +++ b/scripts/setup/machine-setup/lib/tools.sh @@ -113,6 +113,9 @@ tools_install() { if tool_is_installed "$tool"; then present+=("$tool"); else missing+=("$tool"); fi done + LAST_INSTALLED=("${missing[@]}") + LAST_KEPT=("${present[@]}") + info "$label — installs what is missing, keeps what you already have" ((${#present[@]})) && echo " already here: ${present[*]}" diff --git a/scripts/setup/machine-setup/machine-setup.sh b/scripts/setup/machine-setup/machine-setup.sh index 23142e1e..7540532e 100755 --- a/scripts/setup/machine-setup/machine-setup.sh +++ b/scripts/setup/machine-setup/machine-setup.sh @@ -91,8 +91,8 @@ if ! skip; then # shellcheck disable=SC2046 # word splitting is how the list is passed pkg_install "Core packages" $(pkgs_core) + summarise_last "Core packages" ok "System updated and core packages in place" - SUMMARY+=("System packages updated, core packages installed") step_ok fi @@ -109,8 +109,7 @@ step "Command-line tools" if ! skip; then # shellcheck disable=SC2046 # word splitting is how the list is passed tools_install "Command-line tools" $(tools_default) - - SUMMARY+=("Command-line tools: $(tools_default)") + summarise_last "Command-line tools" step_ok fi