From 30a5c7144c0b1b574de1873e7dd922d9c12b3558 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 15 Aug 2024 12:26:08 -0300 Subject: [PATCH] Ensure DEBIAN_FRONTEND=noninteractive is used with apt install Also fix some inconsistencies in the scripts. --- home/.chezmoihooks/ensure-pre-requisites.sh | 2 +- ..._onchange_before_20-upgrade-ca-certificates.sh.tmpl | 10 ++++++---- home/dot_local/bin/executable_full-upgrade.tmpl | 4 ++-- root/.chezmoihooks/ensure-pre-requisites.sh | 4 ++-- .../run_after_10-install-apt-packages.sh.tmpl | 9 +++++---- .../run_before_30-uninstall-apt-packages.sh.tmpl | 2 +- scripts/install_dotfiles.sh | 6 +++--- scripts/test.sh | 6 +++--- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/home/.chezmoihooks/ensure-pre-requisites.sh b/home/.chezmoihooks/ensure-pre-requisites.sh index 9217fada..493458cf 100755 --- a/home/.chezmoihooks/ensure-pre-requisites.sh +++ b/home/.chezmoihooks/ensure-pre-requisites.sh @@ -29,4 +29,4 @@ source "${CHEZMOI_SOURCE_DIR?}/.chezmoitemplates/scripts-library" log_task "Installing missing packages with APT: ${missing_packages[*]}" c sudo apt update -c sudo apt install --yes --no-install-recommends "${missing_packages[@]}" +c sudo DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends "${missing_packages[@]}" diff --git a/home/.chezmoiscripts/run_onchange_before_20-upgrade-ca-certificates.sh.tmpl b/home/.chezmoiscripts/run_onchange_before_20-upgrade-ca-certificates.sh.tmpl index e40ebfd8..aa694baa 100644 --- a/home/.chezmoiscripts/run_onchange_before_20-upgrade-ca-certificates.sh.tmpl +++ b/home/.chezmoiscripts/run_onchange_before_20-upgrade-ca-certificates.sh.tmpl @@ -10,13 +10,15 @@ true || source ../.chezmoitemplates/scripts-library log_task "Upgrading ca-certificates" -# Ignore apt update error if it is due to expired certificate (because chances are that -# the next command will fix it. -if output="$(c sudo apt update --yes)" || [[ "${output}" == *"The certificate chain uses expired certificate."* ]]; then +# Ignore apt update error if it is due to expired certificate (because chances +# are that the next command will fix it). +# shellcheck disable=SC2310 +if output="$(c sudo apt update)" || [[ "${output}" == *"The certificate chain uses expired certificate."* ]]; then echo "${output}" true else echo "${output}" exit 1 fi -c sudo apt install --yes --no-install-recommends ca-certificates + +c sudo DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends ca-certificates diff --git a/home/dot_local/bin/executable_full-upgrade.tmpl b/home/dot_local/bin/executable_full-upgrade.tmpl index 8a0b91e1..66caf3b3 100644 --- a/home/dot_local/bin/executable_full-upgrade.tmpl +++ b/home/dot_local/bin/executable_full-upgrade.tmpl @@ -114,8 +114,8 @@ fi if apt --version &>/dev/null; then log_task "Updating apt packages" - c sudo DEBIAN_FRONTEND=noninteractive apt update --yes - c sudo DEBIAN_FRONTEND=noninteractive apt upgrade --yes + c sudo apt update + c sudo DEBIAN_FRONTEND=noninteractive apt full-upgrade --yes c sudo DEBIAN_FRONTEND=noninteractive apt autoremove --yes fi diff --git a/root/.chezmoihooks/ensure-pre-requisites.sh b/root/.chezmoihooks/ensure-pre-requisites.sh index e5caff6c..1f235094 100755 --- a/root/.chezmoihooks/ensure-pre-requisites.sh +++ b/root/.chezmoihooks/ensure-pre-requisites.sh @@ -24,7 +24,7 @@ fi # shellcheck source=../.chezmoitemplates/scripts-library source "${CHEZMOI_SOURCE_DIR?}/.chezmoitemplates/scripts-library" -log_task "Installing missing packages with APT: ${missing_packages[*]}" +log_task "Installing missing pre-requisite packages with APT: ${missing_packages[*]}" c apt update -c apt install --yes --no-install-recommends "${missing_packages[@]}" +c DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends "${missing_packages[@]}" diff --git a/root/.chezmoiscripts/run_after_10-install-apt-packages.sh.tmpl b/root/.chezmoiscripts/run_after_10-install-apt-packages.sh.tmpl index c5d0459e..a99ddc2d 100644 --- a/root/.chezmoiscripts/run_after_10-install-apt-packages.sh.tmpl +++ b/root/.chezmoiscripts/run_after_10-install-apt-packages.sh.tmpl @@ -69,14 +69,15 @@ done if [[ ${#missing_packages[@]} -gt 0 ]]; then log_task "Installing missing packages with APT: ${missing_packages[*]}" - c apt update --yes + c apt update + extra_args=() if [[ "${DOTFILES_TEST:-}" == true ]]; then log_manual_action "Not installing recommended packages to speed up test mode" - recommends_arg="--no-install-recommends" + extra_args+=("--no-install-recommends") else - recommends_arg="--install-recommends" + extra_args+=("--install-recommends") fi - c apt install --yes "${recommends_arg}" "${missing_packages[@]}" + c DEBIAN_FRONTEND=noninteractive apt install --yes "${extra_args[@]}" "${missing_packages[@]}" fi diff --git a/root/.chezmoiscripts/run_before_30-uninstall-apt-packages.sh.tmpl b/root/.chezmoiscripts/run_before_30-uninstall-apt-packages.sh.tmpl index a5872860..8f28b712 100644 --- a/root/.chezmoiscripts/run_before_30-uninstall-apt-packages.sh.tmpl +++ b/root/.chezmoiscripts/run_before_30-uninstall-apt-packages.sh.tmpl @@ -22,6 +22,6 @@ for package in "${unwanted_packages[@]}"; do # shellcheck disable=SC2310 if is_apt_package_installed "${package}"; then log_task "Removing unwanted package '${package}' installed with APT" - c apt remove --yes --auto-remove "${package}" + c DEBIAN_FRONTEND=noninteractive apt remove --yes --auto-remove "${package}" fi done diff --git a/scripts/install_dotfiles.sh b/scripts/install_dotfiles.sh index 0dc43555..9ced52ba 100755 --- a/scripts/install_dotfiles.sh +++ b/scripts/install_dotfiles.sh @@ -76,9 +76,9 @@ DOTFILES_BRANCH=${DOTFILES_BRANCH:-"master"} DOTFILES_DIR="${HOME}/.dotfiles" if ! command -v git >/dev/null 2>&1; then - log_task "Installing git" - sudo apt update --yes - sudo apt install --yes --no-install-recommends git + log_task "Installing git with APT" + sudo apt update + sudo DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends git fi if [ -d "${DOTFILES_DIR}" ]; then diff --git a/scripts/test.sh b/scripts/test.sh index 17a575d3..1ed5ad8a 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -179,7 +179,7 @@ for variant in "${variants[@]}"; do export IS_WSL=true # Exercises install-pre-requisites.sh -sudo apt remove --yes zsh curl git gpg +sudo DEBIAN_FRONTEND=noninteractive apt remove --yes --auto-remove zsh curl git gpg cat <<'EOM' | sudo tee /usr/local/bin/wslpath #!/bin/bash @@ -205,8 +205,8 @@ EOF run_test "${os}" "$( # shellcheck disable=SC2312 cat <<'EOF' -sudo apt update --yes -sudo apt install --yes --no-install-recommends gnome-shell +sudo apt update +sudo DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends gnome-shell EOF )" ;;