Testing new logic..

This commit is contained in:
pika 2025-05-24 13:40:22 +02:00
parent c75b6b41b2
commit 0ad00ad5d1

View file

@ -6,37 +6,37 @@
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
} }
# WHY: source-script() {
# This import will give you the following variables: local url="$1"
# _sudo="sudo -E" <- only if non root user
# distro = <distro name, like 'arch', 'debian', 'fedora'..>
# arch = bool
# fedora = bool
# opensuse = bool....
# You can then use it for, `if $arch; then`
# Also this gives you the _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..
getImports() {
local url="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh"
local import="$(mktemp)" 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" # ─< if $1 is a local file, source this one instead >─────────────────────────────────────
sleep 0.2 if [ -f "$url" ]; then
rm "$import" source "$url"
sleep 0.1
return 0
else
# ─< if $1 is a url, grab it and source it, also deletes afterwards >─────────────────────
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"
echo "${BLUE}Sourcing external script:${NC} $url"
line
sleep 0.1
rm -f "$import"
fi
} }
getDependencies() { getDependencies() {
echo_info "Checking build dependencies.." pen bold blue "Checking build dependencies.."
# INFO: # INFO:
# ╭─────────────────────────────────────────────────────────────────────────╮ # ╭─────────────────────────────────────────────────────────────────────────╮
@ -65,10 +65,10 @@
declare -n pkgArray="${deps[$distro]}" declare -n pkgArray="${deps[$distro]}"
case "$distro" in case "$distro" in
debian | ubuntu | fedora | opensuse) checkAndInstall "${pkgArray[@]}" ;; debian | ubuntu | fedora | opensuse) check-and-install ${pkgArray[@]} ;;
*) *)
echo_warning "No dependencies for $distro.." pen bold yellow "No dependencies for $distro.."
echo_warning "Could be good, could be bad :):" pen bold yellow "Could be good, could be bad :):"
return 0 return 0
;; ;;
esac esac
@ -76,16 +76,16 @@
main() { main() {
if $silent; then if $silent; then
echo_warning "Executing script silently!" pen bold yellow "Executing script silently!"
fi fi
# if ! getDependencies; then # if ! getDependencies; then
# echo_error "Error when installing dependencies.." # echo-error "Error when installing dependencies.."
# fi # fi
case "$distro" in case "$distro" in
arch) arch)
_install zen-browser-bin pkg-install zen-browser-bin
;; ;;
*) *)
getDependencies getDependencies
@ -100,13 +100,14 @@
ARCH="aarch64" ARCH="aarch64"
;; ;;
*) *)
echo_error "❌ Unsupported architecture: $ARCH" >&2 echo-error "❌ Unsupported architecture: $ARCH" >&2
exit 1 exit 1
;; ;;
esac esac
cloneUrl="https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-${ARCH}.tar.xz" cloneUrl="https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-${ARCH}.tar.xz"
local tempDir="$(mktemp -d)" local tempDir="$(mktemp -d)"
if [ -d "$HOME/.local/bin/" ]; then if [ -d "$HOME/.local/bin/" ]; then
local zenDir="$HOME/.local/bin" local zenDir="$HOME/.local/bin"
else else
@ -117,47 +118,72 @@
fi fi
# cd "$zenDir" || mkdir -p "$zenDir" && cd "$zenDir" # cd "$zenDir" || mkdir -p "$zenDir" && cd "$zenDir"
cd "$tempDir" || mkdir -p "$tempDir" && cd "$tempDir" cd "$tempDir" || mkdir -p "$tempDir" && cd "$tempDir"
echo_info "Downloading .tar.xz from $cloneUrl" spin bold blue "Downloading .tar.xz from $cloneUrl"
local err out
if command_exists wget; then if command_exists wget; then
wget "$cloneUrl" if run --err err --out out wget "$cloneUrl"; then
check
else
throw-err
# pen bold yellow "OUT: ${out:-}"
# echo-error "${err:-}"
fi
elif command_exists curl; then elif command_exists curl; then
curl -fsSL "$cloneUrl" -o "zen.linux-${ARCH}.tar.xz"
if run --err err --out out curl -fsSL "$cloneUrl" -o "zen.linux-${ARCH}.tar.xz"; then
check
else
throw-err
# pen bold yellow "OUT: ${out:-}"
# echo-error "${err:-}"
fi
# curl -fsSL "$cloneUrl" -o "zen.linux-${ARCH}.tar.xz"
else else
echo-error "curl/wget is required but missing.."
exit 69 exit 69
echo_error "curl/wget is required but missing.."
fi fi
echo_info "Extracting archive.." spin bold blue "Extracting archive.."
run tar -xf "./zen.linux-${ARCH}.tar.xz" -C "$zenDir" if run tar -xf "./zen.linux-${ARCH}.tar.xz" -C "$zenDir"; then
check "Extracted archive.."
else
throw-err
# pen bold yellow "OUT: ${out:-}"
# echo-error "${err:-}"
fi
echo_info "Installing to /bin/zen-browser" pen bold blue "Installing to /bin/zen-browser"
$_sudo ln -fsr "$zenDir/zen/zen-bin" /bin/zen-browser $_sudo ln -fsr "$zenDir/zen/zen-bin" /bin/zen-browser
;; ;;
esac esac
} }
# setup() { # WHY:
# if getImports; then # This import will give you the following variables:
# case "$@" in # _sudo="sudo -E" <- only if non root user
# --silent | -s) # distro = <distro name, like 'arch', 'debian', 'fedora'..>
# silent=true # arch = bool
# echo_warning "Running script silently!" # fedora = bool
# ;; # opensuse = bool....
# *) # You can then use it for, `if $arch; then`
# silent=false # Also this gives you the pkg-install command, which installs a package pased on the packagemanager/distro used.
# ;; # CAUTION:
# esac # This only wokrs for generic package names, like neovim, or vim, or tmux etc..
# fi # not every package packagemanager has the same packagenames for their packages..
# setup-env() {
# if ! command_exists zen-browser; then # local beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh
# return 0 # local pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh
# else local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
# echo_error "zen-browser does already exist on this machine!"
# return 69
# fi
# }
if getImports; then 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 >─────────────────────────────────────────────────────────────────── # ─< package variable >───────────────────────────────────────────────────────────────────
unset PACKAGE unset PACKAGE
@ -168,8 +194,8 @@
PACKAGE=zen-browser PACKAGE=zen-browser
if command_exists "$PACKAGE"; then if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!" pen bold yellow "$PACKAGE is already installed!"
echo_warning "Exiting now!" pen bold yellow "Exiting now!"
exit 69 exit 69
fi fi