gettin the filecheck inplace
This commit is contained in:
parent
61fa8a8509
commit
934933c058
1 changed files with 58 additions and 9 deletions
67
dream.sh
67
dream.sh
|
@ -80,7 +80,7 @@ echo_pkg() {
|
||||||
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}-install:${NC}${BRIGHT_GREEN} Installing $PACKAGE now!${NC}"
|
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}-install:${NC}${BRIGHT_GREEN} Installing $PACKAGE now!${NC}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}:${NC}${YELLOW} $1 ${NC}"
|
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}:${NC}${BOLD}${BRIGHT_YELLOW} $1 ${NC}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
|
@ -120,6 +120,54 @@ run-silent() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup-dependencies() {
|
||||||
|
local arr=("$@")
|
||||||
|
local pkg_installable pkg_not_installable pkg
|
||||||
|
|
||||||
|
# echo ${arr[@]}
|
||||||
|
|
||||||
|
for pkg in "${arr[@]}"; do
|
||||||
|
case "$distro" in
|
||||||
|
debian | ubuntu)
|
||||||
|
if apt-cache show $pkg >/dev/null 2>&1; then
|
||||||
|
pkg_installable+=("$pkg")
|
||||||
|
else
|
||||||
|
pkg_not_installable+=("$pkg")
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
arch)
|
||||||
|
if pacman -Si $pkg >/dev/null 2>&1; then
|
||||||
|
pkg_installable+=("$pkg")
|
||||||
|
elif paru -Si $pkg >/dev/null 2>&1 || yay -Si $pkg >/dev/null 2>&1; then
|
||||||
|
pkg_installable+=("$pkg")
|
||||||
|
else
|
||||||
|
pkg_not_installable+=("$pkg")
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
fedora)
|
||||||
|
if dnf --cacheonly list --available --exact "$pkg" >/dev/null 2>&1; then
|
||||||
|
pkg_installable+=("$pkg")
|
||||||
|
else
|
||||||
|
pkg_not_installable+=("$pkg")
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
opensuse)
|
||||||
|
if zypper --no-refresh info "$pkg" &>/dev/null; then
|
||||||
|
pkg_installable+=("$pkg")
|
||||||
|
else
|
||||||
|
pkg_not_installable+=("$pkg")
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 69
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "green ${pkg_installable[@]}"
|
||||||
|
echo "red ${pkg_not_installable[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
# if given an array, it checks if the command is available, and if not - installs all packages in that array one by one
|
# if given an array, it checks if the command is available, and if not - installs all packages in that array one by one
|
||||||
check-and-install() {
|
check-and-install() {
|
||||||
local package_group=("$@")
|
local package_group=("$@")
|
||||||
|
@ -155,6 +203,7 @@ check-and-install() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# check and removes items inside an array
|
# check and removes items inside an array
|
||||||
check-and-remove() {
|
check-and-remove() {
|
||||||
local pkglength="${#@}"
|
local pkglength="${#@}"
|
||||||
|
@ -187,7 +236,7 @@ check-and-remove() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||||
check_env() {
|
check-environment() {
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
if command-exists sudo; then
|
if command-exists sudo; then
|
||||||
_sudo="sudo -E"
|
_sudo="sudo -E"
|
||||||
|
@ -317,7 +366,7 @@ _setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||||
get_packager() {
|
get-packager-variables() {
|
||||||
# ─< define fallback function >───────────────────────────────────────────────────────────
|
# ─< define fallback function >───────────────────────────────────────────────────────────
|
||||||
fallback() {
|
fallback() {
|
||||||
local pkger=""
|
local pkger=""
|
||||||
|
@ -440,7 +489,7 @@ get_packager() {
|
||||||
# │ Automated setup for refreshing repositories and overall getting the variables to setup │
|
# │ Automated setup for refreshing repositories and overall getting the variables to setup │
|
||||||
# ╰────────────────────────────────────────────────────────────────────────────────────────╯
|
# ╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
dist_setup() {
|
distro-setup() {
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
debian)
|
debian)
|
||||||
repen bold "Found $(pen red bold $distro)"
|
repen bold "Found $(pen red bold $distro)"
|
||||||
|
@ -975,12 +1024,12 @@ seek() {
|
||||||
# NOTE:
|
# NOTE:
|
||||||
# ──────────────────────────────────────< end beddu >────────────────────────────────────
|
# ──────────────────────────────────────< end beddu >────────────────────────────────────
|
||||||
|
|
||||||
if check_env; then
|
if check-environment; then
|
||||||
# ─< gets the some variables like $aur, $debian, $ubuntu, $distro... >────────────────────
|
# ─< gets the some variables like $aur, $debian, $ubuntu, $distro... >────────────────────
|
||||||
get_packager
|
get-packager-variables
|
||||||
|
|
||||||
# ─< get more indepths variables like $trixie, $bookworm, $jammy, $fedora_40.. >──────────
|
# ─< get more indepths variables like $trixie, $bookworm, $jammy, $fedora_40.. >──────────
|
||||||
dist_setup
|
distro-setup
|
||||||
|
|
||||||
# WHY:
|
# WHY:
|
||||||
# ╭─────────────────────────────────────────────────────────────────────────╮
|
# ╭─────────────────────────────────────────────────────────────────────────╮
|
||||||
|
@ -989,8 +1038,8 @@ if check_env; then
|
||||||
# ╰─────────────────────────────────────────────────────────────────────────╯
|
# ╰─────────────────────────────────────────────────────────────────────────╯
|
||||||
pikaCheckFile="$HOME/.cache/pika_script_detection"
|
pikaCheckFile="$HOME/.cache/pika_script_detection"
|
||||||
|
|
||||||
if [ ! -f "$pikaCheckFile" ]; then
|
if ! checkFileAge "$pikaCheckFile"; then
|
||||||
pen bold grey "First time importing.."
|
pen bold grey "Updating sources.."
|
||||||
|
|
||||||
if update-package-list; then
|
if update-package-list; then
|
||||||
silentexec touch "$pikaCheckFile"
|
silentexec touch "$pikaCheckFile"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue