diff --git a/test.sh b/test.sh index 0c6d87d..35545c0 100755 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ command_exists() { command -v "$@" >/dev/null 2>&1 } -getImports() { +source-script() { local url="https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh" local import="$(mktemp)" if command_exists curl; then @@ -22,8 +22,8 @@ getImports() { rm -f "$import" } -getDependencies() { - echo_info "Checking build dependencies.." +spin-get-dependencies() { + spin grey "Getting dependencies.." # INFO: # ╭─────────────────────────────────────────────────────────────────────────╮ @@ -36,6 +36,9 @@ getDependencies() { depsArch=() depsAlpine=() + declare -A deplist + local deplist=() + declare -A deps=( [debian]="depsDebian" [ubuntu]="depsUbuntu" @@ -53,7 +56,13 @@ getDependencies() { case "$distro" in debian | ubuntu | arch | fedora | alpine | opensuse) - checkAndInstall "${pkgArray[@]}" + for pkg in "${pkgArray[@]}"; do + if ! command_exists $pkg; then + deplist+=$pkg + fi + done + + pkglist="${deplist[@]}" ;; *) echo_error "There are no dependencies to install for $distro" @@ -65,50 +74,22 @@ getDependencies() { # echo default main() { - if $silent; then - pen bold red "Executing script silently!" - fi + local err - # Kindly ask for input (empty answer is accepted) - seek name "What's your name?" - pen "Hello, $name!" - - # Firmly ask for input (empty answer NOT accepted) - # request name "No really, what's your name?" - # pen "There you go, $name!" - - # Yes/no confirmation (defaults to "yes") - if confirm "Continue?"; then - spin "Working on it.." - sleep 2 - check "Done!" - pen green "Continuing..." + if ! spin-get-dependencies; then + throw "Dependencies could not get generated!" else - spin "Working on it.." - sleep 2 - check "Done!" - pen red "waiting.." - sleep 2 - repen spin "Almost done.." - sleep 2 - repen spin "Waiting some more.." - sleep 2 - check "Task completed!" + check "Dependency list generated!" + + spin bold yellow "Installing packagelist.. ${pkglist[@]}" + if run --err err pkg-install "${pkglist[*]}"; then + check "Installed packages!" + else + throw "$(pen bold blue ${pkglist[*]}) could not get installed!" + echo_error "${err:-}" + fi fi - # Defaulting to "no" - if confirm --default-no "Are you sure?"; then - pen green "Proceeding..." - else - pen red "Cancelled." - fi - - # Menu selection - choose color "Select a color:" "Red" "Green" "Blue" - pen "You selected: $color" - - # source_script "https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh" - # case "$distro" in # arch) # pen bold blue "This is Arch!" @@ -133,9 +114,11 @@ main() { # exit 1 # ;; # esac + # source_script "https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh" + } -if getImports; then +if source-script; then # ─< package variable >─────────────────────────────────────────────────────────────────── unset PACKAGE