installer: scaffold package manager abstraction and support matrix

This commit is contained in:
Abhimanyu Saharan
2026-02-13 09:40:54 +00:00
parent 6e8069fc2a
commit 645e620ae9
3 changed files with 93 additions and 11 deletions

View File

@@ -58,6 +58,8 @@ The installer is interactive and will:
- Generate and configure environment files. - Generate and configure environment files.
- Bootstrap and start the selected deployment mode. - Bootstrap and start the selected deployment mode.
Installer support matrix: [`docs/installer-support.md`](./docs/installer-support.md)
### Option B: Manual setup ### Option B: Manual setup
### Prerequisites ### Prerequisites

25
docs/installer-support.md Normal file
View File

@@ -0,0 +1,25 @@
# Installer platform support
This document defines current support status for `./install.sh`.
## Support states
- **Stable**: full tested path in CI and expected to work end-to-end.
- **Scaffolded**: distro is detected and actionable install guidance is provided, but full automatic package installation is not implemented yet.
- **Unsupported**: distro/package manager is not detected by installer.
## Current matrix
| Distro family | Package manager | State | Notes |
|---|---|---|---|
| Debian / Ubuntu | `apt` | **Stable** | Full automatic dependency install path. |
| Fedora / RHEL / CentOS | `dnf` / `yum` | **Scaffolded** | Detection + actionable commands present; auto-install path is TODO. |
| openSUSE | `zypper` | **Scaffolded** | Detection + actionable commands present; auto-install path is TODO. |
| Arch Linux | `pacman` | **Scaffolded** | Detection + actionable commands present; auto-install path is TODO. |
| Other Linux distros | unknown | **Unsupported** | Installer exits with package-manager guidance requirement. |
## Guard rails
- Debian/Ubuntu behavior must remain stable for every portability PR.
- New distro support should be added behind explicit package-manager adapters and tests.
- If a distro is scaffolded but not fully automated, installer should fail fast with actionable manual commands (not generic errors).

View File

@@ -7,7 +7,8 @@ REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
LOG_DIR="$REPO_ROOT/.install-logs" LOG_DIR="$REPO_ROOT/.install-logs"
LINUX_DISTRO="" LINUX_DISTRO=""
APT_UPDATED=0 PKG_MANAGER=""
PKG_UPDATED=0
DOCKER_USE_SUDO=0 DOCKER_USE_SUDO=0
INTERACTIVE=0 INTERACTIVE=0
@@ -145,12 +146,40 @@ as_root() {
fi fi
} }
install_command_hint() {
local manager="$1"
shift
local -a packages
packages=("$@")
case "$manager" in
apt)
printf 'sudo apt-get update && sudo apt-get install -y %s' "${packages[*]}"
;;
dnf)
printf 'sudo dnf install -y %s' "${packages[*]}"
;;
yum)
printf 'sudo yum install -y %s' "${packages[*]}"
;;
zypper)
printf 'sudo zypper install -y %s' "${packages[*]}"
;;
pacman)
printf 'sudo pacman -Sy --noconfirm %s' "${packages[*]}"
;;
*)
printf 'install packages manually: %s' "${packages[*]}"
;;
esac
}
detect_platform() { detect_platform() {
local uname_s local uname_s
local id_like local id_like
uname_s="$(uname -s)" uname_s="$(uname -s)"
if [[ "$uname_s" != "Linux" ]]; then if [[ "$uname_s" != "Linux" ]]; then
die "Unsupported platform: $uname_s. This installer currently supports Ubuntu/Debian only." die "Unsupported platform: $uname_s. Linux is required."
fi fi
if [[ ! -r /etc/os-release ]]; then if [[ ! -r /etc/os-release ]]; then
@@ -162,13 +191,25 @@ detect_platform() {
LINUX_DISTRO="${ID:-unknown}" LINUX_DISTRO="${ID:-unknown}"
id_like="${ID_LIKE:-}" id_like="${ID_LIKE:-}"
if [[ "$LINUX_DISTRO" != "ubuntu" && "$LINUX_DISTRO" != "debian" && ! "$id_like" =~ (^|[[:space:]])debian($|[[:space:]]) ]]; then if command_exists apt-get; then
die "Unsupported Linux distribution: $LINUX_DISTRO. This installer currently supports Ubuntu/Debian only." PKG_MANAGER="apt"
elif command_exists dnf; then
PKG_MANAGER="dnf"
elif command_exists yum; then
PKG_MANAGER="yum"
elif command_exists zypper; then
PKG_MANAGER="zypper"
elif command_exists pacman; then
PKG_MANAGER="pacman"
else
die "Unsupported Linux distribution: $LINUX_DISTRO. No supported package manager detected (expected apt/dnf/yum/zypper/pacman)."
fi fi
if ! command_exists apt-get; then if [[ "$PKG_MANAGER" != "apt" ]]; then
die "apt-get is required on this system." warn "Detected distro '$LINUX_DISTRO' with package manager '$PKG_MANAGER'. This installer currently provides Debian/Ubuntu as stable path; other distros are scaffolded with actionable guidance."
fi fi
info "Detected Linux distro: $LINUX_DISTRO (package manager: $PKG_MANAGER)"
} }
install_packages() { install_packages() {
@@ -179,11 +220,21 @@ install_packages() {
return 0 return 0
fi fi
if [[ "$APT_UPDATED" -eq 0 ]]; then case "$PKG_MANAGER" in
as_root apt-get update apt)
APT_UPDATED=1 if [[ "$PKG_UPDATED" -eq 0 ]]; then
fi as_root apt-get update
as_root apt-get install -y "${packages[@]}" PKG_UPDATED=1
fi
as_root apt-get install -y "${packages[@]}"
;;
dnf|yum|zypper|pacman)
die "Automatic package install is not implemented yet for '$PKG_MANAGER'. Run: $(install_command_hint "$PKG_MANAGER" "${packages[@]}")"
;;
*)
die "Unknown package manager '$PKG_MANAGER'. Install manually: ${packages[*]}"
;;
esac
} }
prompt_with_default() { prompt_with_default() {
@@ -383,6 +434,10 @@ ensure_nodejs() {
die "Cannot continue without Node.js >= 20." die "Cannot continue without Node.js >= 20."
fi fi
if [[ "$PKG_MANAGER" != "apt" ]]; then
die "Node.js auto-install is currently implemented for apt-based distros only. Install Node.js >= 20 manually, then rerun installer. Suggested command: $(install_command_hint "$PKG_MANAGER" nodejs npm)"
fi
install_packages ca-certificates curl gnupg install_packages ca-certificates curl gnupg
curl -fsSL https://deb.nodesource.com/setup_20.x | as_root bash - curl -fsSL https://deb.nodesource.com/setup_20.x | as_root bash -
install_packages nodejs install_packages nodejs