installer: scaffold package manager abstraction and support matrix
This commit is contained in:
@@ -58,6 +58,8 @@ The installer is interactive and will:
|
||||
- Generate and configure environment files.
|
||||
- Bootstrap and start the selected deployment mode.
|
||||
|
||||
Installer support matrix: [`docs/installer-support.md`](./docs/installer-support.md)
|
||||
|
||||
### Option B: Manual setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
25
docs/installer-support.md
Normal file
25
docs/installer-support.md
Normal 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).
|
||||
77
install.sh
77
install.sh
@@ -7,7 +7,8 @@ REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
LOG_DIR="$REPO_ROOT/.install-logs"
|
||||
|
||||
LINUX_DISTRO=""
|
||||
APT_UPDATED=0
|
||||
PKG_MANAGER=""
|
||||
PKG_UPDATED=0
|
||||
DOCKER_USE_SUDO=0
|
||||
INTERACTIVE=0
|
||||
|
||||
@@ -145,12 +146,40 @@ as_root() {
|
||||
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() {
|
||||
local uname_s
|
||||
local id_like
|
||||
uname_s="$(uname -s)"
|
||||
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
|
||||
|
||||
if [[ ! -r /etc/os-release ]]; then
|
||||
@@ -162,13 +191,25 @@ detect_platform() {
|
||||
LINUX_DISTRO="${ID:-unknown}"
|
||||
id_like="${ID_LIKE:-}"
|
||||
|
||||
if [[ "$LINUX_DISTRO" != "ubuntu" && "$LINUX_DISTRO" != "debian" && ! "$id_like" =~ (^|[[:space:]])debian($|[[:space:]]) ]]; then
|
||||
die "Unsupported Linux distribution: $LINUX_DISTRO. This installer currently supports Ubuntu/Debian only."
|
||||
if command_exists apt-get; then
|
||||
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
|
||||
|
||||
if ! command_exists apt-get; then
|
||||
die "apt-get is required on this system."
|
||||
if [[ "$PKG_MANAGER" != "apt" ]]; then
|
||||
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
|
||||
|
||||
info "Detected Linux distro: $LINUX_DISTRO (package manager: $PKG_MANAGER)"
|
||||
}
|
||||
|
||||
install_packages() {
|
||||
@@ -179,11 +220,21 @@ install_packages() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ "$APT_UPDATED" -eq 0 ]]; then
|
||||
as_root apt-get update
|
||||
APT_UPDATED=1
|
||||
fi
|
||||
as_root apt-get install -y "${packages[@]}"
|
||||
case "$PKG_MANAGER" in
|
||||
apt)
|
||||
if [[ "$PKG_UPDATED" -eq 0 ]]; then
|
||||
as_root apt-get update
|
||||
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() {
|
||||
@@ -383,6 +434,10 @@ ensure_nodejs() {
|
||||
die "Cannot continue without Node.js >= 20."
|
||||
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
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | as_root bash -
|
||||
install_packages nodejs
|
||||
|
||||
Reference in New Issue
Block a user