Fix Alpine install: enable community repo, make extras best-effort
- Enable Alpine community repo (vim/fzf live there, commented out by default). - Split essential vs extra packages; extras (htop/neofetch/fzf) install best-effort so a missing neofetch (removed from Alpine 3.20+) does not abort. - Make run() return its command's exit status explicitly so 'if run ...' guards work under 'set -e'.
This commit is contained in:
29
install.sh
29
install.sh
@@ -35,11 +35,14 @@ die() { printf '\033[0;31m✘\033[0m %s\n' "$1" >&2; exit 1; }
|
||||
|
||||
run() {
|
||||
# Print the command, then run it (unless --dry-run).
|
||||
# We capture the exit status explicitly so that a failing command does NOT
|
||||
# trip the caller's 'set -e' inside 'if run ... ; then' constructs.
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
printf ' $ %s\n' "$*"
|
||||
else
|
||||
"$@"
|
||||
return 0
|
||||
fi
|
||||
"$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
usage() {
|
||||
@@ -102,14 +105,26 @@ install_packages() {
|
||||
EXTRA="htop neofetch fzf"
|
||||
|
||||
if [ "$PKG" = "apk" ]; then
|
||||
# On Alpine, vim/fzf live in the 'community' repo, which is commented
|
||||
# out by default in /etc/apk/repositories. Enable it (idempotent).
|
||||
info "Ensuring Alpine community repository is enabled"
|
||||
run sed -i -E "s|^#(.*/community)$|\1|" /etc/apk/repositories
|
||||
run $MGR_UPDATE
|
||||
run $MGR_ADD $ESSENTIAL $EXTRA
|
||||
else
|
||||
run $MGR_UPDATE
|
||||
run $MGR_ADD $ESSENTIAL
|
||||
# Newer Debian dropped neofetch from the repos; don't fail the whole run on it.
|
||||
info "Installing extra packages (best-effort)"
|
||||
run $MGR_ADD $EXTRA || warn "Some extra packages failed to install (non-fatal)."
|
||||
fi
|
||||
|
||||
info "Installing essential packages"
|
||||
run $MGR_ADD $ESSENTIAL
|
||||
|
||||
# Extras (htop, neofetch, fzf) are best-effort: a missing one must not
|
||||
# abort the whole bootstrap (e.g. neofetch was dropped from Alpine 3.20+,
|
||||
# and Debian/Ubuntu increasingly ship it as 'neofetch' but sometimes omit it).
|
||||
info "Installing extra packages (best-effort)"
|
||||
if run $MGR_ADD $EXTRA; then
|
||||
ok "Extra packages installed"
|
||||
else
|
||||
warn "Some extra packages failed to install (non-fatal)."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user