2024-04-27 15:47:23 +00:00
|
|
|
#! /usr/bin/env sh
|
2024-04-26 13:38:22 +00:00
|
|
|
|
2024-05-02 08:27:18 +00:00
|
|
|
# defaults
|
2024-08-19 12:27:10 +00:00
|
|
|
[ -n "${SPCD_CMD_SUM}" ] || SPCD_CMD_SUM="sha512sum"
|
2024-08-06 10:53:23 +00:00
|
|
|
[ -n "${SPCD_DNS_1}" ] || SPCD_DNS_1="9.9.9.9"
|
2024-06-27 11:58:43 +00:00
|
|
|
[ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd"
|
|
|
|
[ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx"
|
2024-08-21 14:46:48 +00:00
|
|
|
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
|
2024-08-24 13:12:13 +00:00
|
|
|
[ -n "${SPCD_REF_FEATURE}" ] || SPCD_REF_FEATURE="f"
|
|
|
|
[ -n "${SPCD_REF_RELEASE}" ] || SPCD_REF_RELEASE="main"
|
|
|
|
[ -n "${SPCD_REF_STAGING}" ] || SPCD_REF_STAGING="dev"
|
2024-08-24 14:11:41 +00:00
|
|
|
[ -n "${SPCD_URL_ALPINE}" ] ||
|
|
|
|
SPCD_URL_ALPINE="https://dl-cdn.alpinelinux.org"
|
|
|
|
[ -n "${SPCD_URL_ARCH}" ] ||
|
|
|
|
SPCD_URL_ARCH="https://geo.mirror.pkgbuild.com"
|
|
|
|
[ -n "${SPCD_URL_DEBIAN}" ] ||
|
|
|
|
SPCD_URL_DEBIAN="https://deb.debian.org"
|
|
|
|
[ -n "${SPCD_URL_EPEL}" ] ||
|
|
|
|
SPCD_URL_EPEL="https://dl.fedoraproject.org"
|
|
|
|
[ -n "${SPCD_URL_FEDORA}" ] ||
|
|
|
|
SPCD_URL_FEDORA="https://rpmfind.net"
|
|
|
|
[ -n "${SPCD_URL_OPENSUSE}" ] ||
|
|
|
|
SPCD_URL_OPENSUSE="https://download.opensuse.org"
|
|
|
|
[ -n "${SPCD_URL_PYTHON}" ] ||
|
|
|
|
SPCD_URL_PYTHON="https://pypi.org/simple"
|
|
|
|
[ -n "${SPCD_URL_ROCKY}" ] ||
|
|
|
|
SPCD_URL_ROCKY="https://dl.rockylinux.org"
|
|
|
|
[ -n "${SPCD_URL_UBUNTU}" ] ||
|
|
|
|
SPCD_URL_UBUNTU="https://ubuntu.mirrors.ovh.net"
|
2024-04-26 11:38:38 +00:00
|
|
|
|
2024-08-24 14:54:07 +00:00
|
|
|
# ╭───────╮
|
|
|
|
# │ steps │
|
|
|
|
# ╰───────╯
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_main() {
|
2024-08-24 14:54:07 +00:00
|
|
|
# env
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_set_environment_variables
|
|
|
|
spcd_list_working_directory
|
2024-08-24 14:54:07 +00:00
|
|
|
# pkg
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_set_packages_repositories
|
|
|
|
spcd_set_packages_configuration
|
|
|
|
#
|
|
|
|
spcd_set_https_verification_off
|
|
|
|
spcd_set_dns_resolving
|
|
|
|
spcd_update_packages_catalog
|
|
|
|
spcd_install_packages_tools
|
2024-08-24 15:11:03 +00:00
|
|
|
# ca
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_install_ca_certificates
|
|
|
|
spcd_write_ca_certificates
|
|
|
|
spcd_update_ca_certificates
|
2024-08-24 15:11:03 +00:00
|
|
|
# pkg
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_set_https_verification_on
|
|
|
|
spcd_update_packages_catalog
|
|
|
|
spcd_upgrade_packages
|
|
|
|
spcd_install_dos2unix
|
|
|
|
spcd_install_git
|
2024-08-24 15:11:03 +00:00
|
|
|
# python
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_install_python
|
|
|
|
spcd_install_python_modules
|
|
|
|
spcd_install_packages
|
|
|
|
spcd_write_python_module
|
|
|
|
spcd_switch_to_python
|
2024-04-27 15:36:14 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 14:54:07 +00:00
|
|
|
# ╭───────┬─────╮
|
|
|
|
# │ steps │ env │
|
|
|
|
# ╰───────┴─────╯
|
2024-06-24 06:10:47 +00:00
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_set_environment_variables() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Set environment variables"
|
|
|
|
# check script first
|
|
|
|
[ -n "${SPCD}" ] || spcd_error_ci "SPCD"
|
|
|
|
# continuous integration / github → gitea → forgejo
|
|
|
|
if [ -n "${GITHUB_ACTIONS}" ]; then
|
|
|
|
# project branch
|
|
|
|
if [ -n "${GITHUB_REF_NAME}" ]; then
|
|
|
|
SPCD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
|
|
|
else
|
|
|
|
spcd_error_ci "GITHUB_REF_NAME"
|
|
|
|
fi
|
|
|
|
# project root
|
|
|
|
if [ -n "${GITHUB_SERVER_URL}" ]; then
|
|
|
|
SPCD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
|
|
|
|
[ -n "${GITHUB_TOKEN}" ] &&
|
|
|
|
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}${GITHUB_TOKEN}@"
|
|
|
|
SPCD_PROJECT_ROOT="\
|
2024-07-22 09:58:37 +00:00
|
|
|
${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
2024-08-19 08:35:27 +00:00
|
|
|
else
|
|
|
|
spcd_error_ci "GITHUB_SERVER_URL"
|
|
|
|
fi
|
|
|
|
# project path & name
|
|
|
|
if [ -n "${GITHUB_REPOSITORY}" ]; then
|
|
|
|
# project path
|
|
|
|
SPCD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
|
|
|
|
# project name
|
|
|
|
SPCD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
|
|
|
else
|
|
|
|
spcd_error_ci "GITHUB_REPOSITORY"
|
|
|
|
fi
|
|
|
|
# continuous integration / gitlab
|
|
|
|
elif [ -n "${GITLAB_CI}" ]; then
|
|
|
|
# project branch
|
|
|
|
if [ -n "${CI_COMMIT_BRANCH}" ]; then
|
|
|
|
SPCD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_COMMIT_BRANCH"
|
|
|
|
fi
|
|
|
|
# project root / protocol
|
|
|
|
if [ -n "${CI_SERVER_PROTOCOL}" ]; then
|
|
|
|
# project root / login
|
|
|
|
if [ -n "${CI_REGISTRY_USER}" ]; then
|
|
|
|
# project root / password
|
|
|
|
if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
|
|
|
|
# project root / host
|
|
|
|
if [ -n "${CI_SERVER_FQDN}" ]; then
|
|
|
|
# project root
|
|
|
|
SPCD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
|
2024-07-19 19:59:09 +00:00
|
|
|
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
|
2024-08-19 08:35:27 +00:00
|
|
|
# project path
|
|
|
|
if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
|
|
|
|
SPCD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
|
|
|
|
# project name
|
|
|
|
if [ -n "${CI_PROJECT_NAME}" ]; then
|
|
|
|
SPCD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_PROJECT_NAME"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_PROJECT_NAMESPACE"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_SERVER_FQDN"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_REGISTRY_PASSWORD"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_REGISTRY_USER"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
spcd_error_ci "CI_SERVER_PROTOCOL"
|
|
|
|
fi
|
|
|
|
# continuous integration / unsupported
|
|
|
|
else
|
|
|
|
spcd_error_ci "ø"
|
|
|
|
fi
|
|
|
|
# check project variables
|
|
|
|
case "${SPCD_PROJECT_BRANCH}" in
|
2024-08-24 14:10:36 +00:00
|
|
|
"${SPCD_REF_RELEASE}" | \
|
|
|
|
"${SPCD_REF_STAGING}" | \
|
|
|
|
"${SPCD_REF_FEATURE}") ;;
|
2024-08-19 08:35:27 +00:00
|
|
|
*) spcd_error_ci "SPCD_PROJECT_BRANCH" ;;
|
|
|
|
esac
|
|
|
|
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
|
|
|
|
[ -n "${SPCD_PROJECT_PATH}" ] || spcd_error_ci "SPCD_PROJECT_PATH"
|
|
|
|
[ -n "${SPCD_PROJECT_NAME}" ] || spcd_error_ci "SPCD_PROJECT_NAME"
|
|
|
|
#
|
|
|
|
spcd_echo "SPCD_PROJECT_BRANCH" \
|
|
|
|
"SPCD_PROJECT_ROOT" "SPCD_PROJECT_PATH" "SPCD_PROJECT_NAME"
|
|
|
|
# set path
|
|
|
|
SPCD_PATH="$(realpath "${0}")"
|
|
|
|
spcd_echo "SPCD_PATH"
|
|
|
|
# set operating system id
|
|
|
|
SPCD_OS_ID="$(spcd_grep_os ID)"
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"almalinux") SPCD_OS_ID="${SPCD_OS_ALMA}" ;;
|
|
|
|
"alpine") SPCD_OS_ID="${SPCD_OS_ALPINE}" ;;
|
|
|
|
"arch") SPCD_OS_ID="${SPCD_OS_ARCH}" ;;
|
|
|
|
"debian") SPCD_OS_ID="${SPCD_OS_DEBIAN}" ;;
|
|
|
|
"fedora") SPCD_OS_ID="${SPCD_OS_FEDORA}" ;;
|
2024-08-20 06:27:15 +00:00
|
|
|
"opensuse-leap") SPCD_OS_ID="${SPCD_OS_OPENSUSE}" ;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"rocky") SPCD_OS_ID="${SPCD_OS_ROCKY}" ;;
|
|
|
|
"ubuntu") SPCD_OS_ID="${SPCD_OS_UBUNTU}" ;;
|
|
|
|
*) spcd_error_os "SPCD_OS_ID" ;;
|
|
|
|
esac
|
|
|
|
# set operating system version
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}" | \
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
SPCD_OS_VERSION=$(spcd_grep_os VERSION_ID |
|
|
|
|
sed "s|^\([0-9]\+\)\..*|\1|")
|
|
|
|
;;
|
2024-08-20 06:27:15 +00:00
|
|
|
"${SPCD_OS_ALPINE}" | "${SPCD_OS_OPENSUSE}")
|
2024-08-19 08:35:27 +00:00
|
|
|
SPCD_OS_VERSION=$(spcd_grep_os VERSION_ID |
|
|
|
|
sed "s|^\([0-9]\+\.[0-9]\+\)\..*|\1|")
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
|
|
|
SPCD_OS_VERSION="$(spcd_grep_os VERSION_CODENAME)"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
# check operating system version
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"9" | "8") ;;
|
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"3.20" | "3.19") ;;
|
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
2024-08-20 20:12:30 +00:00
|
|
|
"20240818" | "20240101") ;;
|
2024-08-19 08:35:27 +00:00
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
2024-08-20 20:12:30 +00:00
|
|
|
"bookworm" | "bullseye") ;;
|
2024-08-19 08:35:27 +00:00
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_FEDORA}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"40" | "39") ;;
|
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
2024-08-20 06:27:15 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"15.6" | "15.5") ;;
|
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_OS_UBUNTU}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"noble" | "jammy") ;;
|
|
|
|
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_OS_ID" "SPCD_OS_VERSION"
|
|
|
|
# universal
|
|
|
|
SPCD_DNS_FILE="/etc/resolv.conf"
|
|
|
|
SPCD_PKG_CA="ca-certificates"
|
|
|
|
SPCD_PKG_DOS2UNIX="dos2unix"
|
|
|
|
SPCD_PKG_GIT="git"
|
|
|
|
SPCD_PYTHON_ALIAS="python3"
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_DNS_FILE" \
|
|
|
|
"SPCD_PKG_CA" "SPCD_PKG_DOS2UNIX" "SPCD_PKG_GIT" "SPCD_PYTHON_ALIAS"
|
|
|
|
# set ca command & root
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
|
|
|
|
SPCD_CA_ROOT="/etc/pki/ca-trust/source/anchors"
|
|
|
|
SPCD_CMD_CA="update-ca-trust"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
SPCD_CA_ROOT="/usr/local/share/ca-certificates"
|
|
|
|
SPCD_CMD_CA="update-ca-certificates"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
SPCD_CA_ROOT="/etc/ca-certificates/trust-source/anchors"
|
|
|
|
SPCD_CMD_CA="update-ca-trust"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
|
|
|
SPCD_CA_ROOT="/usr/local/share/ca-certificates"
|
|
|
|
SPCD_CMD_CA="update-ca-certificates"
|
|
|
|
;;
|
2024-08-20 06:36:22 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
|
|
|
SPCD_CA_ROOT="/etc/pki/trust/anchors"
|
|
|
|
SPCD_CMD_CA="update-ca-certificates"
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_CA_ROOT" "SPCD_CMD_CA"
|
|
|
|
# set package manager
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
SPCD_PM="${SPCD_PM_APK}"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
|
|
|
SPCD_PM="${SPCD_PM_APT}"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
|
|
|
|
SPCD_PM="${SPCD_PM_DNF}"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
SPCD_PM="${SPCD_PM_PACMAN}"
|
|
|
|
;;
|
2024-08-20 06:36:22 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
|
|
|
SPCD_PM="${SPCD_PM_ZYPPER}"
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
*) ;;
|
|
|
|
esac
|
2024-08-21 11:52:38 +00:00
|
|
|
# set package format
|
|
|
|
case "${SPCD_PM}" in
|
|
|
|
"${SPCD_PM_APK}")
|
|
|
|
SPCD_PF="${SPCD_PF_APK}"
|
|
|
|
;;
|
|
|
|
"${SPCD_PM_APT}")
|
|
|
|
SPCD_PF="${SPCD_PF_DEB}"
|
|
|
|
;;
|
|
|
|
"${SPCD_PM_PACMAN}")
|
|
|
|
SPCD_PF="${SPCD_PF_PKG}"
|
|
|
|
;;
|
|
|
|
"${SPCD_PM_DNF}" | "${SPCD_PM_ZYPPER}")
|
|
|
|
SPCD_PF="${SPCD_PF_RPM}"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
# set package manager variables
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_split
|
2024-08-21 11:54:47 +00:00
|
|
|
spcd_echo "SPCD_PF" "SPCD_PM"
|
2024-08-19 08:35:27 +00:00
|
|
|
case "${SPCD_PM}" in
|
|
|
|
"${SPCD_PM_DNF}")
|
|
|
|
SPCD_PM_CLEAN="dnf clean all"
|
|
|
|
SPCD_PM_INSTALL="dnf install --assumeyes"
|
|
|
|
SPCD_PM_QUERY="rpm --query"
|
|
|
|
SPCD_PM_UPDATE="dnf makecache"
|
|
|
|
SPCD_PM_UPGRADE="dnf upgrade --assumeyes"
|
|
|
|
SPCD_PKG_PKG=""
|
|
|
|
SPCD_PM_CONF_PATH="/etc/dnf/dnf.conf"
|
|
|
|
SPCD_PM_CONF_TEXT="\
|
2024-05-04 16:16:12 +00:00
|
|
|
[main]
|
|
|
|
best=True
|
|
|
|
clean_requirements_on_remove=True
|
|
|
|
gpgcheck=1
|
|
|
|
installonly_limit=3
|
|
|
|
skip_if_unavailable=False
|
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
SPCD_PM_HTTPS_PATH="/etc/dnf/dnf.conf.d/https.conf"
|
|
|
|
SPCD_PM_HTTPS_TEXT="\
|
2024-06-03 19:00:28 +00:00
|
|
|
sslverify=False
|
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
"${SPCD_PM_APK}")
|
|
|
|
SPCD_PM_CLEAN="apk cache purge"
|
|
|
|
SPCD_PM_INSTALL="apk add"
|
|
|
|
SPCD_PM_QUERY="apk info"
|
|
|
|
SPCD_PM_UPDATE="apk update"
|
|
|
|
SPCD_PM_UPGRADE="apk upgrade"
|
|
|
|
SPCD_PKG_PKG=""
|
|
|
|
SPCD_PM_CONF_PATH=""
|
|
|
|
SPCD_PM_CONF_TEXT=""
|
|
|
|
SPCD_PM_HTTPS_PATH="/etc/apk/repositories.d/https"
|
|
|
|
SPCD_PM_HTTPS_TEXT="\
|
2024-06-03 19:00:28 +00:00
|
|
|
--no-verify
|
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
"${SPCD_PM_PACMAN}")
|
|
|
|
SPCD_PM_CLEAN="pacman --sync --clean --noconfirm"
|
|
|
|
SPCD_PM_INSTALL="pacman --sync --noconfirm"
|
|
|
|
SPCD_PM_QUERY="pacman --query"
|
|
|
|
SPCD_PM_UPDATE="pacman --sync --refresh"
|
|
|
|
SPCD_PM_UPGRADE="pacman --sync --sysupgrade --noconfirm"
|
|
|
|
SPCD_PKG_PKG=""
|
|
|
|
SPCD_PM_CONF_PATH=""
|
|
|
|
SPCD_PM_CONF_TEXT=""
|
|
|
|
SPCD_PM_HTTPS_PATH="/etc/pacman.d/https.conf"
|
|
|
|
SPCD_PM_HTTPS_TEXT="\
|
2024-06-03 19:00:28 +00:00
|
|
|
SSLVerify = No
|
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
"${SPCD_PM_APT}")
|
|
|
|
SPCD_PM_CLEAN="apt-get clean"
|
|
|
|
SPCD_PM_INSTALL="apt-get install --assume-yes"
|
|
|
|
SPCD_PM_QUERY="dpkg-query --show"
|
|
|
|
SPCD_PM_UPDATE="apt-get update"
|
|
|
|
SPCD_PM_UPGRADE="apt-get upgrade --assume-yes"
|
|
|
|
SPCD_PKG_PKG="apt-utils"
|
|
|
|
SPCD_PM_CONF_PATH="/etc/apt/apt.conf.d/apt.conf"
|
|
|
|
SPCD_PM_CONF_TEXT="\
|
2024-05-04 16:16:12 +00:00
|
|
|
Acquire::Check-Valid-Until True;
|
|
|
|
APT::Get::Show-Versions True;
|
|
|
|
APT::Install-Recommends False;
|
|
|
|
APT::Install-Suggests False;
|
|
|
|
Dir::Etc::SourceParts \"\";
|
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
SPCD_PM_HTTPS_PATH="/etc/apt/apt.conf.d/https"
|
|
|
|
SPCD_PM_HTTPS_TEXT="\
|
2024-06-03 19:00:28 +00:00
|
|
|
Acquire::https::Verify-Peer False;
|
2024-08-20 11:22:24 +00:00
|
|
|
"
|
|
|
|
;;
|
|
|
|
"${SPCD_PM_ZYPPER}")
|
|
|
|
SPCD_PM_CLEAN="zypper clean"
|
|
|
|
SPCD_PM_INSTALL="zypper --non-interactive install"
|
|
|
|
SPCD_PM_QUERY="rpm --query"
|
|
|
|
SPCD_PM_UPDATE="zypper refresh"
|
|
|
|
SPCD_PM_UPGRADE="zypper --non-interactive update"
|
|
|
|
SPCD_PKG_PKG=""
|
|
|
|
SPCD_PM_CONF_PATH=""
|
|
|
|
SPCD_PM_CONF_TEXT="\
|
|
|
|
"
|
|
|
|
SPCD_PM_HTTPS_PATH=""
|
|
|
|
SPCD_PM_HTTPS_TEXT="\
|
2024-06-03 19:00:28 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_PM_CLEAN" \
|
|
|
|
"SPCD_PM_INSTALL" "SPCD_PM_QUERY" "SPCD_PM_UPDATE" "SPCD_PM_UPGRADE"
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_PKG_PKG" "SPCD_PM_CONF_PATH" "SPCD_PM_HTTPS_PATH"
|
|
|
|
# specific
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}")
|
|
|
|
SPCD_URL_DEFAULT="https://repo.almalinux.org/almalinux"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
SPCD_URL_DEFAULT="https://dl-cdn.alpinelinux.org/alpine"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
SPCD_URL_DEFAULT="https://geo.mirror.pkgbuild.com"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}")
|
|
|
|
SPCD_URL_DEFAULT="http://deb.debian.org/debian"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_FEDORA}")
|
|
|
|
SPCD_URL_DEFAULT="http://download.example/pub/fedora/linux/releases"
|
|
|
|
;;
|
2024-08-20 09:31:15 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
|
|
|
SPCD_URL_DEFAULT="http://download.opensuse.org"
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_OS_ROCKY}")
|
|
|
|
SPCD_URL_DEFAULT="http://dl.rockylinux.org/\$contentdir"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_UBUNTU}")
|
|
|
|
SPCD_URL_DEFAULT="http://archive.ubuntu.com/ubuntu"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
SPCD_URL_CHOSEN="${SPCD_URL_DEFAULT}"
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}")
|
|
|
|
[ -n "${SPCD_URL_ALMA}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ALMA}"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
[ -n "${SPCD_URL_ALPINE}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ALPINE}"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
[ -n "${SPCD_URL_ARCH}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ARCH}"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}")
|
|
|
|
[ -n "${SPCD_URL_DEBIAN}" ] && SPCD_URL_CHOSEN="${SPCD_URL_DEBIAN}" ||
|
|
|
|
SPCD_URL_CHOSEN="https://deb.debian.org/debian"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_FEDORA}")
|
|
|
|
[ -n "${SPCD_URL_FEDORA}" ] && SPCD_URL_CHOSEN="${SPCD_URL_FEDORA}" ||
|
|
|
|
SPCD_URL_CHOSEN="https://rpmfind.net/linux/fedora/linux/releases"
|
|
|
|
;;
|
2024-08-20 09:40:16 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
2024-08-20 10:49:54 +00:00
|
|
|
[ -n "${SPCD_URL_OPENSUSE}" ] &&
|
|
|
|
SPCD_URL_CHOSEN="${SPCD_URL_OPENSUSE}" ||
|
2024-08-20 09:40:16 +00:00
|
|
|
SPCD_URL_CHOSEN="https://download.opensuse.org"
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_OS_ROCKY}")
|
|
|
|
[ -n "${SPCD_URL_ROCKY}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ROCKY}" ||
|
|
|
|
SPCD_URL_CHOSEN="https://dl.rockylinux.org/\$contentdir"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_UBUNTU}")
|
|
|
|
[ -n "${SPCD_URL_UBUNTU}" ] && SPCD_URL_CHOSEN="${SPCD_URL_UBUNTU}" ||
|
|
|
|
SPCD_URL_CHOSEN="https://ubuntu.mirrors.ovh.net/ubuntu"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_URL_DEFAULT" "SPCD_URL_CHOSEN"
|
|
|
|
# set python command & package
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}")
|
|
|
|
SPCD_PYTHON_COMMAND="python3.12"
|
|
|
|
SPCD_PYTHON_PACKAGE="python3.12"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"3.20") SPCD_PYTHON_COMMAND="python3.12" ;;
|
|
|
|
"3.19") SPCD_PYTHON_COMMAND="python3.11" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
SPCD_PYTHON_PACKAGE="python3"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
SPCD_PYTHON_COMMAND="python3.12"
|
|
|
|
SPCD_PYTHON_PACKAGE="python"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"bookworm") SPCD_PYTHON_COMMAND="python3.11" ;;
|
|
|
|
"bullseye") SPCD_PYTHON_COMMAND="python3.9" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
SPCD_PYTHON_PACKAGE="python3"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_FEDORA}")
|
2024-08-20 13:32:18 +00:00
|
|
|
SPCD_PYTHON_COMMAND="python3.12"
|
|
|
|
SPCD_PYTHON_PACKAGE="python3"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
2024-08-20 08:56:07 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"15.6")
|
|
|
|
SPCD_PYTHON_COMMAND="python3.12"
|
|
|
|
SPCD_PYTHON_PACKAGE="python312"
|
|
|
|
;;
|
|
|
|
"15.5")
|
|
|
|
SPCD_PYTHON_COMMAND="python3.11"
|
|
|
|
SPCD_PYTHON_PACKAGE="python311"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_OS_UBUNTU}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"noble") SPCD_PYTHON_COMMAND="python3.12" ;;
|
|
|
|
"jammy") SPCD_PYTHON_COMMAND="python3.10" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
SPCD_PYTHON_PACKAGE="python3"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_PYTHON_COMMAND" "SPCD_PYTHON_PACKAGE"
|
|
|
|
# set python packages
|
|
|
|
case "${SPCD_OS_ID}" in
|
2024-08-20 09:17:06 +00:00
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}" | \
|
|
|
|
"${SPCD_OS_OPENSUSE}")
|
2024-08-19 08:35:27 +00:00
|
|
|
SPCD_PYTHON_PACKAGES="/usr/lib64/${SPCD_PYTHON_COMMAND}/site-packages"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}" | "${SPCD_OS_ARCH}")
|
|
|
|
SPCD_PYTHON_PACKAGES="/usr/lib/${SPCD_PYTHON_COMMAND}/site-packages"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
|
|
|
SPCD_PYTHON_PACKAGES="/usr/lib/${SPCD_PYTHON_ALIAS}/dist-packages"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
SPCD_PYTHON_VENV_PACKAGES="\
|
2024-08-07 11:35:39 +00:00
|
|
|
${SPCD_PYTHON_VENV}/lib/${SPCD_PYTHON_COMMAND}/site-packages"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_split
|
|
|
|
spcd_echo "SPCD_PYTHON_PACKAGES" "SPCD_PYTHON_VENV_PACKAGES"
|
|
|
|
# variables
|
2024-08-23 14:13:32 +00:00
|
|
|
# certificate authorities
|
2024-08-19 08:35:27 +00:00
|
|
|
[ -n "${SPCD_CA_1}" ] && SPCD_CA=true
|
2024-08-23 14:13:32 +00:00
|
|
|
# downloads
|
|
|
|
SPCD_DL="$(mktemp --directory)"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_split
|
2024-08-23 14:13:32 +00:00
|
|
|
spcd_echo "SPCD_CA" "SPCD_DL"
|
2024-04-27 09:56:16 +00:00
|
|
|
}
|
|
|
|
|
2024-07-20 14:21:34 +00:00
|
|
|
spcd_list_working_directory() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "List working directory"
|
|
|
|
spcd_lwd__path="$(realpath .)"
|
|
|
|
spcd_ls "${spcd_lwd__path}"
|
2024-07-20 14:21:34 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 14:54:07 +00:00
|
|
|
# ╭───────┬─────╮
|
|
|
|
# │ steps │ pkg │
|
|
|
|
# ╰───────┴─────╯
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_set_packages_repositories() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Set packages repositories"
|
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"8") spcd_spr__file="/etc/yum.repos.d/almalinux.repo" ;;
|
|
|
|
"9") spcd_spr__file="/etc/yum.repos.d/almalinux-baseos.repo" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_sed "${spcd_spr__file}" \
|
|
|
|
"|^mirrorlist|# mirrorlist|" \
|
|
|
|
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \
|
|
|
|
"|^# baseurl|baseurl|"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_ALPINE}")
|
|
|
|
spcd_spr__file="/etc/apk/repositories"
|
|
|
|
spcd_write "${spcd_spr__file}" "\
|
2024-06-27 11:58:43 +00:00
|
|
|
${SPCD_URL_CHOSEN}/v${SPCD_OS_VERSION}/main
|
|
|
|
${SPCD_URL_CHOSEN}/v${SPCD_OS_VERSION}/community
|
2024-05-04 10:50:20 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
"${SPCD_OS_DEBIAN}")
|
|
|
|
spcd_spr__file="/etc/apt/sources.list"
|
|
|
|
spcd_write "${spcd_spr__file}" "\
|
2024-06-27 11:58:43 +00:00
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION} main
|
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-backports main
|
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-updates main
|
|
|
|
deb ${SPCD_URL_CHOSEN}-security ${SPCD_OS_VERSION}-security main
|
2024-05-03 19:03:07 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
2024-08-20 11:08:15 +00:00
|
|
|
"${SPCD_OS_OPENSUSE}")
|
|
|
|
for spcd_spr__file in \
|
|
|
|
"backports-update" \
|
|
|
|
"non-oss" \
|
|
|
|
"oss" \
|
|
|
|
"sle-update" \
|
|
|
|
"update-non-oss" \
|
|
|
|
"update" \
|
|
|
|
"openh264"; do
|
|
|
|
spcd_sed "/etc/zypp/repos.d/repo-${spcd_spr__file}.repo" \
|
|
|
|
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|"
|
|
|
|
done
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_OS_ROCKY}")
|
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"8") spcd_spr__file="/etc/yum.repos.d/Rocky-BaseOS.repo" ;;
|
|
|
|
"9") spcd_spr__file="/etc/yum.repos.d/rocky.repo" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
spcd_sed "${spcd_spr__file}" \
|
|
|
|
"|^mirrorlist|# mirrorlist|" \
|
|
|
|
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \
|
|
|
|
"|^#baseurl|baseurl|"
|
|
|
|
;;
|
|
|
|
"${SPCD_OS_UBUNTU}")
|
|
|
|
spcd_spr__file="/etc/apt/sources.list"
|
|
|
|
spcd_write "${spcd_spr__file}" "\
|
2024-07-22 08:50:58 +00:00
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION} main universe
|
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-backports main universe
|
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-updates main universe
|
|
|
|
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-security main universe
|
2024-05-04 21:47:31 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
2024-04-26 14:13:35 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_set_packages_configuration() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Set packages configuration"
|
|
|
|
spcd_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}"
|
|
|
|
case "${SPCD_OS_ID}" in
|
2024-08-19 20:13:59 +00:00
|
|
|
"${SPCD_OS_ARCH}")
|
|
|
|
pacman-key --init
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
|
|
|
export DEBIAN_FRONTEND="noninteractive"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
2024-05-04 20:36:30 +00:00
|
|
|
}
|
|
|
|
|
2024-05-03 21:19:30 +00:00
|
|
|
# agnostic steps
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_set_https_verification_off() {
|
2024-08-19 08:35:27 +00:00
|
|
|
if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
|
|
|
|
spcd_step "Set HTTPS verification off"
|
|
|
|
spcd_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")"
|
|
|
|
spcd_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}"
|
|
|
|
fi
|
2024-04-26 14:23:30 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_set_dns_resolving() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Set DNS resolving"
|
|
|
|
while true; do
|
|
|
|
spcd_sdr__index=$((spcd_sdr__index + 1))
|
|
|
|
eval "spcd_sdr__value=\"\${SPCD_DNS_${spcd_sdr__index}}\""
|
|
|
|
[ -n "${spcd_sdr__value}" ] || break
|
|
|
|
spcd_sdr__text="${spcd_sdr__text}\
|
2024-08-06 10:53:23 +00:00
|
|
|
nameserver ${spcd_sdr__value}
|
2024-05-04 10:14:30 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
done
|
|
|
|
spcd_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}"
|
2024-05-04 10:14:30 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_update_packages_catalog() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Update packages catalog"
|
|
|
|
${SPCD_PM_UPDATE} || exit
|
2024-04-26 14:27:36 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_install_packages_tools() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Install packages tools"
|
|
|
|
spcd_install_package "${SPCD_PKG_PKG}"
|
2024-06-21 11:20:20 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 15:11:03 +00:00
|
|
|
# ╭───────┬────╮
|
|
|
|
# │ steps │ ca │
|
|
|
|
# ╰───────┴────╯
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_install_ca_certificates() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Install CA"
|
|
|
|
spcd_install_package "${SPCD_PKG_CA}"
|
2024-06-21 11:20:20 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_write_ca_certificates() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Write CA certificates"
|
|
|
|
spcd_mkdir "${SPCD_CA_ROOT}"
|
|
|
|
while true; do
|
|
|
|
spcd_wcc__index=$((spcd_wcc__index + 1))
|
|
|
|
eval "spcd_wcc__text=\"\${SPCD_CA_${spcd_wcc__index}}\""
|
|
|
|
[ -n "${spcd_wcc__text}" ] || break
|
|
|
|
spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt"
|
|
|
|
spcd_split
|
|
|
|
spcd_write "${spcd_wcc__path}" "${spcd_wcc__text}"
|
|
|
|
spcd_openssl "${spcd_wcc__path}"
|
|
|
|
done
|
2024-05-03 15:20:44 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_update_ca_certificates() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Update CA certificates"
|
|
|
|
${SPCD_CMD_CA} || exit
|
2024-04-27 21:58:48 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 15:11:03 +00:00
|
|
|
# ╭───────┬─────╮
|
|
|
|
# │ steps │ pkg │
|
|
|
|
# ╰───────┴─────╯
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_set_https_verification_on() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Set HTTPS verification on"
|
|
|
|
spcd_rm "${SPCD_PM_HTTPS_PATH}"
|
2024-04-26 14:50:25 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_upgrade_packages() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Upgrade packages"
|
|
|
|
${SPCD_PM_UPGRADE} || exit
|
2024-04-26 14:35:15 +00:00
|
|
|
}
|
|
|
|
|
2024-08-19 08:19:15 +00:00
|
|
|
spcd_install_dos2unix() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Install dos2unix"
|
|
|
|
spcd_install_package "${SPCD_PKG_DOS2UNIX}"
|
2024-08-19 08:19:15 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_install_git() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Install Git"
|
|
|
|
spcd_install_package "${SPCD_PKG_GIT}"
|
2024-04-26 14:35:15 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 15:11:03 +00:00
|
|
|
# ╭───────┬────────╮
|
|
|
|
# │ steps │ python │
|
|
|
|
# ╰───────┴────────╯
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_install_python() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Install Python"
|
|
|
|
spcd_install_package "${SPCD_PYTHON_PACKAGE}"
|
2024-08-21 10:44:50 +00:00
|
|
|
spcd_substep "Link alias to command"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_ln_python "${SPCD_PYTHON_COMMAND}"
|
2024-08-19 12:38:39 +00:00
|
|
|
# venv
|
2024-08-21 10:44:50 +00:00
|
|
|
spcd_substep "Install virtual environment"
|
2024-08-19 12:15:29 +00:00
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
|
|
|
spcd_install_package "python3-venv"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
2024-08-21 10:44:50 +00:00
|
|
|
spcd_substep "Configure PIP"
|
2024-08-19 12:15:29 +00:00
|
|
|
spcd_write "/etc/pip.conf" "\
|
|
|
|
[global]
|
|
|
|
index-url = ${SPCD_URL_PYTHON}
|
|
|
|
"
|
2024-08-21 10:44:50 +00:00
|
|
|
spcd_substep "Create virtual environment"
|
2024-08-19 12:15:29 +00:00
|
|
|
"${SPCD_PYTHON_ALIAS}" -m "venv" "${SPCD_PYTHON_VENV}"
|
2024-08-21 10:44:50 +00:00
|
|
|
spcd_substep "Activate virtual environment"
|
2024-08-19 12:15:29 +00:00
|
|
|
export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}"
|
|
|
|
export VIRTUAL_ENV="${SPCD_PYTHON_VENV}"
|
2024-04-26 14:39:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-19 08:23:08 +00:00
|
|
|
spcd_install_python_modules() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Install Python modules"
|
|
|
|
spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}"
|
2024-08-23 16:07:41 +00:00
|
|
|
spcd_ls "${spcd_ipm__target}"
|
|
|
|
spcd_split
|
|
|
|
spcd_ipm__path="$(spcd_pip_install "${SPCD_GIT_MAIN}")"
|
|
|
|
# check matching of file and variable
|
2024-08-23 16:18:43 +00:00
|
|
|
spcd_split
|
2024-08-23 16:07:41 +00:00
|
|
|
spcd_ipm__script="${spcd_ipm__path}/main.sh"
|
2024-08-23 16:18:43 +00:00
|
|
|
ls -l "${spcd_ipm__script}"
|
|
|
|
spcd_ipm__check="${spcd_ipm__script}.${SPCD_CMD_SUM}"
|
|
|
|
"${SPCD_CMD_SUM}" "${spcd_ipm__script}" >"${spcd_ipm__check}"
|
|
|
|
printf "%s" "${SPCD}" >"${spcd_ipm__script}"
|
|
|
|
ls -l "${spcd_ipm__script}"
|
|
|
|
dos2unix "${spcd_ipm__script}"
|
|
|
|
ls -l "${spcd_ipm__script}"
|
|
|
|
"${SPCD_CMD_SUM}" -c "${spcd_ipm__check}" || spcd_error_ci "SPCD"
|
2024-08-23 16:07:41 +00:00
|
|
|
spcd_split
|
|
|
|
spcd_pip_install "${SPCD_GIT_ROOT}"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_split
|
|
|
|
spcd_ls "${spcd_ipm__target}"
|
2024-08-19 08:23:08 +00:00
|
|
|
}
|
|
|
|
|
2024-07-21 20:02:51 +00:00
|
|
|
spcd_install_packages() {
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_step "Install packages"
|
2024-08-19 08:35:27 +00:00
|
|
|
# epel
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install EPEL"
|
2024-08-19 08:35:27 +00:00
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}")
|
|
|
|
spcd_install_package "epel-release"
|
|
|
|
[ -n "${SPCD_URL_EPEL}" ] && spcd_ip__epel="${SPCD_URL_EPEL}" ||
|
|
|
|
spcd_ip__epel="https://dl.fedoraproject.org"
|
|
|
|
spcd_sed "/etc/yum.repos.d/epel.repo" \
|
|
|
|
"|^metalink|# metalink|" \
|
|
|
|
"|https://download.example|${spcd_ip__epel}|" \
|
|
|
|
"|^#baseurl|baseurl|"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
2024-08-19 17:56:49 +00:00
|
|
|
# bats
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install BATS"
|
2024-08-19 17:56:49 +00:00
|
|
|
spcd_install_package "bats"
|
2024-08-19 08:35:27 +00:00
|
|
|
# graphviz
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install GraphViz"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_install_package "graphviz"
|
2024-08-21 09:53:09 +00:00
|
|
|
# openssh
|
|
|
|
spcd_substep "Install OpenSSH"
|
|
|
|
case "${SPCD_PM}" in
|
|
|
|
"${SPCD_PM_APK}" | "${SPCD_PM_APT}")
|
|
|
|
spcd_install_package "openssh-client"
|
|
|
|
;;
|
|
|
|
"${SPCD_PM_DNF}" | "${SPCD_PM_ZYPPER}")
|
|
|
|
spcd_install_package "openssh-clients"
|
|
|
|
;;
|
|
|
|
"${SPCD_PM_PACMAN}") spcd_install_package "openssh" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
2024-08-19 08:35:27 +00:00
|
|
|
# plantuml
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install PlantUML"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_install_package "plantuml"
|
|
|
|
# rsync
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install Rsync"
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_install_package "rsync"
|
|
|
|
# shell check
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install ShellCheck"
|
2024-08-21 12:47:29 +00:00
|
|
|
case "${SPCD_PF}" in
|
2024-08-21 11:56:58 +00:00
|
|
|
"${SPCD_PF_RPM}")
|
2024-08-20 13:44:30 +00:00
|
|
|
spcd_install_package "ShellCheck"
|
|
|
|
;;
|
2024-08-19 08:35:27 +00:00
|
|
|
*) spcd_install_package "shellcheck" ;;
|
|
|
|
esac
|
|
|
|
# shfmt
|
2024-08-21 09:52:33 +00:00
|
|
|
spcd_substep "Install ShellFormat"
|
2024-08-19 08:35:27 +00:00
|
|
|
case "${SPCD_OS_ID}" in
|
|
|
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}") ;;
|
|
|
|
"${SPCD_OS_DEBIAN}")
|
2024-08-21 12:47:29 +00:00
|
|
|
case "${SPCD_OS_VERSION}" in
|
|
|
|
"bullseye") ;;
|
|
|
|
*) spcd_install_package "shfmt" ;;
|
|
|
|
esac
|
2024-08-19 08:35:27 +00:00
|
|
|
;;
|
|
|
|
*) spcd_install_package "shfmt" ;;
|
|
|
|
esac
|
2024-06-27 11:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spcd_write_python_module() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Write Python module"
|
|
|
|
for spcd_wpm__variable in \
|
|
|
|
OS_ID OS_VERSION \
|
|
|
|
PROJECT_ROOT PROJECT_PATH PROJECT_NAME \
|
|
|
|
PYTHON_VENV_BINARIES PYTHON_VENV_PACKAGES \
|
|
|
|
OPEN DOWN VERT SPLT __UP SHUT; do
|
|
|
|
spcd_wpm__value="$(spcd_echo "SPCD_${spcd_wpm__variable}")"
|
|
|
|
spcd_wpm__text="${spcd_wpm__text}${spcd_wpm__value}
|
2024-06-08 17:15:47 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
done
|
|
|
|
for spcd_wpm__root in \
|
|
|
|
"${SPCD_PYTHON_PACKAGES}" "${SPCD_PYTHON_VENV_PACKAGES}"; do
|
|
|
|
spcd_write "${spcd_wpm__root}/env.py" "${spcd_wpm__text}
|
2024-06-27 11:58:43 +00:00
|
|
|
SPCD_STEP = $((SPCD_STEP + 1))
|
2024-06-04 07:18:54 +00:00
|
|
|
"
|
2024-08-19 08:35:27 +00:00
|
|
|
done
|
2024-06-04 19:13:08 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_switch_to_python() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_step "Switch to Python"
|
|
|
|
spcd_stp__name="$(basename "${SPCD_GIT_MAIN}")"
|
|
|
|
echo "\
|
2024-06-27 11:58:43 +00:00
|
|
|
${SPCD_PATH}
|
2024-04-28 13:42:36 +00:00
|
|
|
↓
|
2024-08-07 17:08:03 +00:00
|
|
|
${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
|
2024-08-19 08:35:27 +00:00
|
|
|
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}"
|
2024-04-26 17:00:43 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 12:59:50 +00:00
|
|
|
# ╭───────────┬──────╮
|
|
|
|
# │ functions │ step │
|
|
|
|
# ╰───────────┴──────╯
|
|
|
|
|
|
|
|
spcd_step() {
|
2024-08-25 13:15:21 +00:00
|
|
|
if [ -n "${1}" ]; then
|
2024-08-25 13:48:00 +00:00
|
|
|
spcd_step__prefix="SPCD_STEP_${SPCD_STEP_LEVEL}"
|
|
|
|
spcd_step__index="${spcd_step__prefix}_INDEX"
|
2024-08-25 13:56:33 +00:00
|
|
|
eval "${spcd_step__index}=\$((${spcd_step__index} + 1))"
|
2024-08-25 13:48:00 +00:00
|
|
|
eval "${spcd_step__prefix}_LABEL=\"${1}\""
|
2024-08-25 15:14:42 +00:00
|
|
|
spcd_banner_render
|
2024-08-25 13:15:21 +00:00
|
|
|
fi
|
2024-08-25 12:59:50 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 13:03:08 +00:00
|
|
|
spcd_step_in() {
|
2024-08-25 15:31:52 +00:00
|
|
|
[ -n "${1}" ] && spcd_step "${1}"
|
2024-08-25 13:48:00 +00:00
|
|
|
SPCD_STEP_LEVEL=$((SPCD_STEP_LEVEL + 1))
|
2024-08-25 13:15:21 +00:00
|
|
|
spcd_step_wipe
|
2024-08-25 13:03:08 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 13:03:28 +00:00
|
|
|
spcd_step_out() {
|
2024-08-25 13:15:21 +00:00
|
|
|
spcd_step_wipe
|
2024-08-25 13:48:00 +00:00
|
|
|
SPCD_STEP_LEVEL=$((SPCD_STEP_LEVEL - 1))
|
2024-08-25 13:03:28 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 14:40:19 +00:00
|
|
|
# ╭───────────╮
|
|
|
|
# │ functions │
|
|
|
|
# ╰───────────╯
|
2024-04-27 19:38:43 +00:00
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_cat() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_cat__file="${1}"
|
|
|
|
if [ -n "${spcd_cat__file}" ]; then
|
|
|
|
spcd_open "${spcd_cat__file}"
|
|
|
|
cat "${spcd_cat__file}" || exit
|
|
|
|
spcd_shut "${spcd_cat__file}"
|
|
|
|
fi
|
2024-04-28 10:35:43 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_echo() {
|
2024-08-19 08:35:27 +00:00
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
for spcd_echo__name in "${@}"; do
|
|
|
|
spcd_echo__text=""
|
|
|
|
eval "spcd_echo__text=\"\${${spcd_echo__name}}\""
|
|
|
|
echo "${spcd_echo__name} = \"${spcd_echo__text}\""
|
|
|
|
done
|
|
|
|
fi
|
2024-05-02 07:59:17 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_error_ci() {
|
2024-08-19 08:35:27 +00:00
|
|
|
echo "× CI: ${*}"
|
|
|
|
exit "${SPCD_ERROR_CI}"
|
2024-04-29 09:01:48 +00:00
|
|
|
}
|
2024-05-02 08:33:34 +00:00
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_error_os() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_error_os__variable="${1}"
|
|
|
|
printf "× OS: "
|
|
|
|
spcd_echo "${spcd_error_os__variable}"
|
|
|
|
exit "${SPCD_ERROR_OS}"
|
2024-04-29 09:01:48 +00:00
|
|
|
}
|
|
|
|
|
2024-08-23 15:26:28 +00:00
|
|
|
spcd_git_clone() {
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
spcd_gc__name="$(basename "${1}")"
|
|
|
|
spcd_gc__path="${SPCD_DL}/${spcd_gc__name}"
|
|
|
|
spcd_gc__url="$(spcd_git_url "${1}")"
|
2024-08-23 19:10:11 +00:00
|
|
|
git clone "${spcd_gc__url}" "${spcd_gc__path}"
|
2024-08-23 15:26:28 +00:00
|
|
|
echo "${spcd_gc__path}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-08-23 15:00:06 +00:00
|
|
|
spcd_git_url() {
|
2024-08-22 08:52:36 +00:00
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
case "${1}" in
|
|
|
|
http*) echo "${1}" ;;
|
|
|
|
*/*) echo "${SPCD_PROJECT_ROOT}/${1}" ;;
|
|
|
|
*) echo "${SPCD_PROJECT_ROOT}/${SPCD_PROJECT_PATH}/${1}" ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_grep_os() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_grep_os__variable="${1}"
|
|
|
|
[ -n "${spcd_grep_os__variable}" ] &&
|
|
|
|
grep "^${spcd_grep_os__variable}=" "/etc/os-release" |
|
|
|
|
sed "s|^${spcd_grep_os__variable}=||" |
|
|
|
|
sed "s|^\"\(.*\)\"$|\1|"
|
2024-05-02 14:46:08 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_install_package() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_install_package__name="${1}"
|
|
|
|
if [ -n "${spcd_install_package__name}" ]; then
|
|
|
|
${SPCD_PM_INSTALL} "${spcd_install_package__name}" || exit
|
|
|
|
${SPCD_PM_CLEAN} || exit
|
|
|
|
fi
|
2024-04-27 19:38:43 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_ln_python() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_ln_python__command="${1}"
|
|
|
|
if [ -n "${spcd_ln_python__command}" ]; then
|
|
|
|
echo "→ ${SPCD_PYTHON_ALIAS} → ${spcd_ln_python__command}"
|
|
|
|
ln -f -s "${spcd_ln_python__command}" \
|
|
|
|
"/usr/bin/${SPCD_PYTHON_ALIAS}" || exit
|
|
|
|
fi
|
2024-05-03 22:24:14 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_ls() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_ls__path="${1}"
|
|
|
|
if [ -n "${spcd_ls__path}" ]; then
|
|
|
|
spcd_open "${spcd_ls__path}"
|
|
|
|
ls -a -l "${spcd_ls__path}" || exit
|
|
|
|
spcd_shut "${spcd_ls__path}"
|
|
|
|
fi
|
2024-05-04 08:30:33 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_mkdir() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_mkdir__path="${1}"
|
|
|
|
if [ -n "${spcd_mkdir__path}" ]; then
|
|
|
|
echo "→ ${spcd_mkdir__path}"
|
|
|
|
mkdir --parents "${spcd_mkdir__path}" || exit
|
|
|
|
fi
|
2024-04-29 18:16:14 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_open() {
|
2024-08-19 08:35:27 +00:00
|
|
|
echo "${SPCD_OPEN}${*}"
|
2024-06-04 21:18:25 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_openssl() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_openssl__file="${1}"
|
|
|
|
if [ -f "${spcd_openssl__file}" ]; then
|
|
|
|
openssl x509 \
|
|
|
|
-in "${spcd_openssl__file}" \
|
|
|
|
-noout -text ||
|
|
|
|
exit
|
|
|
|
fi
|
2024-05-04 07:50:13 +00:00
|
|
|
}
|
|
|
|
|
2024-08-23 16:07:41 +00:00
|
|
|
spcd_pip_install() {
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
spcd_pi__name="$(basename "${1}")"
|
|
|
|
spcd_pi__path="$(spcd_git_clone "${1}")"
|
|
|
|
spcd_pi__path="${spcd_pi__path}/${spcd_pi__name}"
|
|
|
|
spcd_pi__target="${SPCD_PYTHON_VENV_PACKAGES}"
|
|
|
|
cp --recursive "${spcd_pi__path}" "${spcd_pi__target}"
|
|
|
|
echo "${spcd_pi__target}/${spcd_pi__name}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_rm() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_rm__path="${1}"
|
|
|
|
if [ -e "${spcd_rm__path}" ]; then
|
|
|
|
echo "← ${spcd_rm__path}"
|
|
|
|
rm -r "${spcd_rm__path}" || exit
|
|
|
|
fi
|
2024-04-28 11:00:18 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_sed() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_sed__file="${1}"
|
|
|
|
shift
|
|
|
|
if [ -f "${spcd_sed__file}" ]; then
|
|
|
|
spcd_cat "${spcd_sed__file}"
|
|
|
|
for spcd_sed__regex in "${@}"; do
|
|
|
|
sed --in-place "s${spcd_sed__regex}g" "${spcd_sed__file}" &&
|
|
|
|
spcd_cat "${spcd_sed__file}" || exit
|
|
|
|
done
|
|
|
|
fi
|
2024-04-29 21:07:52 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_shut() {
|
2024-08-19 08:35:27 +00:00
|
|
|
echo "${SPCD_SHUT}${*}"
|
2024-06-04 21:18:25 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_split() {
|
2024-08-19 08:35:27 +00:00
|
|
|
echo "${SPCD_SPLT}"
|
2024-04-30 10:36:33 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
spcd_write() {
|
2024-08-19 08:35:27 +00:00
|
|
|
spcd_write__file="${1}"
|
|
|
|
spcd_write__text="${2}"
|
|
|
|
if [ -n "${spcd_write__file}" ]; then
|
|
|
|
[ -f "${spcd_write__file}" ] && spcd_cat "${spcd_write__file}"
|
|
|
|
echo "→ ${spcd_write__file}"
|
|
|
|
printf "%s" "${spcd_write__text}" >"${spcd_write__file}" || exit
|
|
|
|
spcd_cat "${spcd_write__file}"
|
|
|
|
fi
|
2024-04-27 19:24:59 +00:00
|
|
|
}
|
|
|
|
|
2024-05-02 09:10:54 +00:00
|
|
|
# constants
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
SPCD_BOX_DOWN="╭"
|
|
|
|
SPCD_BOX_LEFT="╴"
|
|
|
|
SPCD_BOX_RIGHT="╶"
|
|
|
|
SPCD_BOX_UP="╰"
|
|
|
|
SPCD_BOX_VERTICAL="│"
|
|
|
|
|
2024-07-19 20:02:42 +00:00
|
|
|
SPCD_ERROR_CI=1
|
|
|
|
SPCD_ERROR_OS=2
|
2024-06-27 11:58:43 +00:00
|
|
|
|
|
|
|
SPCD_OS_ALMA="alma"
|
|
|
|
SPCD_OS_ALPINE="alpine"
|
|
|
|
SPCD_OS_ARCH="arch"
|
|
|
|
SPCD_OS_DEBIAN="debian"
|
|
|
|
SPCD_OS_FEDORA="fedora"
|
2024-08-20 06:27:15 +00:00
|
|
|
SPCD_OS_OPENSUSE="opensuse"
|
2024-06-27 11:58:43 +00:00
|
|
|
SPCD_OS_ROCKY="rocky"
|
|
|
|
SPCD_OS_UBUNTU="ubuntu"
|
|
|
|
|
2024-08-21 11:52:38 +00:00
|
|
|
SPCD_PF_APK="apk"
|
|
|
|
SPCD_PF_DEB="deb"
|
|
|
|
SPCD_PF_PKG="pkg"
|
|
|
|
SPCD_PF_RPM="rpm"
|
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
SPCD_PM_APK="apk"
|
|
|
|
SPCD_PM_APT="apt"
|
|
|
|
SPCD_PM_DNF="dnf"
|
|
|
|
SPCD_PM_PACMAN="pacman"
|
2024-08-20 06:27:15 +00:00
|
|
|
SPCD_PM_ZYPPER="zypper"
|
2024-06-27 11:58:43 +00:00
|
|
|
|
2024-08-07 11:10:09 +00:00
|
|
|
SPCD_PYTHON_VENV="/opt/venv"
|
2024-08-07 22:07:44 +00:00
|
|
|
SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin"
|
2024-08-07 10:37:04 +00:00
|
|
|
|
2024-06-27 11:58:43 +00:00
|
|
|
SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
|
|
|
|
|
|
|
|
SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}"
|
|
|
|
SPCD_VERT="${SPCD_BOX_VERTICAL}"
|
|
|
|
SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}"
|
|
|
|
SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}"
|
2024-06-04 18:10:29 +00:00
|
|
|
|
2024-08-24 14:20:05 +00:00
|
|
|
# ╭──────────╮
|
|
|
|
# │ internal │
|
|
|
|
# ╰──────────╯
|
2024-08-24 11:00:25 +00:00
|
|
|
|
2024-08-24 14:35:32 +00:00
|
|
|
spcd_fill() {
|
|
|
|
spcd_fill__index=${1}
|
|
|
|
while [ "${spcd_fill__index}" -gt 0 ]; do
|
|
|
|
printf "%s" "${2}"
|
|
|
|
spcd_fill__index=$((spcd_fill__index - 1))
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2024-08-24 14:32:20 +00:00
|
|
|
# ╭──────────┬────────╮
|
|
|
|
# │ internal │ banner │
|
|
|
|
# ╰──────────┴────────╯
|
|
|
|
|
2024-08-25 10:03:48 +00:00
|
|
|
SPCD_BANNER_DOWN_AND_HORIZONTAL="┬"
|
2024-08-25 12:36:41 +00:00
|
|
|
SPCD_BANNER_DOWN_AND_LEFT="╮"
|
2024-08-25 12:25:37 +00:00
|
|
|
SPCD_BANNER_DOWN_AND_RIGHT="╭"
|
2024-08-25 12:36:41 +00:00
|
|
|
SPCD_BANNER_HORIZONTAL="─"
|
2024-08-25 10:03:48 +00:00
|
|
|
SPCD_BANNER_UP_AND_HORIZONTAL="┴"
|
2024-08-25 10:16:26 +00:00
|
|
|
SPCD_BANNER_UP_AND_LEFT="╯"
|
2024-08-25 12:36:41 +00:00
|
|
|
SPCD_BANNER_UP_AND_RIGHT="╰"
|
|
|
|
SPCD_BANNER_VERTICAL="│"
|
2024-08-25 10:03:48 +00:00
|
|
|
|
2024-08-24 11:00:25 +00:00
|
|
|
spcd_banner_add() {
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
spcd_ba__text=" ${1} "
|
|
|
|
spcd_ba__length=${#spcd_ba__text}
|
2024-08-25 10:03:48 +00:00
|
|
|
spcd_ba__filler="$(
|
|
|
|
spcd_fill "${spcd_ba__length}" "${SPCD_BANNER_HORIZONTAL}"
|
|
|
|
)"
|
2024-08-25 14:08:12 +00:00
|
|
|
if [ -n "${SPCD_BANNER_MIDDLE}" ]; then
|
|
|
|
spcd_banner_split
|
|
|
|
else
|
|
|
|
spcd_banner_open
|
|
|
|
fi
|
2024-08-24 11:08:10 +00:00
|
|
|
spcd_banner_append \
|
2024-08-24 11:00:25 +00:00
|
|
|
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-08-25 15:10:26 +00:00
|
|
|
spcd_banner_add_index() {
|
|
|
|
unset spcd_bi__label
|
|
|
|
unset spcd_bi__level
|
|
|
|
while true; do
|
|
|
|
spcd_bi__level=$((spcd_bi__level + 1))
|
|
|
|
eval "spcd_bi__value=\"\${SPCD_BANNER_${spcd_bi__level}_INDEX}\""
|
|
|
|
[ -n "${spcd_bi__value}" ] || break
|
|
|
|
if [ -n "${spcd_bi__label}" ]; then
|
|
|
|
spcd_bi__label="${spcd_bi__label}.${spcd_bi__value}"
|
|
|
|
else
|
|
|
|
spcd_bi__label="${spcd_bi__value}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
spcd_banner_add "${spcd_bi__label}"
|
|
|
|
}
|
|
|
|
|
2024-08-24 11:08:10 +00:00
|
|
|
spcd_banner_append() {
|
2024-08-24 11:00:25 +00:00
|
|
|
if [ -n "${3}" ]; then
|
2024-08-25 05:06:10 +00:00
|
|
|
SPCD_BANNER_TOP="${SPCD_BANNER_TOP}${1}"
|
|
|
|
SPCD_BANNER_MIDDLE="${SPCD_BANNER_MIDDLE}${2}"
|
|
|
|
SPCD_BANNER_BOTTOM="${SPCD_BANNER_BOTTOM}${3}"
|
2024-08-24 11:00:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
spcd_banner_close() {
|
2024-08-25 10:16:26 +00:00
|
|
|
spcd_banner_append \
|
|
|
|
"${SPCD_BANNER_DOWN_AND_LEFT}" \
|
|
|
|
"${SPCD_BANNER_VERTICAL}" \
|
|
|
|
"${SPCD_BANNER_UP_AND_LEFT}"
|
2024-08-24 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 11:04:49 +00:00
|
|
|
spcd_banner_echo() {
|
|
|
|
echo "\
|
2024-08-25 05:06:10 +00:00
|
|
|
${SPCD_BANNER_TOP}
|
|
|
|
${SPCD_BANNER_MIDDLE}
|
|
|
|
${SPCD_BANNER_BOTTOM}"
|
2024-08-24 11:04:49 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 11:00:25 +00:00
|
|
|
spcd_banner_open() {
|
2024-08-25 10:09:49 +00:00
|
|
|
spcd_banner_append \
|
2024-08-25 12:25:37 +00:00
|
|
|
"${SPCD_BANNER_DOWN_AND_RIGHT}" \
|
|
|
|
"${SPCD_BANNER_VERTICAL}" \
|
|
|
|
"${SPCD_BANNER_UP_AND_RIGHT}"
|
2024-08-24 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 15:14:42 +00:00
|
|
|
spcd_banner_render() {
|
|
|
|
spcd_banner_unset
|
|
|
|
spcd_banner_add_index
|
|
|
|
spcd_banner_add "S"
|
|
|
|
#
|
2024-08-25 15:19:31 +00:00
|
|
|
unset spcd_br__level
|
|
|
|
while true; do
|
|
|
|
spcd_br__level=$((spcd_br__level + 1))
|
|
|
|
eval "spcd_br__value=\"\${SPCD_BANNER_${spcd_br__level}_LABEL}\""
|
|
|
|
[ -n "${spcd_br__value}" ] || break
|
|
|
|
spcd_banner_add "${spcd_br__value}"
|
2024-08-25 15:14:42 +00:00
|
|
|
done
|
|
|
|
#
|
|
|
|
spcd_banner_close
|
|
|
|
spcd_banner_echo
|
|
|
|
spcd_banner_unset
|
|
|
|
}
|
|
|
|
|
2024-08-24 11:00:25 +00:00
|
|
|
spcd_banner_split() {
|
2024-08-25 10:03:48 +00:00
|
|
|
spcd_banner_append \
|
|
|
|
"${SPCD_BANNER_DOWN_AND_HORIZONTAL}" \
|
2024-08-25 10:09:49 +00:00
|
|
|
"${SPCD_BANNER_VERTICAL}" \
|
2024-08-25 10:03:48 +00:00
|
|
|
"${SPCD_BANNER_UP_AND_HORIZONTAL}"
|
2024-08-24 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 11:05:37 +00:00
|
|
|
spcd_banner_unset() {
|
2024-08-25 13:17:25 +00:00
|
|
|
unset \
|
|
|
|
SPCD_BANNER_TOP \
|
|
|
|
SPCD_BANNER_MIDDLE \
|
|
|
|
SPCD_BANNER_BOTTOM
|
2024-08-24 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 12:59:50 +00:00
|
|
|
# ╭──────────┬──────╮
|
|
|
|
# │ internal │ step │
|
|
|
|
# ╰──────────┴──────╯
|
|
|
|
|
|
|
|
SPCD_STEP=1
|
|
|
|
|
2024-08-25 13:15:21 +00:00
|
|
|
spcd_step_wipe() {
|
2024-08-25 13:48:00 +00:00
|
|
|
unset \
|
|
|
|
"SPCD_STEP_${SPCD_STEP_LEVEL}_INDEX" \
|
|
|
|
"SPCD_STEP_${SPCD_STEP_LEVEL}_LABEL"
|
2024-08-25 13:15:21 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 12:59:50 +00:00
|
|
|
# ╭──────────╮
|
|
|
|
# │ internal │
|
|
|
|
# ╰──────────╯
|
2024-08-24 11:00:25 +00:00
|
|
|
|
2024-07-29 18:56:28 +00:00
|
|
|
spcd_main
|