From 44afad72415171744f1ccbaf28709fe1463d1ad5 Mon Sep 17 00:00:00 2001 From: b1ek Date: Thu, 15 Feb 2024 05:01:12 +1000 Subject: [PATCH] (feat) add help menu and some pacman checks --- brick.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/brick.sh b/brick.sh index 77e5689..17fd148 100755 --- a/brick.sh +++ b/brick.sh @@ -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"