diff --git a/bootstrap/install_packages.sh b/bootstrap/install_packages.sh index 66ac563..a7383fd 100755 --- a/bootstrap/install_packages.sh +++ b/bootstrap/install_packages.sh @@ -11,6 +11,7 @@ PKG_TSV_FILE=${PKG_TSV_FILE:-bootstrap/packages_stable.tsv} packages_repo="${BOOTSTRAP_PACKAGES:-$(grep -e ' R ' "$PKG_TSV_FILE" | cut -f1 -d' ')}" packages_aur="${BOOTSTRAP_PACKAGES_AUR:-$(grep -e ' A ' "$PKG_TSV_FILE" | cut -f1 -d' ')}" packages_pipx="${BOOTSTRAP_PACKAGES_PIPX:-$(grep -e ' P ' "$PKG_TSV_FILE" | cut -f1,5 -d' ')}" +packages_uv="${BOOTSTRAP_PACKAGES_PIPX:-$(grep -e ' U ' "$PKG_TSV_FILE" | cut -f1,5 -d' ')}" main() { local cmd="" @@ -18,7 +19,7 @@ main() { case "$1" in -v | --version) - printf "Package bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.3\n" + printf "Package bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.4\n" ;; -h | --help) printf "Usage: install [-f|--force][-v|--version][-h|--help]\n\n-f Do not ask for any confirmations but force update and installation.\n" @@ -72,6 +73,14 @@ install_packages() { fi } +# check if any packages in list +has_pkg() { # 1=variable containing packages + if [ -n "$1" ]; then + return 0 + fi + return 1 +} + install_pipx() { if type pipx >/dev/null 2>&1; then echo "Existing pipx installation found .........................................." @@ -84,6 +93,18 @@ install_pipx() { fi } +install_uv() { + if type uv >/dev/null 2>&1; then + echo "Existing uv installation found .........................................." + return + fi + if "$unattended"; then + paru -S --noconfirm uv + else + paru -S uv + fi +} + install_pipx_pkgs() { while IFS= read -r line; do if [ -z "$line" ]; then return; fi @@ -97,6 +118,20 @@ install_pipx_pkgs() { done <<<"$packages_pipx" } +install_uv_pkgs() { + while IFS= read -r line; do + if [ -z "$line" ]; then return; fi + prog=$(echo "$line" | cut -f1 -d' ') + injections=$(echo "$line" | cut -f2 -d' ') + + cmd_with_args="uv tool install" + for inject_args in ${injections//,/ }; do + cmd_with_args+=" --with $inject_args" + done + $cmd_with_args "$prog" + done <<<"$packages_uv" +} + install() { unattended=$1 echo "Beginning package bootstrap ..............................................." @@ -105,11 +140,20 @@ install() { echo "Installing apps ..........................................................." update_repos "$unattended" install_packages "$unattended" - echo "Done ......................................................................" - echo "Installing pipx ..........................................................." - install_pipx - echo "Installing pipx packages .................................................." - install_pipx_pkgs + + if has_pkg "$packages_pipx"; then + echo "Installing pipx ..........................................................." + install_pipx + echo "Installing pipx packages .................................................." + install_pipx_pkgs + fi + + if has_pkg "$packages_uv"; then + echo "Installing uv ..........................................................." + install_uv + echo "Installing uv packages .................................................." + install_uv_pkgs + fi echo "Done ......................................................................" }