#!/usr/bin/env bash PACKAGE=postinstallation # ─< Check if the given command exists silently >───────────────────────────────────────── command-exists() { command -v "$@" >/dev/null 2>&1 } source-script() { local url="$1" local import="$(mktemp)" if command-exists curl; then curl -fsSL $url -o $import elif command-exists wget; then wget -O $import $url else echo "curl/wget is required, but missing.." exit 69 fi source "$import" sleep 0.2 rm "$import" } get-dependencies() { pen bold blue "Checking build dependencies.." # INFO: # ╭─────────────────────────────────────────────────────────────────────────╮ # │ You can define dependencies for various linux distros here. It will │ # │ automagically be pulled via the $pkgArray[$distro] variable │ # ╰─────────────────────────────────────────────────────────────────────────╯ generalDeps=( "awk" "7zip" "bc" "btop" "curl" "fzf" "gawk" "git" "duf" "keychain" "make" "pv" "ripgrep" "rsync" "stow" "sudo" "unzip" "vi" "zsh" "zoxide" ) generalBloat=( "nano" "micro" ) depsDebian=( "eza" ) depsFedora=() depsOpensuse=() depsArch=( "tldr" "oh-my-posh" "eza" "dog" "ytui-bin" ) depsAlpine=() declare -A deps=( [debian]="depsDebian" [ubuntu]="depsUbuntu" [fedora]="depsFedora" [arch]="depsArch" [alpine]="depsAlpine" [opensuse]="depsOpensuse" ) # INFO: # ╭────────────────────────────────────────────────────────────────╮ # │ This variable stores the packages you provided for each distro │ # ╰────────────────────────────────────────────────────────────────╯ # declare -n pkgArray="${deps[$distro]}" local pkg pkglist=() case "$distro" in debian | ubuntu | arch | fedora | alpine | opensuse) pen bold blue "Getting package counter.." for pkg in "${generalDeps[@]} ${pkgArray[@]}"; do if ! command-exists $pkg; then pkglist=("$pkg") fi done check "Done getting packages" check-and-install "${pkglist[@]}" ;; *) echo-error "There are no dependencies to install for $distro" return 0 ;; esac } removeBloat() { if ! $arch; then spin "Removing bloat.." for pkg in "${generalBloat[@]}"; do if run --err err pkg-remove "$pkg"; then upclear check "Removed $pkg" else upclear throw "Error while removing $pkg" echo-error "${err:-}" fi done else pen bold blue "There are no pacakges to remove on arch.." fi } init-nala() { if command-exists nala; then # pen bold blue "Nala is already present, fetching mirros now!" # pen bold yellow "(This might take a minute or two, depending on your internet speed)" if confirm "Nala is already present. Do you want to auto fetch the best mirrors?"; then check green bold "Depending on your internet speed, this might take a while.." $_sudo nala fetch --auto --assume-yes --https-only fi else if confirm "Nala is not installed on the system, do you want to install it now?" # arch = bool # fedora = bool # opensuse = bool.... # You can then use it for, `if $arch; then` # Also this gives you the pkg-install command, which installs a package pased on the packagemanager/distro used. # 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.. setup-env() { # local beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh # local pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh if ! command-exists pkg-install && ! command-exists check-and-install && ! command-exists spin; then source-script $dream line fi } if setup-env; then # ─< package variable >─────────────────────────────────────────────────────────────────── unset PACKAGE # ─< argument list variables >──────────────────────────────────────────────────────────── silent=false PACKAGE=postinstallation main fi