(feat) add help menu and some pacman checks

This commit is contained in:
b1ek 2024-02-15 05:01:12 +10:00
parent 1937426dcb
commit 44afad7241
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 21 additions and 4 deletions

View File

@ -40,7 +40,7 @@ brickdb() {
}
pkg_installed() {
if [ ! -z $(echo "$BRICKS_INSTALLED" | grep "$1") ]; then
if [ ! -z $(echo "$BRICKS_INSTALLED" | grep -E "^$1 \\\\d") ]; then
return 0
fi
return 1
@ -53,7 +53,7 @@ user_confirm() {
fi
while true; do
read -r -n 1 -p "${1:-Continue?} [Y/n]: " REPLY
read -r -n 1 -p "$(inf "- ${1:-Continue?} [Y/n]: ")" REPLY
case $REPLY in
[yY]) echo ; return 0 ;;
[nN]) echo ; return 1 ;;
@ -150,6 +150,14 @@ while [[ $# -gt 0 ]]; do
echo "https://git.blek.codes/blek/os"
exit 0
;;
-h|--help)
echo "brick $version (gpl 3 only)"
inf "Usage: $0 [PACKAGES]"
inf "$(inf "-h --help \t - Display this message")"
inf "$(inf "-v --version \t - Print version and exit")"
inf "$(inf "-L \t - List all packages")"
exit 0
;;
-*)
# meh domt need unkonw args
shift;;
@ -186,8 +194,11 @@ if [ "${#PKGS[@]}" == "0" ]; then
inf "nothing to do"
exit
else
inf "Packages to install: ${PKGS[@]}"
user_confirm
inf "packages to install: ${PKGS[@]}"
if ! user_confirm; then
inf "canceled"
exit
fi
fi
PACDEPS=()
@ -220,6 +231,12 @@ if [ "${#PACDEPS[@]}" != "0" ]; then
# then there might actually be no work to be done
if [ "$TO_INSTALL" != "" ]; then
if [ -f /var/lib/pacman/db.lck ]; then
errcho "pacman is running now; can't install pacman deps"
errcho "if you are sure that pacman is not running, delete /var/lib/pacman/db.lck manually"
fi
inf "installing pacman packages:"
inf "$TO_INSTALL"