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
+25 -17
View File
@@ -2,30 +2,33 @@
[[ $1 = "--help" ]] && {
echo "\nusage: ./box_setup.sh [system-type]"
echo "\nsystem-type options: work"
echo "\nexamples:\n ./box_setup.sh\n ./box_setup.sh work\n"
echo "\nsystem-type options: music_studio, programming"
echo "\nexamples:\n ./box_setup.sh\n ./box_setup.sh music_studio\n"
exit 0
}
echo "---- settings vars for system type -----"
# determine OS and, if linux, distro
[[ "$OSTYPE" = *"darwin"* ]] && setup_os="macos" || {
[[ "$OSTYPE" = *"linux"* ]] && setup_os="linux" && {
# determine OS and distro
case "$OSTYPE" in
(*linux*)
setup_os="linux"
[[ -f /etc/os-release ]] && . /etc/os-release
setup_distro=$(echo "${NAME%% *}" | tr '[:upper:]' '[:lower:]')
[[ -z "$setup_distro" ]] && echo "OS: linux; distro not detected" && exit 1
}
}
[[ -z "$setup_os" ]] && echo "OS not detected" && exit 1
;;
(*darwin*)
setup_os="macos"
setup_distro="macos" # just repeat macos, but maybe there is some better value
;;
esac
# ensure OS and distro are set before proceeding
[[ -z "$setup_os" ]] && echo "setup OS not detected" && exit 1
[[ -z "$setup_distro" ]] && echo "setup distro not detected" && exit 1
# set package manager commands for installs
[[ "$setup_os" = "macos" ]] && {
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
} || {
[[ "$setup_os" = "linux" ]] && {
case "$setup_os" in
(linux)
case $setup_distro in
(arch | artix)
install_cmd="sudo pacman -S --noconfirm"
@@ -38,8 +41,13 @@ echo "---- settings vars for system type -----"
update_pkgs_cmd='sudo apt upgrade'
;;
esac
}
}
;;
(macos)
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
;;
esac
# export vars for scripts
export BOX_SETUP_OS="$setup_os"
-6
View File
@@ -16,12 +16,6 @@ for the code contained within these sources, but I wanted to give attribution no
- [YouTube video - neovim config video](https://www.youtube.com/watch?v=w7i4amO_zaE)
- [FrontEnd Masters course - dev productivity v2](https://frontendmasters.com/courses/developer-productivity-v2/)
## Idea of using a list of programs in a file for build/install
The idea of using a file with a list of programs in it for building and/or
installing programs was inspired by Luke Smith's
[LARBS project](https://github.com/LukeSmithxyz/LARBS/tree/master).
## Theme-swtiching/setting logic and some themes
Much of the "theme-switching" or "theme-setting" logic and scripts are derived from
+4 -6
View File
@@ -8,16 +8,14 @@
- xresources working? use from/within theme-changing logic?
- finished artix/dinit setup
- include figuring out wiregaurd/vpn stuff
- switch install approach from csv file to:
- checking for custom file for os/distro
- then checking custom file for overall
- then just installing via package manager
- web browsers config and install (primary: qutebrowser, alt1: brave, alt2: tor)
- web browsers config and install (primary: qutebrowser, alt1: brave, alt2: tor?)
- config for mpd, and client(s), (mpd clients to consider: mpc, ncmpcpp, ncmpc, inori)
- get find, xargs, and awk (use nawk) as unified as i can across system types
## optional
- pick rss reader; newsboat? others? option with inbox and separate queues?
- configured neomutt
- picked and configured rss reader
- newsboat? others? option with inbox and separate queues?
- make all these scripts POSIX-compliant (or at least usable in ksh/oksh)
+16 -31
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
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "program not applicable for this OS or distro, skipping build/installation"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# use normal package manager for macos install, since default is noop for other OSs
${=BOX_SETUP_INSTALL_COMMAND} --cask nikitabobko/tap/aerospace
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "TODO: custom script for bitwig not yet implemented; may just want manual install"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "TODO: custom script for bitwig not yet implemented; may just want manual install"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "program not applicable for this OS or distro, skipping build/installation"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# use normal package manager for macos install, since default is noop for other OSs
${=BOX_SETUP_INSTALL_COMMAND} coreutils
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
# for now, use luke's build; i can make my own fork later if desired
git clone https://github.com/LukeSmithxyz/dmenu.git
pushd dmenu > /dev/null
sudo make clean install
popd > /dev/null
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+7
View File
@@ -0,0 +1,7 @@
#!/bin/sh
git clone https://git.drinkingtea.net/david/dwm.git
pushd dwm > /dev/null
sudo make clean install
popd > /dev/null
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "program not applicable for this OS or distro, skipping build/installation"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# use normal package manager for macos install, since default is noop for other OSs
${=BOX_SETUP_INSTALL_COMMAND} findutils
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# adjust prefix for package manager before install
${=BOX_SETUP_INSTALL_COMMAND} --cask gimp
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# adjust prefix for package manager before install
${=BOX_SETUP_INSTALL_COMMAND} --cask kitty
@@ -1,6 +1,7 @@
#!/bin/zsh
git clone https://github.com/ibara/oksh.git
pushd oksh > /dev/null
./configure
make && sudo make install
@@ -1,2 +0,0 @@
echo 'hello from bitwig custom build!'
echo 'custom script for bitwig is not yet implemented, these echos just here for testing'
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# change package name; on arch it is 'pandoc-cli'
${=BOX_SETUP_INSTALL_COMMAND} pandoc-cli
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# change package name; on artix it is 'pandoc-bin'
${=BOX_SETUP_INSTALL_COMMAND} pandoc-bin
@@ -1,18 +0,0 @@
#!/bin/zsh
# from primeagen's examples and dev repo
# currnetly not used, but keeping for reference in case i need this soon for debian
install_neovim_dir=$HOME/.local/build/neovim
install_neovim_version="v0.10.3"
[ ! -z $NVIM_VERSION ] && install_neovim_version="$NVIM_VERSION"
echo "install_neovim_version: \"$install_neovim_version\""
[ ! -d $install_neovim_dir ] && git clone https://github.com/neovim/neovim.git $install_neovim_dir
git -C $install_neovim_dir fetch --all
git -C $install_neovim_dir checkout $install_neovim_version
make -C $install_neovim_dir clean
make -C $install_neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make -C $install_neovim_dir install
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "program not applicable for this OS or distro, skipping build/installation"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# use normal package manager for macos install, since default is noop for other OSs
${=BOX_SETUP_INSTALL_COMMAND} koekeishiya/formulae/skhd
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# git clone https://git.drinkingtea.net/david/st.git
# pushd st > /dev/null
# sudo make clean install
# popd > /dev/null
echo "TODO: st build not yet done, skipping this install for now"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/zsh
# tenacity is not readily available on macos, so just use audacity for now
${=BOX_SETUP_INSTALL_COMMAND} --cask audacity
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "intentionally skipping build/installation for macos"
-38
View File
@@ -1,38 +0,0 @@
name,kind,os_overrides,distro_overrides,system_type_overrides,notes
gcc,package_manager,macos: name='',,,
clang,package_manager,macos: name='',,,
musl,package_manager,macos: name='',,,
coreutils,package_manager,linux: name='',,,
findutils,package_manager,linux: name='',,,
make,package_manager,,,,
cmake,package_manager,,,,
mise,build_custom,,,,TODO implement the build_custom script for this
mpv,package_manager,,,,
kitty,package_manager,macos: name='--cask kitty',,,
zsh,package_manager,,,,
ksh,build_custom,,,,
tmux,package_manager,,,,
neovim,package_manager,,,,
mutt,package_manager,,,,
podman,package_manager,,,,
curl,package_manager,,,,
grep,package_manager,,,,
ripgrep,package_manager,,,,
sed,package_manager,macos: name='',,,
fzf,package_manager,,,,
jq,package_manager,,,,
parallel,package_manager,,,,
gettext,package_manager,,,,
htop,package_manager,,,,
ffmpeg,package_manager,,,work: name='',
mpd,package_manager,,,,
ncmpcpp,package_manager,,,,
git,package_manager,,,,
calcurse,package_manager,,,,
zathura,package_manager,macos: name='',,,
tenacity,package_manager,macos: name='--cask audacity',,work: name='',tenacity not available via homebrew; use audacity in macos
bitwig-studio,package_manager,macos: name='--cask bitwig-studio',artix: kind='aur'; arch: kind='aur'; debian: kind='build_custom';,work: name='',
gimp,package_manager,macos: name='--cask gimp',,,
--cask nikitabobko/tap/aerospace,package_manager,linux: name='',,,
koekeishiya/formulae/skhd,package_manager,linux: name='',,,
pandoc,package_manager,,arch: name='pandoc-cli'; artix: name='pandoc-bin';,work: name='',
1 name kind os_overrides distro_overrides system_type_overrides notes
2 gcc package_manager macos: name=''
3 clang package_manager macos: name=''
4 musl package_manager macos: name=''
5 coreutils package_manager linux: name=''
6 findutils package_manager linux: name=''
7 make package_manager
8 cmake package_manager
9 mise build_custom TODO implement the build_custom script for this
10 mpv package_manager
11 kitty package_manager macos: name='--cask kitty'
12 zsh package_manager
13 ksh build_custom
14 tmux package_manager
15 neovim package_manager
16 mutt package_manager
17 podman package_manager
18 curl package_manager
19 grep package_manager
20 ripgrep package_manager
21 sed package_manager macos: name=''
22 fzf package_manager
23 jq package_manager
24 parallel package_manager
25 gettext package_manager
26 htop package_manager
27 ffmpeg package_manager work: name=''
28 mpd package_manager
29 ncmpcpp package_manager
30 git package_manager
31 calcurse package_manager
32 zathura package_manager macos: name=''
33 tenacity package_manager macos: name='--cask audacity' work: name='' tenacity not available via homebrew; use audacity in macos
34 bitwig-studio package_manager macos: name='--cask bitwig-studio' artix: kind='aur'; arch: kind='aur'; debian: kind='build_custom'; work: name=''
35 gimp package_manager macos: name='--cask gimp'
36 --cask nikitabobko/tap/aerospace package_manager linux: name=''
37 koekeishiya/formulae/skhd package_manager linux: name=''
38 pandoc package_manager arch: name='pandoc-cli'; artix: name='pandoc-bin'; work: name=''
+30
View File
@@ -0,0 +1,30 @@
gcc
musl
coreutils
findutils
make
mpv
kitty
zsh
ksh
tmux
neovim
neomutt
curl
grep
ripgrep
sed
fzf
jq
parallel
gettext
htop
ffmpeg
mpd
ncmpcpp
git
calcurse
zathura
gimp
aerospace
skhd
@@ -0,0 +1,2 @@
tenacity
bitwig-studio
@@ -0,0 +1,5 @@
clang
cmake
mise
podman
pandoc