bootstrap: Add pipx managed package installation

Packages managed through pipx (and pipx itself) are now also
installed in the initial process. They are marked as coming
from 'P' source in the package TSV. There is a special field
for these packages which declares any injections made by pipx
which will also automatically get injected into the pipx
environment on installation.
This commit is contained in:
Marty Oehme 2023-06-08 13:05:01 +02:00
parent bfe7e7790c
commit 29cb20efcb
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 40 additions and 3 deletions

View file

@ -7,9 +7,10 @@
# DESCRIPTION: Display usage information for this script.
# PARAMETERS: see usage function
#==============================================================================
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' ' )}"
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' ')}"
main() {
local cmd=""
@ -69,6 +70,31 @@ install_packages() {
fi
}
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_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() {
unattended=$1
echo "Beginning package bootstrap ..............................................."
@ -78,6 +104,11 @@ install() {
update_repos "$unattended"
install_packages "$unattended"
echo "Done ......................................................................"
echo "Installing pipx ..........................................................."
install_pipx
echo "Installing pipx packages .................................................."
install_pipx_pkgs
echo "Done ......................................................................"
}
main "$@"