Compare commits

...

20 commits

Author SHA1 Message Date
979dc07d98
readme/internals
All checks were successful
/ job (push) Successful in 10m19s
2024-08-26 12:43:52 +02:00
8ada578206
readme/tasks 2024-08-26 12:43:03 +02:00
728acfded9
pm/conf 2024-08-26 12:36:41 +02:00
9fc6c5fea3
spcd_query_package 2024-08-26 12:04:01 +02:00
4db5c7ce08
pm/install 2024-08-26 11:58:06 +02:00
0af77deec9
ca 2024-08-26 11:46:41 +02:00
f35b2cef7e
ca/pkg 2024-08-26 11:42:43 +02:00
43f3540f1b
switch/1 2024-08-26 11:38:51 +02:00
1c15f3fdf1
−pf 2024-08-26 11:36:34 +02:00
37d39200a0
pm/tools 2024-08-26 11:29:30 +02:00
6df1d883ca
purge 2024-08-26 11:24:58 +02:00
b03dd41137
pm/clean 2024-08-26 11:23:50 +02:00
6112868374
ca/root 2024-08-26 11:16:53 +02:00
f3c6f7a1cf
ca/update 2024-08-26 11:11:26 +02:00
124549cd8b
ca 2024-08-26 11:07:27 +02:00
5fad8cbb6e
pm/update 2024-08-26 10:49:12 +02:00
ce7381d8e0
pm/upgrade 2024-08-26 10:43:39 +02:00
6cb19d12a0
dos2unix 2024-08-26 10:34:34 +02:00
0645026bc0
git 2024-08-26 10:33:04 +02:00
f736628313
−bats 2024-08-26 10:31:39 +02:00
2 changed files with 133 additions and 141 deletions

View file

@ -217,11 +217,18 @@ Handle project workflows in a unified way:
* constants for characters
* dynamic substeps
* comment
* review repositories handling for systems
* opensuse
* codecs repository
* disable & enable https
* frame corners
* packages
* configure
* apk
* pacman
* zypper
* repositories
* opensuse
* codecs repository
* disable & enable https
* test
* underscore internals
### Shell → Python

View file

@ -405,11 +405,6 @@ SPCD_OS_OPENSUSE="opensuse"
SPCD_OS_ROCKY="rocky"
SPCD_OS_UBUNTU="ubuntu"
SPCD_PF_APK="apk"
SPCD_PF_DEB="deb"
SPCD_PF_PKG="pkg"
SPCD_PF_RPM="rpm"
SPCD_PM_APK="apk"
SPCD_PM_APT="apt"
SPCD_PM_DNF="dnf"
@ -596,39 +591,9 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
spcd_os_printenv "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_os_printenv "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"
;;
"${SPCD_OS_OPENSUSE}")
SPCD_CA_ROOT="/etc/pki/trust/anchors"
SPCD_CMD_CA="update-ca-certificates"
;;
*) ;;
esac
spcd_split
spcd_os_printenv "SPCD_CA_ROOT" "SPCD_CMD_CA"
spcd_os_printenv "SPCD_DNS_FILE" "SPCD_PYTHON_ALIAS"
# set package manager
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALPINE}")
@ -648,105 +613,35 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
;;
*) ;;
esac
# 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
spcd_split
spcd_os_printenv "SPCD_PF" "SPCD_PM"
spcd_os_printenv "SPCD_PM"
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="\
[main]
best=True
clean_requirements_on_remove=True
gpgcheck=1
installonly_limit=3
skip_if_unavailable=False
"
SPCD_PM_HTTPS_PATH="/etc/dnf/dnf.conf.d/https.conf"
SPCD_PM_HTTPS_TEXT="\
sslverify=False
"
;;
"${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="\
--no-verify
"
;;
"${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="\
SSLVerify = No
"
;;
"${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="\
Acquire::Check-Valid-Until True;
APT::Get::Show-Versions True;
APT::Install-Recommends False;
APT::Install-Suggests False;
Dir::Etc::SourceParts \"\";
"
SPCD_PM_HTTPS_PATH="/etc/apt/apt.conf.d/https"
SPCD_PM_HTTPS_TEXT="\
Acquire::https::Verify-Peer False;
"
;;
"${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="\
"
@ -754,10 +649,7 @@ Acquire::https::Verify-Peer False;
*) ;;
esac
spcd_split
spcd_os_printenv "SPCD_PM_CLEAN" \
"SPCD_PM_INSTALL" "SPCD_PM_QUERY" "SPCD_PM_UPDATE" "SPCD_PM_UPGRADE"
spcd_split
spcd_os_printenv "SPCD_PKG_PKG" "SPCD_PM_CONF_PATH" "SPCD_PM_HTTPS_PATH"
spcd_os_printenv "SPCD_PM_HTTPS_PATH"
# specific
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}")
@ -895,13 +787,10 @@ Acquire::https::Verify-Peer False;
${SPCD_PYTHON_VENV}/lib/${SPCD_PYTHON_COMMAND}/site-packages"
spcd_split
spcd_os_printenv "SPCD_PYTHON_PACKAGES" "SPCD_PYTHON_VENV_PACKAGES"
# variables
# certificate authorities
[ -n "${SPCD_CA_1}" ] && SPCD_CA=true
# downloads
SPCD_DL="$(mktemp --directory)"
spcd_split
spcd_os_printenv "SPCD_CA" "SPCD_DL"
spcd_os_printenv "SPCD_DL"
}
spcd_environment_list_workspace() {
@ -914,12 +803,38 @@ spcd_environment_list_workspace() {
# │ steps │ functions │
# ╰───────┴───────────╯
spcd_clean_cache() {
case "${SPCD_PM}" in
"${SPCD_PM_APK}") apk cache purge ;;
"${SPCD_PM_APT}") apt-get clean ;;
"${SPCD_PM_DNF}") dnf clean all ;;
"${SPCD_PM_PACMAN}") pacman --sync --clean --noconfirm ;;
"${SPCD_PM_ZYPPER}") zypper clean ;;
*) ;;
esac
}
spcd_install_package() {
spcd_install_package__name="${1}"
if [ -n "${spcd_install_package__name}" ]; then
${SPCD_PM_INSTALL} "${spcd_install_package__name}"
${SPCD_PM_CLEAN}
fi
case "${SPCD_PM}" in
"${SPCD_PM_APK}") apk add "${1}" ;;
"${SPCD_PM_APT}") apt-get install --assume-yes "${1}" ;;
"${SPCD_PM_DNF}") dnf install --assumeyes "${1}" ;;
"${SPCD_PM_PACMAN}") pacman --sync --noconfirm "${1}" ;;
"${SPCD_PM_ZYPPER}") zypper --non-interactive install "${1}" ;;
*) ;;
esac
spcd_clean_cache
}
spcd_query_package() {
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
}
# ╭───────┬─────╮
@ -1012,7 +927,34 @@ deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-security main universe
spcd_packages_set_configuration() {
spcd_step "Set configuration"
spcd_os_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}"
case "${SPCD_PM}" in
"${SPCD_PM_DNF}")
spcd_os_write "/etc/dnf/dnf.conf" "\
[main]
best=True
clean_requirements_on_remove=True
gpgcheck=1
installonly_limit=3
skip_if_unavailable=False
"
;;
"${SPCD_PM_APK}")
;;
"${SPCD_PM_PACMAN}")
;;
"${SPCD_PM_APT}")
spcd_os_write "/etc/apt/apt.conf.d/apt.conf" "\
Acquire::Check-Valid-Until True;
APT::Get::Show-Versions True;
APT::Install-Recommends False;
APT::Install-Suggests False;
Dir::Etc::SourceParts \"\";
"
;;
"${SPCD_PM_ZYPPER}")
;;
*) ;;
esac
case "${SPCD_OS_ID}" in
"${SPCD_OS_ARCH}")
pacman-key --init
@ -1026,7 +968,7 @@ spcd_packages_set_configuration() {
spcd_packages_trust_https() {
spcd_step "Trust HTTPS"
if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
if [ -n "${SPCD_CA_1}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
spcd_os_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")"
spcd_os_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}"
fi
@ -1034,12 +976,22 @@ spcd_packages_trust_https() {
spcd_packages_update_catalog() {
spcd_step "Update catalog"
${SPCD_PM_UPDATE}
case "${SPCD_PM}" in
"${SPCD_PM_APK}") apk update ;;
"${SPCD_PM_APT}") apt-get update ;;
"${SPCD_PM_DNF}") dnf makecache ;;
"${SPCD_PM_PACMAN}") pacman --sync --refresh ;;
"${SPCD_PM_ZYPPER}") zypper refresh ;;
*) ;;
esac
}
spcd_packages_install_tools() {
spcd_step "Install tools"
spcd_install_package "${SPCD_PKG_PKG}"
case "${SPCD_PM}" in
"${SPCD_PM_APT}") spcd_install_package "apt-utils" ;;
*) ;;
esac
}
# ╭───────┬────╮
@ -1048,17 +1000,32 @@ spcd_packages_install_tools() {
spcd_ca_install_package() {
spcd_step "Install package"
spcd_install_package "${SPCD_PKG_CA}"
spcd_install_package "ca-certificates"
}
spcd_ca_write_certificates() {
spcd_step "Write certificates"
spcd_os_mkdir "${SPCD_CA_ROOT}"
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
spcd_wcc__root="/etc/pki/ca-trust/source/anchors"
;;
"${SPCD_OS_ALPINE}" | "${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
spcd_wcc__root="/usr/local/share/ca-certificates"
;;
"${SPCD_OS_ARCH}")
spcd_wcc__root="/etc/ca-certificates/trust-source/anchors"
;;
"${SPCD_OS_OPENSUSE}")
spcd_wcc__root="/etc/pki/trust/anchors"
;;
*) ;;
esac
spcd_os_mkdir "${spcd_wcc__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_wcc__path="${spcd_wcc__root}/${spcd_wcc__index}.crt"
spcd_split
spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}"
spcd_openssl_x509 "${spcd_wcc__path}"
@ -1067,7 +1034,21 @@ spcd_ca_write_certificates() {
spcd_ca_update_certificates() {
spcd_step "Update certificates"
${SPCD_CMD_CA}
case "${SPCD_OS_ID}" in
"${SPCD_OS_ARCH}" | \
"${SPCD_OS_ALMA}" | \
"${SPCD_OS_FEDORA}" | \
"${SPCD_OS_ROCKY}")
update-ca-trust
;;
"${SPCD_OS_ALPINE}" | \
"${SPCD_OS_DEBIAN}" | \
"${SPCD_OS_OPENSUSE}" | \
"${SPCD_OS_UBUNTU}")
update-ca-certificates
;;
*) ;;
esac
}
# ╭───────┬──────────╮
@ -1081,17 +1062,24 @@ spcd_packages_verify_https() {
spcd_packages_upgrade_system() {
spcd_step "Upgrade system"
${SPCD_PM_UPGRADE}
case "${SPCD_PM}" in
"${SPCD_PM_APK}") apk upgrade ;;
"${SPCD_PM_APT}") apt-get upgrade --assume-yes ;;
"${SPCD_PM_DNF}") dnf upgrade --assumeyes ;;
"${SPCD_PM_PACMAN}") pacman --sync --sysupgrade --noconfirm ;;
"${SPCD_PM_ZYPPER}") zypper --non-interactive update ;;
*) ;;
esac
}
spcd_packages_install_dos2unix() {
spcd_step "Install dos2unix"
spcd_install_package "${SPCD_PKG_DOS2UNIX}"
spcd_install_package "dos2unix"
}
spcd_packages_install_git() {
spcd_step "Install Git"
spcd_install_package "${SPCD_PKG_GIT}"
spcd_install_package "git"
}
# ╭───────┬────────╮
@ -1166,9 +1154,6 @@ spcd_install_packages() {
;;
*) ;;
esac
# bats
spcd_step "BATS"
spcd_install_package "bats"
# graphviz
spcd_step "GraphViz"
spcd_install_package "graphviz"
@ -1192,8 +1177,8 @@ spcd_install_packages() {
spcd_install_package "rsync"
# shell check
spcd_step "ShellCheck"
case "${SPCD_PF}" in
"${SPCD_PF_RPM}")
case "${SPCD_PM}" in
"${SPCD_PM_DNF}" | "${SPCD_PM_ZYPPER}")
spcd_install_package "ShellCheck"
;;
*) spcd_install_package "shellcheck" ;;
@ -1224,7 +1209,7 @@ spcd_python_write_module() {
spcd_wpm__text="${spcd_wpm__text}${spcd_wpm__value}
"
done
eval "spcd_wpm__index=\$((SPCD_STEP_${SPCD_STEP_LEVEL}_INDEX + 1))"
spcd_wpm__index=$((SPCD_STEP_1_INDEX + 1))
for spcd_wpm__root in \
"${SPCD_PYTHON_PACKAGES}" "${SPCD_PYTHON_VENV_PACKAGES}"; do
spcd_os_write "${spcd_wpm__root}/env.py" "${spcd_wpm__text}