mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-10-11 00:00:13 +08:00
[actions] never let an apt install wait on a prompt
Moving WSL package installs out of `setup-wsl`'s `additional-packages` lost its non-interactive setup: on Ubuntu 18.04, upgrading `libssl1.1` asks whether to restart services, and the job waited on that dialog until it was cancelled. Set `DEBIAN_FRONTEND=noninteractive`, keep existing config files without asking, and give apt no stdin.
This commit is contained in:
@@ -20,11 +20,14 @@ if [ "$(id -u)" != '0' ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
apt_get() {
|
apt_get() {
|
||||||
|
# never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
|
||||||
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get \
|
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get \
|
||||||
-o Acquire::Retries=5 \
|
-o Acquire::Retries=5 \
|
||||||
-o Acquire::http::Timeout=30 \
|
-o Acquire::http::Timeout=30 \
|
||||||
-o Acquire::https::Timeout=30 \
|
-o Acquire::https::Timeout=30 \
|
||||||
"$@"
|
-o Dpkg::Options::=--force-confdef \
|
||||||
|
-o Dpkg::Options::=--force-confold \
|
||||||
|
"$@" < /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
ATTEMPT=1
|
ATTEMPT=1
|
||||||
|
|||||||
@@ -157,11 +157,13 @@ jobs:
|
|||||||
name: 'Install packages with retries'
|
name: 'Install packages with retries'
|
||||||
shell: 'wsl-bash {0}'
|
shell: 'wsl-bash {0}'
|
||||||
run: |
|
run: |
|
||||||
|
# never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
attempt=1
|
attempt=1
|
||||||
delay=15
|
delay=15
|
||||||
while true; do
|
while true; do
|
||||||
apt-get -o Acquire::Retries=5 update || true
|
apt-get -o Acquire::Retries=5 update < /dev/null || true
|
||||||
if apt-get -o Acquire::Retries=5 install --yes bash git curl ca-certificates wget; then
|
if apt-get -o Acquire::Retries=5 -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install --yes bash git curl ca-certificates wget < /dev/null; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
if [ "${attempt}" -ge 8 ]; then
|
if [ "${attempt}" -ge 8 ]; then
|
||||||
@@ -227,14 +229,17 @@ jobs:
|
|||||||
}
|
}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
# never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
packages=(bash git curl ca-certificates wget)
|
packages=(bash git curl ca-certificates wget)
|
||||||
retry apt-get update || true
|
install_options=(-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install --yes)
|
||||||
if ! retry apt-get install --yes "${packages[@]}"; then
|
retry apt-get update < /dev/null || true
|
||||||
|
if ! retry apt-get "${install_options[@]}" "${packages[@]}" < /dev/null; then
|
||||||
# a security index can outlive the pool objects it advertises, which
|
# a security index can outlive the pool objects it advertises, which
|
||||||
# no retry resolves; main is complete once a release is archived
|
# no retry resolves; main is complete once a release is archived
|
||||||
sed -i '/debian-security/d' /etc/apt/sources.list
|
sed -i '/debian-security/d' /etc/apt/sources.list
|
||||||
retry apt-get update || true
|
retry apt-get update < /dev/null || true
|
||||||
retry apt-get install --yes "${packages[@]}"
|
retry apt-get "${install_options[@]}" "${packages[@]}" < /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Retrieve nvm on WSL
|
- name: Retrieve nvm on WSL
|
||||||
|
|||||||
Reference in New Issue
Block a user