From d9093f3b0994662848e87f1d16beb83d70b3f514 Mon Sep 17 00:00:00 2001 From: edgarriba Date: Tue, 19 May 2026 15:20:22 +0200 Subject: [PATCH] fix(install): auto-install missing unzip/curl via host package manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The install script bailed on fresh Ubuntu/Debian boxes with 'Missing required dependencies: unzip' — verified by running 'curl ... install.sh | sh' inside a stock ubuntu:24.04 container. Now check_deps() probes for apt-get / dnf / yum / apk / pacman and attempts an unattended install of the missing package (with sudo if not root). Falls back to the original explicit-install error message if no recognized package manager is found or sudo is unavailable — so we never silently fail, and the error includes the right command for each distro family. Tested end-to-end in a fresh ubuntu:24.04 arm64 container: before fix: ERROR Missing required dependencies: unzip after fix : INFO Installing unzip via apt-get... → bubbaloop 0.0.14 Co-Authored-By: Claude Sonnet 4.6 --- scripts/install.sh | 62 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index b2882d4b..f134b061 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -65,7 +65,44 @@ detect_os() { esac } -# Check for required dependencies +# Try to install a missing OS package via the host's package manager. +# Returns 0 on success, 1 if no recognized PM is available or sudo is missing. +try_install_pkg() { + local pkg="$1" + local sudo_cmd="" + + if [ "$(id -u)" -ne 0 ]; then + if command -v sudo &> /dev/null; then + sudo_cmd="sudo" + else + return 1 + fi + fi + + if command -v apt-get &> /dev/null; then + info "Installing $pkg via apt-get..." + DEBIAN_FRONTEND=noninteractive $sudo_cmd apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive $sudo_cmd apt-get install -y -qq "$pkg" + elif command -v dnf &> /dev/null; then + info "Installing $pkg via dnf..." + $sudo_cmd dnf install -y "$pkg" + elif command -v yum &> /dev/null; then + info "Installing $pkg via yum..." + $sudo_cmd yum install -y "$pkg" + elif command -v apk &> /dev/null; then + info "Installing $pkg via apk..." + $sudo_cmd apk add --no-cache "$pkg" + elif command -v pacman &> /dev/null; then + info "Installing $pkg via pacman..." + $sudo_cmd pacman -Sy --noconfirm "$pkg" + else + return 1 + fi +} + +# Check for required dependencies; auto-install missing ones via the host's +# package manager when possible. Bails with a clear manual-install hint +# only if auto-install fails (no PM, no sudo, or the install itself errors). check_deps() { local missing=() @@ -77,8 +114,27 @@ check_deps() { missing+=("unzip") fi - if [ ${#missing[@]} -gt 0 ]; then - error "Missing required dependencies: ${missing[*]}" + if [ ${#missing[@]} -eq 0 ]; then + return 0 + fi + + info "Missing dependencies: ${missing[*]} — attempting to install..." + + local still_missing=() + for pkg in "${missing[@]}"; do + if try_install_pkg "$pkg" && command -v "$pkg" &> /dev/null; then + info "Installed $pkg" + else + still_missing+=("$pkg") + fi + done + + if [ ${#still_missing[@]} -gt 0 ]; then + error "Could not auto-install: ${still_missing[*]}. Install manually and re-run: + Debian/Ubuntu: sudo apt-get install -y ${still_missing[*]} + Fedora/RHEL: sudo dnf install -y ${still_missing[*]} + Alpine: sudo apk add ${still_missing[*]} + Arch: sudo pacman -S ${still_missing[*]}" fi }