2019-11-24 15:17:14 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Simple app bootstrapping script
|
|
|
|
|
|
|
|
#=== main function ============================================================
|
|
|
|
# NAME: main
|
|
|
|
# DESCRIPTION: Display usage information for this script.
|
|
|
|
# PARAMETERS: see usage function
|
|
|
|
#==============================================================================
|
2023-06-08 11:02:45 +00:00
|
|
|
PKG_TSV_FILE=${PKG_TSV_FILE:-bootstrap/packages_stable.tsv}
|
2023-06-08 11:05:01 +00:00
|
|
|
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' ')}"
|
2019-12-30 09:20:17 +00:00
|
|
|
|
2019-11-24 15:17:14 +00:00
|
|
|
main() {
|
2021-04-04 18:52:52 +00:00
|
|
|
local cmd=""
|
|
|
|
local ret=0
|
2019-11-24 15:17:14 +00:00
|
|
|
|
2021-04-04 18:52:52 +00:00
|
|
|
case "$1" in
|
|
|
|
-v | --version)
|
|
|
|
printf "Package bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.3\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
|
2019-11-24 15:17:14 +00:00
|
|
|
|
2021-04-04 18:52:52 +00:00
|
|
|
$cmd "$@"
|
|
|
|
ret=$((ret + $?))
|
|
|
|
exit $ret
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-08 11:03:27 +00:00
|
|
|
install_paru() {
|
|
|
|
# check for existing paru installation
|
|
|
|
if type paru >/dev/null 2>&1; then
|
|
|
|
echo "Existing paru installation found ..........................................."
|
2021-04-04 18:52:52 +00:00
|
|
|
return
|
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
|
2023-06-08 11:03:27 +00:00
|
|
|
# use tmp dir to make paru
|
2021-04-04 18:52:52 +00:00
|
|
|
target=$(mktemp -d)
|
2023-06-08 11:03:27 +00:00
|
|
|
git clone https://aur.archlinux.org/paru.git "$target"
|
2021-04-04 18:52:52 +00:00
|
|
|
cd "$target" || exit
|
|
|
|
makepkg -si
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
update_repos() {
|
2021-04-04 18:52:52 +00:00
|
|
|
unattended="$1"
|
|
|
|
if "$unattended"; then
|
2023-06-08 11:03:27 +00:00
|
|
|
paru -Sqyy --noconfirm
|
2021-04-04 18:52:52 +00:00
|
|
|
else
|
2023-06-08 11:03:27 +00:00
|
|
|
paru -Syy
|
2021-04-04 18:52:52 +00:00
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_packages() {
|
2021-04-04 18:52:52 +00:00
|
|
|
unattended="$1"
|
|
|
|
if "$unattended"; then
|
2023-06-08 11:03:27 +00:00
|
|
|
echo "$packages_repo" "$packages_aur" | paru -Squ --noconfirm --needed -
|
2021-04-04 18:52:52 +00:00
|
|
|
else
|
2023-06-08 11:03:27 +00:00
|
|
|
echo "$packages_repo" | paru -Squ --needed -
|
|
|
|
echo "$packages_aur" | paru -S --needed -
|
2021-04-04 18:52:52 +00:00
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-08 11:05:01 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2019-11-24 15:17:14 +00:00
|
|
|
install() {
|
2021-04-04 18:52:52 +00:00
|
|
|
unattended=$1
|
|
|
|
echo "Beginning package bootstrap ..............................................."
|
2023-06-08 11:03:27 +00:00
|
|
|
echo "Installing paru ............................................................"
|
|
|
|
install_paru
|
2021-04-04 18:52:52 +00:00
|
|
|
echo "Installing apps ..........................................................."
|
|
|
|
update_repos "$unattended"
|
|
|
|
install_packages "$unattended"
|
|
|
|
echo "Done ......................................................................"
|
2023-06-08 11:05:01 +00:00
|
|
|
echo "Installing pipx ..........................................................."
|
|
|
|
install_pipx
|
|
|
|
echo "Installing pipx packages .................................................."
|
|
|
|
install_pipx_pkgs
|
|
|
|
echo "Done ......................................................................"
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|