Compare commits

..

No commits in common. "4b7fb8a89f0a9f65e70797bb0a8058726056b315" and "5928a2fdcc99199200487659105ef8bb0236bc47" have entirely different histories.

2 changed files with 190 additions and 211 deletions

View file

@ -217,12 +217,11 @@ Handle project workflows in a unified way:
* build instead of readme
* generate graphs
* list behavior differences
* Continuous Integration platforms
* Operating Systems
* list CI behavior differences
#### Shell
* command to echo & run
* comment
* handle errors
* packages

View file

@ -1,20 +1,8 @@
#! /usr/bin/env sh
# ╭───────────────╮
# │ __ = internal │
# ╰───────────────╯
# __SPCD_BANNER_TOP
# __SPCD_BANNER_MIDDLE
# __SPCD_BANNER_BOTTOM
# __SPCD_STEP_LEVEL
# __SPCD_STEP_level_INDEX
# __SPCD_STEP_level_LABEL
# ╭─────────────╮
# │ _ = private │
# ╰─────────────╯
# ╭───╮
# │ _ │
# ╰───╯
_SPCD_BOX_DOWN_AND_HORIZONTAL="┬"
_SPCD_BOX_DOWN_AND_LEFT="╮"
@ -207,9 +195,9 @@ _spcd_txt_pick() {
esac
}
# ╭───────────
# │ p = public
# ╰───────────
# ╭───────────
# │ functions
# ╰───────────
spcd_ca() {
local grep="\(After\|Before\|Issuer\|Signature Algorithm\|Subject:\)"
@ -259,7 +247,7 @@ nameserver ${value}
fi
}
spcd_run() {
spcd_eval() {
if [ -n "${1}" ]; then
_spcd_frame_open "${@}"
"${@}"
@ -267,9 +255,9 @@ spcd_run() {
fi
}
# ╭───┬───────╮
# │ p │ error │
# ╰───┴───────╯
# ╭───────────┬───────╮
# │ functions │ error │
# ╰───────────┴───────╯
spcd_error_ci() {
echo "× CI: ${*}"
@ -282,9 +270,9 @@ spcd_error_os() {
exit "${_SPCD_ERROR_OS}"
}
# ╭───┬────╮
# │ p │ os │
# ╰───┴────╯
# ╭───────────┬────╮
# │ functions │ os │
# ╰───────────┴────╯
spcd_os_grep() {
local variable="${1}"
@ -349,17 +337,17 @@ spcd_os_write() {
fi
}
# ╭───┬───────╮
# │ p │ split │
# ╰───┴───────╯
# ╭───────────┬───────╮
# │ functions │ split │
# ╰───────────┴───────╯
spcd_split() {
echo "${_SPCD_RULE_LEFT}${_SPCD_RULE_MIDDLE}${_SPCD_RULE_RIGHT}"
}
# ╭───┬──────╮
# │ p │ step │
# ╰───┴──────╯
# ╭───────────┬──────╮
# │ functions │ step │
# ╰───────────┴──────╯
spcd_step() {
if [ -n "${1}" ]; then
@ -383,9 +371,9 @@ spcd_step_out() {
__SPCD_STEP_LEVEL=$((__SPCD_STEP_LEVEL - 1))
}
# ╭───┬─────╮
# │ p │ txt │
# ╰───┴─────╯
# ╭───────────┬─────╮
# │ functions │ txt │
# ╰───────────┴─────╯
SPCD_TXT_LOCALE_ENGLISH="en_US"
SPCD_TXT_LOCALE_FRENCH="fr_FR"
@ -397,13 +385,13 @@ spcd_txt_get() {
esac
}
# ╭──────────
# │ s = step │
# ╰──────────
# ╭──────
# │ step │
# ╰──────
# ╭───┬───────────╮
# │ s │ constants │
# ╰───┴───────────╯
# ╭──────┬───────────╮
# │ step │ constants │
# ╰──────┴───────────╯
SPCD_OS_ALMA="alma"
SPCD_OS_ALPINE="alpine"
@ -420,9 +408,9 @@ SPCD_PM_DNF="dnf"
SPCD_PM_PACMAN="pacman"
SPCD_PM_ZYPPER="zypper"
# ╭───┬─────────────╮
# │ s │ environment │
# ╰───┴─────────────╯
# ╭──────┬─────────────╮
# │ step │ environment │
# ╰──────┴─────────────╯
spcd_step__environment_print() {
spcd_ca "list"
@ -790,9 +778,20 @@ spcd_step__environment_list_workspace() {
spcd_os_ls "$(realpath .)"
}
# ╭──────────────╮
# │ f = function │
# ╰──────────────╯
# ╭──────┬───────────╮
# │ step │ functions │
# ╰──────┴───────────╯
spcd_clean_cache() {
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_eval apk cache purge ;;
"${SPCD_PM_APT}") spcd_eval apt-get clean ;;
"${SPCD_PM_DNF}") spcd_eval dnf clean all ;;
"${SPCD_PM_PACMAN}") spcd_eval pacman --sync --clean --noconfirm ;;
"${SPCD_PM_ZYPPER}") spcd_eval zypper clean ;;
*) ;;
esac
}
spcd_git_clone() {
if [ -n "${1}" ]; then
@ -815,6 +814,29 @@ spcd_git_url() {
fi
}
spcd_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_install_package() {
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_eval apk add "${1}" ;;
"${SPCD_PM_APT}") spcd_eval apt-get install --assume-yes "${1}" ;;
"${SPCD_PM_DNF}") spcd_eval dnf install --assumeyes "${1}" ;;
"${SPCD_PM_PACMAN}") spcd_eval pacman --sync --noconfirm "${1}" ;;
"${SPCD_PM_ZYPPER}") spcd_eval zypper --non-interactive install "${1}" ;;
*) ;;
esac
spcd_clean_cache
}
spcd_python_ln() {
local command="${1}"
if [ -n "${command}" ]; then
@ -836,6 +858,17 @@ spcd_python_pip() {
fi
}
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
}
spcd_txt_locale() {
local action="${1}"
local chosen="${2}"
@ -915,7 +948,7 @@ spcd_txt_locale() {
*) ;;
esac
spcd_split
spcd_os_printenv "${name}"
echo "${name}"
if [ -n "${regex}" ]; then
locale --keyword-name "${name}" | grep "${regex}"
fi
@ -938,7 +971,7 @@ spcd_txt_locales() {
spcd_split
case "${SPCD_PM}" in
"${SPCD_PM_APK}")
spcd_f_pm_install "musl-locales"
spcd_install_package "musl-locales"
export MUSL_LOCPATH="/usr/share/i18n/locales/musl"
;;
"${SPCD_PM_APT}")
@ -949,17 +982,17 @@ ${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
"
done
spcd_os_write "/etc/locale.gen" "${text}"
spcd_f_pm_install "locales"
spcd_install_package "locales"
;;
"${SPCD_PM_DNF}")
local language
for name in "${@}"; do
language="$(echo "${name}" | cut -d _ -f 1)"
spcd_f_pm_install "glibc-langpack-${language}"
spcd_install_package "glibc-langpack-${language}"
done
;;
"${SPCD_PM_PACMAN}") spcd_f_pm_install "glibc-locales" ;;
"${SPCD_PM_ZYPPER}") spcd_f_pm_install "glibc-locale" ;;
"${SPCD_PM_PACMAN}") spcd_install_package "glibc-locales" ;;
"${SPCD_PM_ZYPPER}") spcd_install_package "glibc-locale" ;;
*) ;;
esac
spcd_split
@ -981,7 +1014,7 @@ ${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
done
;;
"list")
if ! spcd_run locale --all-locales; then
if ! spcd_eval locale --all-locales; then
echo "No locales yet!"
fi
;;
@ -989,133 +1022,18 @@ ${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
esac
}
# ╭───┬────╮
# │ f │ pm │
# ╰───┴────╯
spcd_f_pm_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_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_clean
}
spcd_f_pm_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_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_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 │ 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
}
# ╭───┬─────╮
# │ s │ dns │
# ╰───┴─────╯
# ╭──────┬─────╮
# │ step │ dns │
# ╰──────┴─────╯
spcd_step__dns() {
spcd_step "DNS"
spcd_dns "write"
}
# ╭───┬──────────╮
# │ s │ packages │
# ╰───┴──────────╯
# ╭──────┬──────────╮
# │ step │ packages │
# ╰──────┴──────────╯
spcd_step__packages_set_repositories() {
spcd_step "Set repositories"
@ -1288,7 +1206,7 @@ Dir::Etc::SourceParts \"\";
esac
case "${SPCD_OS_ID}" in
"${SPCD_OS_ARCH}")
spcd_run pacman-key --init
spcd_eval pacman-key --init
;;
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
export DEBIAN_FRONTEND="noninteractive"
@ -1298,10 +1216,51 @@ Dir::Etc::SourceParts \"\";
esac
}
spcd_step__packages_trust_https() {
spcd_step "Trust HTTPS"
local path text
if [ -n "${SPCD_CA_1}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
path="$(spcd_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_step__packages_update_catalog() {
spcd_step "Update catalog"
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_eval apk update ;;
"${SPCD_PM_APT}") spcd_eval apt-get update ;;
"${SPCD_PM_DNF}") spcd_eval dnf makecache ;;
"${SPCD_PM_PACMAN}") spcd_eval pacman --sync --refresh ;;
"${SPCD_PM_ZYPPER}") spcd_eval zypper refresh ;;
*) ;;
esac
}
spcd_step__packages_install_tools() {
spcd_step "Install tools"
case "${SPCD_PM}" in
"${SPCD_PM_APT}") spcd_f_pm_install "apt-utils" ;;
"${SPCD_PM_APT}") spcd_install_package "apt-utils" ;;
*) ;;
esac
}
@ -1317,13 +1276,13 @@ spcd_step__packages_install_locales() {
spcd_step_out
}
# ╭───┬────╮
# │ s │ ca │
# ╰───┴────╯
# ╭──────┬────╮
# │ step │ ca │
# ╰──────┴────╯
spcd_step__ca_install_package() {
spcd_step "Install package"
spcd_f_pm_install "ca-certificates"
spcd_install_package "ca-certificates"
}
spcd_step__ca_write_certificates() {
@ -1355,39 +1314,60 @@ spcd_step__ca_update_certificates() {
"${SPCD_OS_ALMA}" | \
"${SPCD_OS_FEDORA}" | \
"${SPCD_OS_ROCKY}")
spcd_run update-ca-trust
spcd_eval update-ca-trust
;;
"${SPCD_OS_ALPINE}" | \
"${SPCD_OS_DEBIAN}" | \
"${SPCD_OS_OPENSUSE}" | \
"${SPCD_OS_UBUNTU}")
spcd_run update-ca-certificates
spcd_eval update-ca-certificates
;;
*) ;;
esac
}
# ╭───┬──────────╮
# │ s │ packages │
# ╰───┴──────────╯
# ╭──────┬──────────╮
# │ step │ packages │
# ╰──────┴──────────╯
spcd_step__packages_verify_https() {
spcd_step "Verify HTTPS"
local path
path="$(spcd_https_path)"
if [ -n "${path}" ]; then
spcd_os_rm "${path}"
fi
}
spcd_step__packages_upgrade_system() {
spcd_step "Upgrade system"
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_eval apk upgrade ;;
"${SPCD_PM_APT}") spcd_eval apt-get upgrade --assume-yes ;;
"${SPCD_PM_DNF}") spcd_eval dnf upgrade --assumeyes ;;
"${SPCD_PM_PACMAN}") spcd_eval pacman --sync --sysupgrade --noconfirm ;;
"${SPCD_PM_ZYPPER}") spcd_eval zypper --non-interactive update ;;
*) ;;
esac
}
spcd_step__packages_install_dos2unix() {
spcd_step "Install dos2unix"
spcd_f_pm_install "dos2unix"
spcd_install_package "dos2unix"
}
spcd_step__packages_install_git() {
spcd_step "Install Git"
spcd_f_pm_install "git"
spcd_install_package "git"
}
# ╭───┬────────╮
# │ s │ python │
# ╰───┴────────╯
# ╭──────┬────────╮
# │ step │ python │
# ╰──────┴────────╯
spcd_step__python_install() {
spcd_step "Install package"
spcd_f_pm_install "${SPCD_PYTHON_PACKAGE}"
spcd_install_package "${SPCD_PYTHON_PACKAGE}"
spcd_step "Link alias to command"
spcd_python_ln "${SPCD_PYTHON_COMMAND}"
# venv
@ -1395,7 +1375,7 @@ spcd_step__python_install() {
spcd_step "Install package"
case "${SPCD_OS_ID}" in
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
spcd_f_pm_install "python3-venv"
spcd_install_package "python3-venv"
;;
*) ;;
esac
@ -1445,7 +1425,7 @@ spcd_step__install_packages() {
spcd_step "EPEL"
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}")
spcd_f_pm_install "epel-release"
spcd_install_package "epel-release"
case "${SPCD_OS_VERSION}" in
"9")
set -- \
@ -1477,32 +1457,32 @@ spcd_step__install_packages() {
esac
# graphviz
spcd_step "GraphViz"
spcd_f_pm_install "graphviz"
spcd_install_package "graphviz"
# openssh
spcd_step "OpenSSH"
case "${SPCD_PM}" in
"${SPCD_PM_APK}" | "${SPCD_PM_APT}")
spcd_f_pm_install "openssh-client"
spcd_install_package "openssh-client"
;;
"${SPCD_PM_DNF}" | "${SPCD_PM_ZYPPER}")
spcd_f_pm_install "openssh-clients"
spcd_install_package "openssh-clients"
;;
"${SPCD_PM_PACMAN}") spcd_f_pm_install "openssh" ;;
"${SPCD_PM_PACMAN}") spcd_install_package "openssh" ;;
*) ;;
esac
# plantuml
spcd_step "PlantUML"
spcd_f_pm_install "plantuml"
spcd_install_package "plantuml"
# rsync
spcd_step "Rsync"
spcd_f_pm_install "rsync"
spcd_install_package "rsync"
# shell check
spcd_step "ShellCheck"
case "${SPCD_PM}" in
"${SPCD_PM_DNF}" | "${SPCD_PM_ZYPPER}")
spcd_f_pm_install "ShellCheck"
spcd_install_package "ShellCheck"
;;
*) spcd_f_pm_install "shellcheck" ;;
*) spcd_install_package "shellcheck" ;;
esac
# shfmt
spcd_step "ShellFormat"
@ -1511,10 +1491,10 @@ spcd_step__install_packages() {
"${SPCD_OS_DEBIAN}")
case "${SPCD_OS_VERSION}" in
"bullseye") ;;
*) spcd_f_pm_install "shfmt" ;;
*) spcd_install_package "shfmt" ;;
esac
;;
*) spcd_f_pm_install "shfmt" ;;
*) spcd_install_package "shfmt" ;;
esac
spcd_step_out
}
@ -1575,8 +1555,8 @@ spcd_main() {
spcd_step_in "Packages"
spcd_step__packages_set_repositories
spcd_step__packages_set_configuration
spcd_f_pm_https_trust
spcd_f_pm_update
spcd_step__packages_trust_https
spcd_step__packages_update_catalog
spcd_step__packages_install_tools
spcd_step__packages_install_locales
spcd_step_out
@ -1588,9 +1568,9 @@ spcd_main() {
spcd_step_out
# packages
spcd_step_in "Packages"
spcd_f_pm_https_verify
spcd_f_pm_update
spcd_f_pm_upgrade
spcd_step__packages_verify_https
spcd_step__packages_update_catalog
spcd_step__packages_upgrade_system
spcd_step__packages_install_dos2unix
spcd_step__packages_install_git
spcd_step_out