Refactor install logic, use file-based overrides per OS/distro

This commit is contained in:
2026-01-15 00:06:46 -06:00
parent 9f67636472
commit a220886000
38 changed files with 187 additions and 120 deletions

View File

@@ -1,26 +1,16 @@
#!/bin/zsh
apply_overrides() {
name="$1"
kind="$2"
echo $3 |
sed -E 's/; */\n/g' |
while IFS=$'\n ' read -r override_key override_values; do
[[ -z $override_values ]] && continue
override_key=$(echo $override_key | sed 's/[: ]//g')
[[ $override_key = $BOX_SETUP_OS ]] && eval $override_values
[[ $override_key = $BOX_SETUP_DISTRO ]] && eval $override_values
[[ $4 =~ $override_key ]] && eval $override_values
done
[[ -z $name || -z $kind ]] && echo "zz_skip,zz_skip" || echo "$name,$kind"
}
build_install() {
echo "-- installing $1"
build_custom() {
target=$(echo "custom_$BOX_SETUP_OS-$BOX_SETUP_DISTRO-$1" | tr '-' '_')
target=$(echo "custom-$1-$BOX_SETUP_OS-$BOX_SETUP_DISTRO" | tr '-' '_')
[[ ! -e ./installs_and_builds/$target ]] &&
target=$(echo "custom_default_$1" | tr '-' '_')
target=$(echo "custom-$1-$BOX_SETUP_OS-default" | tr '-' '_')
[[ ! -e ./installs_and_builds/$target ]] &&
echo "custom build/install script not found for: $1" &&
target=$(echo "custom-$1-default" | tr '-' '_')
[[ ! -e ./installs_and_builds/$target ]] &&
${=BOX_SETUP_INSTALL_COMMAND} "$1" &&
return
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/$1.XXXXXXXX") || {
@@ -40,19 +30,14 @@ echo "---- updating package manager / packages"
echo "---- installing programs ---------------"
[[ -z $1 ]] && system_types_list="base" || system_types_list="base,$1"
echo "-------- for system types: $system_types_list"
sed 1d "installs_and_builds/programs.csv" |
while IFS=, read -r name kind os_overrides distro_overrides system_overrides notes; do
apply_overrides $name $kind $os_overrides '' | IFS=, read -r name kind
apply_overrides $name $kind $distro_overrides '' | IFS=, read -r name kind
apply_overrides $name $kind $system_overrides $system_types_list |
IFS=, read -r name kind
[[ $name = 'zz_skip' || $kind = 'zz_skip' ]] && continue
echo "-- installing $name"
[[ $kind = 'package_manager' ]] && ${=BOX_SETUP_INSTALL_COMMAND} ${=name}
[[ $kind = 'build_custom' ]] && build_custom $name
echo "$system_types_list" |
sed -E "s/,/\n/g" |
while IFS="\n" read -r system_type; do
echo "-------- install for system type: $system_type"
cat "installs_and_builds/programs_$system_type.txt" |
while IFS="\n" read -r program_name; do
build_install "$program_name"
done
done