testing new syntax.. kinda..

This commit is contained in:
pika 2025-05-23 16:41:54 +02:00
parent 26cd0e40e5
commit 7dbb519902

View file

@ -18,7 +18,7 @@
# CAUTION: # CAUTION:
# This only wokrs for generic package names, like neovim, or vim, or tmux etc.. # 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.. # not every package packagemanager has the same packagenames for their packages..
getImports() { source-script() {
local url="$1" local url="$1"
local import="$(mktemp)" local import="$(mktemp)"
@ -47,7 +47,6 @@
getDependencies() { getDependencies() {
local err local err
echo_pkg deps "Checking build dependencies, and installs missing.."
local depsDebian=(git ninja-build gettext cmake curl build-essential) local depsDebian=(git ninja-build gettext cmake curl build-essential)
local depsFedora=(git ninja-build cmake gcc make gettext curl glibc-gconv-extra) local depsFedora=(git ninja-build cmake gcc make gettext curl glibc-gconv-extra)
@ -71,15 +70,11 @@
for pkg in "${pkgArray[@]}"; do for pkg in "${pkgArray[@]}"; do
if ! command_exists $pkg; then if ! command_exists $pkg; then
spin yellow bold "Installing $(pen red $pkg)" spin yellow bold "Installing $(pen red $pkg)"
sleep 1 run --err err pkg-install $pkg && check "$pkg $(pen green installed)!" ||
if run --err err pkg-install $pkg; then throw "Something went wrong! Could not install $(pen bold red $pkg)" &&
check "$pkg $(pen green installed)!"
else
throw "Something went wrong! Could not install $(pen bold red $pkg)"
throw "${err:-}" throw "${err:-}"
fi
else else
pen "$pkg $(pen green bold 'already installed')" check "$pkg $(pen green bold 'already installed')"
fi fi
done done
;; ;;
@ -99,31 +94,20 @@
line line
spin yellow "Cloning $(pen bold red $PACKAGE) $(pen yellow 'sources at') $(pen red $cloneDir/neovim).." # spin yellow "Cloning $(pen bold red $PACKAGE) $(pen yellow 'sources at') $(pen red $cloneDir/neovim).."
if command_exists git; then if command_exists git; then
sleep 1 run --err err git clone --depth=1 https://github.com/neovim/neovim.git && check green "Cloned $PACKAGE sources" && cd neovim || throw "Error cloning neovim" && pen bold red "The error: ${err:-}"
if run --err err git clone --depth=1 https://github.com/neovim/neovim.git; then
line
check green "Cloned $PACKAGE sources"
cd neovim || throw "Cannot navigate into neovim"
# pen ${output:-}
else
throw "Cannot clone the repo.."
pen bold red "The error: ${err:-}"
fi
else else
echo_error "Git was required, but is missing.. exiting now" echo_error "Git was required, but is missing.. exiting now"
exit 1 return 69
fi fi
} }
makeInstall() { makeInstall() {
local err local err
line spin "Compiling $PACKAGE from source"
# echo_pkg build "Compiling neovim from source"
spin "Compiling neovim from source"
if run --err err make CMAKE_BUILD_TYPE=RelWithDebInfo; then if run --err err make CMAKE_BUILD_TYPE=RelWithDebInfo; then
check "Compiled $PACKAGE from source" check "Compiled $PACKAGE from source"
line line
@ -138,14 +122,13 @@
fi fi
else else
echo_error "${err:-}" echo_error "${err:-}"
exit 1 exit 69
fi fi
} }
checkAndInitConfig() { checkAndInitConfig() {
local err local err
line
if [ -d "$HOME/.config/nvim/" ]; then if [ -d "$HOME/.config/nvim/" ]; then
# echo_pkg qol "Prefetching neovim setup configuration.." # echo_pkg qol "Prefetching neovim setup configuration.."
spin "Prefetching neovim setup configuration.." spin "Prefetching neovim setup configuration.."
@ -176,16 +159,6 @@
throw "Clone failed!" throw "Clone failed!"
pen "${err:-}" pen "${err:-}"
fi fi
spin bold yellow "Also sourcing config!"
if run --err err nvim --headless +q; then
line
check "Prefetching config was successfull"
else
throw "Prefetching has failed hard!"
pen "${err:-}"
fi
;; ;;
"pika's minimal config") "pika's minimal config")
local url="https://git.k4li.de/dotfiles/nvim-mini.git" local url="https://git.k4li.de/dotfiles/nvim-mini.git"
@ -199,23 +172,34 @@
throw "Clone failed!" throw "Clone failed!"
pen "${err:-}" pen "${err:-}"
fi fi
;;
none) exit 0 ;;
own)
local url err
seek url "What is the url for your neovim config?"
spin bold yellow "Also sourcing config!" spin yellow "Cloning your config!"
if run --err err nvim --headless +q; then if run --err err git clone --recursive --depth=1 $url "$HOME/.config/nvim"; then
line check "Cloned neovim config"
check "Prefetching config was successfull"
else else
throw "Prefetching has failed hard!" throw "Clone failed!"
pen "${err:-}" pen "${err:-}"
fi fi
;; ;;
none) return 0 ;;
*) *)
echo_error "Something failed HARD!" echo_error "Something failed HARD!"
return 69 exit 69
;; ;;
esac esac
fi fi
spin bold yellow "Also sourcing config!"
if run --err err nvim --headless +q; then
check "Prefetching config was successfull"
else
throw "Prefetching has failed hard!"
pen "${err:-}"
fi
} }
main() { main() {
@ -233,7 +217,20 @@
checkAndInitConfig </dev/tty checkAndInitConfig </dev/tty
} }
if getImports "https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh" && getImports "https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh"; then 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
if ! command_exists pkg-install && ! command_exists checkAndInstall; then
source-script $pika
fi
if ! command_exists pen && ! command_exists spin; then
source-script $beddu
fi
}
if setup-env; then
# ─< package variable >─────────────────────────────────────────────────────────────────── # ─< package variable >───────────────────────────────────────────────────────────────────
unset PACKAGE unset PACKAGE
@ -261,6 +258,6 @@
main </dev/tty main </dev/tty
fi fi
echo_note "Cleaning up old $cloneDir directory.." pen grey bold "Cleaning up old $cloneDir directory.."
rm -rf "$cloneDir" rm -rf "$cloneDir"
} }