From 3c1ac59cf94d475b6eb4d9691de2a8d6c94d3f5f Mon Sep 17 00:00:00 2001 From: david Date: Fri, 4 Apr 2025 16:55:39 -0500 Subject: [PATCH] Add script to update package manager defs and packages --- README.md | 9 ++++---- .../s00_package_manager_updates | 8 +++++++ installs_and_builds/{s00_libs => s01_libs} | 0 installs_and_builds/{s01_utils => s02_utils} | 0 set_script_env_vars | 22 ++++++++++++++++--- 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100755 installs_and_builds/s00_package_manager_updates rename installs_and_builds/{s00_libs => s01_libs} (100%) rename installs_and_builds/{s01_utils => s02_utils} (100%) diff --git a/README.md b/README.md index 804ef6f..14f6d71 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,18 @@ # repo containing configs and scripts to set up a box ### 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) - 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` - export the env var `BOX_SETUP_OS` to indicate the operating system - - options defined in `set_env_vars` file -- if on macOS, install [homebrew](https://brew.sh/) + - options defined in `set_script_env_vars` file - ensure sudo access is configured for the current user (2025-01-27, not needed on macos) ### 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` ### todo items diff --git a/installs_and_builds/s00_package_manager_updates b/installs_and_builds/s00_package_manager_updates new file mode 100755 index 0000000..cdd1723 --- /dev/null +++ b/installs_and_builds/s00_package_manager_updates @@ -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} + diff --git a/installs_and_builds/s00_libs b/installs_and_builds/s01_libs similarity index 100% rename from installs_and_builds/s00_libs rename to installs_and_builds/s01_libs diff --git a/installs_and_builds/s01_utils b/installs_and_builds/s02_utils similarity index 100% rename from installs_and_builds/s01_utils rename to installs_and_builds/s02_utils diff --git a/set_script_env_vars b/set_script_env_vars index 052827c..f62d650 100644 --- a/set_script_env_vars +++ b/set_script_env_vars @@ -3,10 +3,26 @@ exit 1 local install_cmd='' +local update_pkg_manager_and_defs_cmd='' +local update_pkgs_cmd='' case $BOX_SETUP_OS in - (arch | artix) install_cmd="sudo pacman -S" ;; - (debian) install_cmd="sudo apt install" ;; - (macos) install_cmd="brew install" ;; + (arch | artix) + install_cmd="sudo pacman -S" + 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 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"