feat: initial commit — void-installer multi-profile (stable-cinnamon + mainline-niri)
This commit is contained in:
53
installer/lib/profiles.sh
Normal file
53
installer/lib/profiles.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# Profile loading. PROFILE env var (default: stable-cinnamon) selects which
|
||||
# config/profiles/<name>/profile.conf is sourced and which packages.list is
|
||||
# used. Every variable defined in profile.conf overrides install.conf.
|
||||
|
||||
PROFILES_DIR="${PROFILES_DIR:-${PROJECT_DIR:-/usr/local/share/installer}/profiles}"
|
||||
|
||||
load_profile() {
|
||||
local profile="${PROFILE:-stable-cinnamon}"
|
||||
local pdir="$PROFILES_DIR/$profile"
|
||||
|
||||
if [[ ! -d "$pdir" ]]; then
|
||||
echo "[ERR] profile '$profile' not found at $pdir" >&2
|
||||
echo "Available profiles:" >&2
|
||||
ls -1 "$PROFILES_DIR" 2>/dev/null | sed 's/^/ - /' >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -r "$pdir/profile.conf" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$pdir/profile.conf"
|
||||
fi
|
||||
|
||||
export PROFILE="$profile"
|
||||
export PROFILE_DIR="$pdir"
|
||||
# Resolve packages list path (profile.conf may set it relative or absolute).
|
||||
if [[ -n "$PROFILE_PACKAGES_FILE" && ! -r "$PROFILE_PACKAGES_FILE" ]]; then
|
||||
# Try resolving relative to profile dir, then project root.
|
||||
if [[ -r "$pdir/$(basename "$PROFILE_PACKAGES_FILE")" ]]; then
|
||||
PROFILE_PACKAGES_FILE="$pdir/$(basename "$PROFILE_PACKAGES_FILE")"
|
||||
elif [[ -r "${PROJECT_DIR:-.}/$PROFILE_PACKAGES_FILE" ]]; then
|
||||
PROFILE_PACKAGES_FILE="${PROJECT_DIR:-.}/$PROFILE_PACKAGES_FILE"
|
||||
fi
|
||||
fi
|
||||
[[ -z "$PROFILE_PACKAGES_FILE" ]] && PROFILE_PACKAGES_FILE="$pdir/packages.list"
|
||||
export PROFILE_PACKAGES_FILE
|
||||
|
||||
echo "[INFO] profile loaded: $PROFILE ($PROFILE_DESC)"
|
||||
return 0
|
||||
}
|
||||
|
||||
run_profile_customizations() {
|
||||
# Source every *.sh under <profile>/customizations/ in name order.
|
||||
local cdir="$PROFILE_DIR/customizations"
|
||||
[[ -d "$cdir" ]] || { echo "[INFO] no profile customizations dir at $cdir"; return 0; }
|
||||
local hook
|
||||
for hook in "$cdir"/*.sh; do
|
||||
[[ -r "$hook" ]] || continue
|
||||
echo "[INFO] running profile hook: $(basename "$hook")"
|
||||
# shellcheck disable=SC1090
|
||||
source "$hook"
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user