Add script to update package manager defs and packages

This commit is contained in:
david 2025-04-04 16:55:39 -05:00
parent e8404ac44d
commit 3c1ac59cf9
5 changed files with 32 additions and 7 deletions

View File

@ -1,17 +1,18 @@
# repo containing configs and scripts to set up a box # repo containing configs and scripts to set up a box
### prerequisites ### prerequisites
- git is installed (to clone repo below, consider adding logic to handle automatically) - when running on a fresh system, ensure package manager is configured
- i.e. source repos, mirrors, etc. are configured
- if on macOS, have to first install the package manager, [homebrew](https://brew.sh/)
- zsh is installed (scripts are written for zsh) - zsh is installed (scripts are written for zsh)
- ensure ZDOTDIR is set in a persistent way for system (not just setup scripts) - ensure ZDOTDIR is set in a persistent way for system (not just setup scripts)
- current approach: add `export ZDOTDIR="$HOME/.config/zsh"` to `/etc/zshenv` - current approach: add `export ZDOTDIR="$HOME/.config/zsh"` to `/etc/zshenv`
- export the env var `BOX_SETUP_OS` to indicate the operating system - export the env var `BOX_SETUP_OS` to indicate the operating system
- options defined in `set_env_vars` file - options defined in `set_script_env_vars` file
- if on macOS, install [homebrew](https://brew.sh/)
- ensure sudo access is configured for the current user (2025-01-27, not needed on macos) - ensure sudo access is configured for the current user (2025-01-27, not needed on macos)
### script run ### script run
- git clone this repo - git clone this repo (TODO: consider adding logic to handle automatically)
- from the repo's root directory, run `./box_setup` - from the repo's root directory, run `./box_setup`
### todo items ### todo items

View File

@ -0,0 +1,8 @@
#!/bin/zsh
[[ -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}

View File

@ -3,10 +3,26 @@
exit 1 exit 1
local install_cmd='' local install_cmd=''
local update_pkg_manager_and_defs_cmd=''
local update_pkgs_cmd=''
case $BOX_SETUP_OS in case $BOX_SETUP_OS in
(arch | artix) install_cmd="sudo pacman -S" ;; (arch | artix)
(debian) install_cmd="sudo apt install" ;; install_cmd="sudo pacman -S"
(macos) install_cmd="brew install" ;; update_pkg_manager_and_defs_cmd='' # don't; update system instead?
update_pkgs_cmd='sudo pacman -Syu'
;;
(debian)
install_cmd="sudo aptitude install"
update_pkg_manager_and_defs_cmd='sudo aptitude update'
update_pkgs_cmd='sudo aptitude full-upgrade'
;;
(macos)
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
;;
esac esac
export BOX_SETUP_INSTALL_COMMAND="$install_cmd" export BOX_SETUP_INSTALL_COMMAND="$install_cmd"
export BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD="$update_pkg_manager_and_defs_cmd"
export BOX_SETUP_UPDATE_PKGS_CMD="$update_pkgs_cmd"