diff --git a/pkgui.sh b/pkgui.sh index eae3c1f..6e7715b 100644 --- a/pkgui.sh +++ b/pkgui.sh @@ -9,7 +9,7 @@ # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user - # distro = + # distro = # arch = bool # fedora = bool # opensuse = bool.... @@ -18,14 +18,24 @@ # CAUTION: # This only wokrs for generic package names, like neovim, or vim, or tmux etc.. # not every package packagemanager has the same packagenames for their packages.. - if command_exists curl; then - eval "$(curl -fsSL https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh)" - else - echo "curl is required, but missing.." - exit 1 - fi + getImports() { + i="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh" + import="$(mktemp)" + if command_exists curl; then + curl -fsSL $i -o $import + else + echo "curl is required, but missing.." + exit 1 + fi + + source "$import" + sleep 0.3 + rm "$import" + echo_warning "cleaned $import" + } checkDeps() { + echo_info "Checking dependencies.." if ! command_exists pkgui; then return 0 else @@ -56,12 +66,13 @@ } instDeps() { + echo_info "Installing missing dependencies.." case "$distro" in arch | opensuse | fedora) - _install go + run _install go ;; debian | ubuntu) - _install golang + run _install golang ;; *) echo_error "$distro is not supported by this script" @@ -72,6 +83,7 @@ getPkgUI() { local tempDir="$(mktemp -d)" local url="https://git.k4li.de/scripts/installs/raw/branch/main/.src/pkgui" + echo_info "Getting the pkgui binary from $url" cd $tempDir || mkdir $tempDir && cd $tempDir echo_info "Curling the binary directly via $url.." @@ -84,23 +96,32 @@ } instPkgUI() { + echo_info "Installing the binary" if [ -d "$HOME/.local/bin" ]; then - ln -srf ./pkgui "$HOME/.local/bin/pkgui" && echo_note "Linked to $HOME/.local/bin/pkgui" + run ln -srf ./pkgui "$HOME/.local/bin/pkgui" && echo_note "Linked to $HOME/.local/bin/pkgui" else echo_note "Couldn't find $HOME/.local/bin directory, linking systemwide.." - $_sudo ln -sfr ./pkgui /bin/pkgui && echo_note "Linked to /bin/pkgui" + run $_sudo ln -sfr ./pkgui /bin/pkgui && echo_note "Linked to /bin/pkgui" fi } main() { - if checkDeps; then - if instDeps; then - if getPkgUI; then - instPkgUI - fi - fi - fi + checkDeps + instDeps + getPkgUI + instPkgUI } + if getImports; then + case "$1" in + --silent | -s) + silent=true + ;; + *) + silent=false + ;; + esac + fi + main }