Replace most install scripts with list in csv file

This commit is contained in:
2025-11-07 14:43:33 -06:00
parent f4baf50cf1
commit ee1c3b096e
31 changed files with 80 additions and 184 deletions

View File

@@ -1,34 +1,41 @@
#!/bin/zsh
find_scripts_in_dir() {
echo $(find $1 -maxdepth 1 -mindepth 1 -type f | sort)
apply_overrides() {
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"
}
install_scripts_from_list() {
for script in $@; do
if [[ -x $script ]]; then
echo "executing: $script"
./$script
fi
done
}
system_types_list="base"
scripts_from_dir=($(find_scripts_in_dir "./installs_and_builds"))
[[ $1 = "personal" ]] && {
system_types_list+=", personal"
scripts_from_dir+=($(find_scripts_in_dir "./installs_and_builds/personal"))
}
[[ $1 = "studio-music" ]] && {
system_types_list+=", studio-music"
scripts_from_dir+=($(find_scripts_in_dir "./installs_and_builds/studio_music"))
}
[[ $1 = "work-placeholder" ]] && {
system_types_list+=", work-placeholder"
scripts_from_dir+=($(find_scripts_in_dir "./installs_and_builds/work_placeholder"))
}
echo "---- updating package manager / packages"
[[ -n "$BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD" ]] &&
${=BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD}
[[ -n "$BOX_SETUP_UPDATE_PKGS_CMD" ]] && ${=BOX_SETUP_UPDATE_PKGS_CMD}
echo "---- installing programs ---------------"
[[ -z $1 ]] && system_types_list="base" || system_types_list="base,$1"
echo "-------- for system types: $system_types_list"
install_scripts_from_list "${scripts_from_dir[@]}"
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
[[ $kind = 'package_manager' ]] && ${=BOX_SETUP_INSTALL_COMMAND} ${=name} || {
[[ $kind = 'build_custom' ]] && {
target=$(echo "custom_$BOX_SETUP_OS-$BOX_SETUP_DISTRO-$name" | tr '-' '_')
"./installs_and_builds/$target"
}
}
done