Added python packages that should be installed through uv (instead of pipx). uv provides a modern package and project management solution for python packages which are not found in the other repositories (or which should have additional dependencies which are not). Will also slowly migrate my existing python packages away from pipx toward uv so we need one tool less.
160 lines
4.4 KiB
Bash
Executable file
160 lines
4.4 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Simple app bootstrapping script
|
|
|
|
#=== main function ============================================================
|
|
# NAME: main
|
|
# DESCRIPTION: Display usage information for this script.
|
|
# PARAMETERS: see usage function
|
|
#==============================================================================
|
|
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=""
|
|
local ret=0
|
|
|
|
case "$1" in
|
|
-v | --version)
|
|
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"
|
|
;;
|
|
-f | --force)
|
|
install true
|
|
;;
|
|
*)
|
|
install false
|
|
;;
|
|
esac
|
|
shift
|
|
|
|
$cmd "$@"
|
|
ret=$((ret + $?))
|
|
exit $ret
|
|
}
|
|
|
|
install_paru() {
|
|
# check for existing paru installation
|
|
if type paru >/dev/null 2>&1; then
|
|
echo "Existing paru installation found ..........................................."
|
|
return
|
|
fi
|
|
|
|
# use tmp dir to make paru
|
|
tempdir=".paru"
|
|
git clone https://aur.archlinux.org/paru.git "$tempdir"
|
|
pushd "$tempdir" || exit 1
|
|
makepkg -si
|
|
popd || exit 1
|
|
rm -rf "$tempdir"
|
|
}
|
|
|
|
update_repos() {
|
|
unattended="$1"
|
|
if "$unattended"; then
|
|
paru -Sqyy --noconfirm
|
|
else
|
|
paru -Syy
|
|
fi
|
|
}
|
|
|
|
install_packages() {
|
|
unattended="$1"
|
|
if "$unattended"; then
|
|
echo "$packages_repo" "$packages_aur" | paru -Squ --noconfirm --needed -
|
|
else
|
|
echo "$packages_repo" | paru -Squ --needed -
|
|
echo "$packages_aur" | paru -S --needed -
|
|
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 .........................................."
|
|
return
|
|
fi
|
|
if "$unattended"; then
|
|
paru -S --noconfirm python-pipx
|
|
else
|
|
paru -S python-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
|
|
prog=$(echo "$line" | cut -f1 -d' ')
|
|
pipx install "$prog"
|
|
|
|
injections=$(echo "$line" | cut -f2 -d' ')
|
|
for inject_args in ${injections//,/ }; do
|
|
pipx inject "$prog" "$inject_args"
|
|
done
|
|
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 ..............................................."
|
|
echo "Installing paru ............................................................"
|
|
install_paru
|
|
echo "Installing apps ..........................................................."
|
|
update_repos "$unattended"
|
|
install_packages "$unattended"
|
|
|
|
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 ......................................................................"
|
|
}
|
|
|
|
main "$@"
|