From acae6216d0325c754af39fb298e565a16aee2742 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 8 Sep 2024 19:39:30 +0200 Subject: [PATCH] mv --- spcd/bootstrap.sh | 242 +++++++++++++++++++++++----------------------- 1 file changed, 123 insertions(+), 119 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index f4c2c03..e2913d6 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -836,6 +836,129 @@ spcd_python_pip() { fi } +# ╭───┬──────────────────────╮ +# │ f │ pm = package manager │ +# ╰───┴──────────────────────╯ + +# ╭───┬────┬───────╮ +# │ f │ pm │ https │ +# ╰───┴────┴───────╯ + +spcd_f_pm_https_path() { + case "${SPCD_PM}" in + "${SPCD_PM_APK}") echo "/etc/apk/repositories.d/https" ;; + "${SPCD_PM_APT}") echo "/etc/apt/apt.conf.d/https" ;; + "${SPCD_PM_DNF}") echo "/etc/dnf/dnf.conf.d/https.conf" ;; + "${SPCD_PM_PACMAN}") echo "/etc/pacman.d/https.conf" ;; + "${SPCD_PM_ZYPPER}") ;; + *) ;; + esac +} + +spcd_f_pm_https_trust() { + spcd_step "Trust" + local path text + if [ -n "${SPCD_CA_1}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then + path="$(spcd_f_pm_https_path)" + if [ -n "${path}" ]; then + spcd_os_mkdir "$(dirname "${path}")" + case "${SPCD_PM}" in + "${SPCD_PM_APK}") text="\ +--no-verify +" ;; + "${SPCD_PM_APT}") text="\ +Acquire::https::Verify-Peer False; +" ;; + "${SPCD_PM_DNF}") text="\ +sslverify=False +" ;; + "${SPCD_PM_PACMAN}") text="\ +SSLVerify = No +" ;; + "${SPCD_PM_ZYPPER}") ;; + *) ;; + esac + [ -n "${text}" ] && + spcd_os_write "${path}" "${text}" + fi + fi +} + +spcd_f_pm_https_verify() { + spcd_step "Verify" + local path + path="$(spcd_f_pm_https_path)" + if [ -n "${path}" ]; then + spcd_os_rm "${path}" + fi +} + +# ╭───┬────┬─────╮ +# │ f │ pm │ pkg │ +# ╰───┴────┴─────╯ + +spcd_f_pm_pkg_clean() { + case "${SPCD_PM}" in + "${SPCD_PM_APK}") spcd_run apk cache purge ;; + "${SPCD_PM_APT}") spcd_run apt-get clean ;; + "${SPCD_PM_DNF}") spcd_run dnf clean all ;; + "${SPCD_PM_PACMAN}") spcd_run pacman --sync --clean --noconfirm ;; + "${SPCD_PM_ZYPPER}") spcd_run zypper clean ;; + *) ;; + esac +} + +spcd_f_pm_pkg_install() { + case "${SPCD_PM}" in + "${SPCD_PM_APK}") spcd_run apk add "${1}" ;; + "${SPCD_PM_APT}") spcd_run apt-get install --assume-yes "${1}" ;; + "${SPCD_PM_DNF}") spcd_run dnf install --assumeyes "${1}" ;; + "${SPCD_PM_PACMAN}") spcd_run pacman --sync --noconfirm "${1}" ;; + "${SPCD_PM_ZYPPER}") spcd_run zypper --non-interactive install "${1}" ;; + *) ;; + esac + spcd_f_pm_pkg_clean +} + +spcd_f_pm_pkg_query() { + case "${SPCD_PM}" in + "${SPCD_PM_APK}") apk info "${1}" ;; + "${SPCD_PM_APT}") dpkg-query --show "${1}" ;; + "${SPCD_PM_DNF}") rpm --query "${1}" ;; + "${SPCD_PM_PACMAN}") pacman --query "${1}" ;; + "${SPCD_PM_ZYPPER}") rpm --query "${1}" ;; + *) ;; + esac +} + +spcd_f_pm_pkg_update() { + spcd_step "Update" + case "${SPCD_PM}" in + "${SPCD_PM_APK}") spcd_run apk update ;; + "${SPCD_PM_APT}") spcd_run apt-get update ;; + "${SPCD_PM_DNF}") spcd_run dnf makecache ;; + "${SPCD_PM_PACMAN}") spcd_run pacman --sync --refresh ;; + "${SPCD_PM_ZYPPER}") spcd_run zypper refresh ;; + *) ;; + esac +} + +spcd_f_pm_pkg_upgrade() { + spcd_step "Upgrade" + case "${SPCD_PM}" in + "${SPCD_PM_APK}") spcd_run apk upgrade ;; + "${SPCD_PM_APT}") spcd_run apt-get upgrade --assume-yes ;; + "${SPCD_PM_DNF}") spcd_run dnf upgrade --assumeyes ;; + "${SPCD_PM_PACMAN}") spcd_run pacman --sync --sysupgrade --noconfirm ;; + "${SPCD_PM_ZYPPER}") spcd_run zypper --non-interactive update ;; + *) ;; + esac +} + +# ╭───┬─────╮ +# │ f │ txt │ +# ╰───┴─────╯ + spcd_txt_locale() { local action="${1}" local chosen="${2}" @@ -989,125 +1112,6 @@ ${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET} esac } -# ╭───┬──────────────────────╮ -# │ f │ pm = package manager │ -# ╰───┴──────────────────────╯ - -# ╭───┬────┬───────╮ -# │ f │ pm │ https │ -# ╰───┴────┴───────╯ - -spcd_f_pm_https_path() { - case "${SPCD_PM}" in - "${SPCD_PM_APK}") echo "/etc/apk/repositories.d/https" ;; - "${SPCD_PM_APT}") echo "/etc/apt/apt.conf.d/https" ;; - "${SPCD_PM_DNF}") echo "/etc/dnf/dnf.conf.d/https.conf" ;; - "${SPCD_PM_PACMAN}") echo "/etc/pacman.d/https.conf" ;; - "${SPCD_PM_ZYPPER}") ;; - *) ;; - esac -} - -spcd_f_pm_https_trust() { - spcd_step "Trust" - local path text - if [ -n "${SPCD_CA_1}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then - path="$(spcd_f_pm_https_path)" - if [ -n "${path}" ]; then - spcd_os_mkdir "$(dirname "${path}")" - case "${SPCD_PM}" in - "${SPCD_PM_APK}") text="\ ---no-verify -" ;; - "${SPCD_PM_APT}") text="\ -Acquire::https::Verify-Peer False; -" ;; - "${SPCD_PM_DNF}") text="\ -sslverify=False -" ;; - "${SPCD_PM_PACMAN}") text="\ -SSLVerify = No -" ;; - "${SPCD_PM_ZYPPER}") ;; - *) ;; - esac - [ -n "${text}" ] && - spcd_os_write "${path}" "${text}" - fi - fi -} - -spcd_f_pm_https_verify() { - spcd_step "Verify" - local path - path="$(spcd_f_pm_https_path)" - if [ -n "${path}" ]; then - spcd_os_rm "${path}" - fi -} - -# ╭───┬────┬─────╮ -# │ f │ pm │ pkg │ -# ╰───┴────┴─────╯ - -spcd_f_pm_pkg_clean() { - case "${SPCD_PM}" in - "${SPCD_PM_APK}") spcd_run apk cache purge ;; - "${SPCD_PM_APT}") spcd_run apt-get clean ;; - "${SPCD_PM_DNF}") spcd_run dnf clean all ;; - "${SPCD_PM_PACMAN}") spcd_run pacman --sync --clean --noconfirm ;; - "${SPCD_PM_ZYPPER}") spcd_run zypper clean ;; - *) ;; - esac -} - -spcd_f_pm_pkg_install() { - case "${SPCD_PM}" in - "${SPCD_PM_APK}") spcd_run apk add "${1}" ;; - "${SPCD_PM_APT}") spcd_run apt-get install --assume-yes "${1}" ;; - "${SPCD_PM_DNF}") spcd_run dnf install --assumeyes "${1}" ;; - "${SPCD_PM_PACMAN}") spcd_run pacman --sync --noconfirm "${1}" ;; - "${SPCD_PM_ZYPPER}") spcd_run zypper --non-interactive install "${1}" ;; - *) ;; - esac - spcd_f_pm_pkg_clean -} - -spcd_f_pm_pkg_query() { - case "${SPCD_PM}" in - "${SPCD_PM_APK}") apk info "${1}" ;; - "${SPCD_PM_APT}") dpkg-query --show "${1}" ;; - "${SPCD_PM_DNF}") rpm --query "${1}" ;; - "${SPCD_PM_PACMAN}") pacman --query "${1}" ;; - "${SPCD_PM_ZYPPER}") rpm --query "${1}" ;; - *) ;; - esac -} - -spcd_f_pm_pkg_update() { - spcd_step "Update" - case "${SPCD_PM}" in - "${SPCD_PM_APK}") spcd_run apk update ;; - "${SPCD_PM_APT}") spcd_run apt-get update ;; - "${SPCD_PM_DNF}") spcd_run dnf makecache ;; - "${SPCD_PM_PACMAN}") spcd_run pacman --sync --refresh ;; - "${SPCD_PM_ZYPPER}") spcd_run zypper refresh ;; - *) ;; - esac -} - -spcd_f_pm_pkg_upgrade() { - spcd_step "Upgrade" - case "${SPCD_PM}" in - "${SPCD_PM_APK}") spcd_run apk upgrade ;; - "${SPCD_PM_APT}") spcd_run apt-get upgrade --assume-yes ;; - "${SPCD_PM_DNF}") spcd_run dnf upgrade --assumeyes ;; - "${SPCD_PM_PACMAN}") spcd_run pacman --sync --sysupgrade --noconfirm ;; - "${SPCD_PM_ZYPPER}") spcd_run zypper --non-interactive update ;; - *) ;; - esac -} - # ╭───┬─────╮ # │ s │ dns │ # ╰───┴─────╯