fix(install): gate get.docker.com by $ID instead of trapping all failures

Deciding the installer up front — get.docker.com for the IDs it recognizes,
Docker's repo directly for unrecognized derivatives — avoids treating a
transient get.docker.com failure (network, apt lock, EOL sleep) on a supported
distro as an "unsupported distro" and silently routing it into the repo path.

Recognized IDs now surface the real failure via die instead of masking it;
unrecognized derivatives (Nobara, Mint, …) skip the doomed call and its
"Unsupported distribution" output entirely rather than running it to fail.

Addresses review feedback on #829.
This commit is contained in:
Patrick Buckley
2026-07-11 18:40:34 -07:00
parent 4d423913b1
commit f4e54ce814
+22 -5
View File
@@ -186,15 +186,32 @@ install_docker_ce_repo() {
esac esac
} }
# The distro IDs get.docker.com installs directly: it matches $ID against this
# exact set (ignoring ID_LIKE) and aborts on anything else. Mirrors the dispatch
# in get.docker.com, including its fedora-asahi-remix -> fedora alias.
get_docker_com_supports() {
case "$1" in
ubuntu|debian|raspbian|centos|fedora|rhel|rocky|sles|fedora-asahi-remix) return 0 ;;
*) return 1 ;;
esac
}
install_docker() { install_docker() {
case "$PKG" in case "$PKG" in
apt|dnf|yum) apt|dnf|yum)
info "Installing Docker via the official get.docker.com script" # Decide up front which installer applies, rather than treating every
# get.docker.com aborts on distros it doesn't recognize by $ID; when it # get.docker.com failure as "unsupported distro": for an ID it knows,
# does, add Docker's repo for the family we detected instead. # let it run and surface any real failure (network, apt lock, EOL) via
if ! curl -fsSL https://get.docker.com | $SUDO sh; then # die instead of masking it with the repo path. Only unrecognized
warn "get.docker.com doesn't recognize '${OS_ID:-this distro}' — using Docker's repository directly." # derivatives (Nobara, Mint, …) — which it would just abort on — skip
# straight to adding Docker's repo ourselves.
if [ -n "$OS_ID" ] && ! get_docker_com_supports "$OS_ID"; then
info "get.docker.com doesn't support '$OS_ID' — using Docker's official repository directly."
install_docker_ce_repo install_docker_ce_repo
else
info "Installing Docker via the official get.docker.com script"
curl -fsSL https://get.docker.com | $SUDO sh \
|| die "get.docker.com failed to install Docker (see the output above). Fix the issue and re-run — the script resumes."
fi fi
;; ;;
pacman) pacman)