Skip to content

Commit

Permalink
Ensure DEBIAN_FRONTEND=noninteractive is used with apt install
Browse files Browse the repository at this point in the history
Also fix some inconsistencies in the scripts.
  • Loading branch information
felipecrs committed Aug 15, 2024
1 parent 040b074 commit 30a5c71
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion home/.chezmoihooks/ensure-pre-requisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions home/dot_local/bin/executable_full-upgrade.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions root/.chezmoihooks/ensure-pre-requisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions scripts/install_dotfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)"
;;
Expand Down

0 comments on commit 30a5c71

Please sign in to comment.