Compare commits

...

21 commits

Author SHA1 Message Date
351c9742ef
−test/local
Some checks failed
/ arch (push) Successful in 3m6s
/ alpine (push) Successful in 1m55s
/ fedora (push) Successful in 7m49s
/ debian (push) Failing after 5m44s
/ opensuse (push) Successful in 3m16s
/ ubuntu (push) Successful in 10m31s
/ alma (push) Successful in 6m43s
/ rocky (push) Successful in 6m55s
2024-08-31 11:10:19 +02:00
746f3968f2
switch 2024-08-31 11:00:17 +02:00
1b71ed0c13
module 2024-08-31 10:58:49 +02:00
4974430c36
disable 2024-08-31 10:56:03 +02:00
25e08725a8
packages 2024-08-31 10:54:54 +02:00
5c0956c09b
modules 2024-08-31 10:03:23 +02:00
6be00f1655
locales 2024-08-31 09:59:39 +02:00
417d22dff1
verify 2024-08-31 09:55:10 +02:00
225a48ee21
ca 2024-08-31 09:54:01 +02:00
c21b751b72
trust 2024-08-31 09:50:20 +02:00
a599e31cb1
repos 2024-08-31 09:38:12 +02:00
05636f94f3
dns 2024-08-31 09:32:52 +02:00
263643ab20
tasks/query 2024-08-31 09:31:41 +02:00
1c5b7d138d
pip 2024-08-31 09:30:59 +02:00
014d10bf98
ln 2024-08-31 09:29:48 +02:00
88f3f036b0
filler 2024-08-31 09:27:22 +02:00
da24f0ccd8
clone 2024-08-31 09:26:10 +02:00
2b950472ed
workspace 2024-08-31 09:21:24 +02:00
5053dca4fb
print 2024-08-31 09:19:46 +02:00
b00e8881a4
locale 2024-08-31 09:18:14 +02:00
6475063e3e
step 2024-08-31 09:13:25 +02:00
2 changed files with 129 additions and 121 deletions

View file

@ -255,6 +255,7 @@ Handle project workflows in a unified way:
* venv
* create
* activate
* query package
* relay environment module name
#### Python

View file

@ -27,9 +27,10 @@ _SPCD_BANNER_VERTICAL="│"
_spcd_banner_add() {
if [ -n "${1}" ]; then
local text=" ${1} "
local length=${#text}
local filler="$(_spcd_fill "${length}" "${_SPCD_BANNER_HORIZONTAL}")"
local text length filler
text=" ${1} "
length=${#text}
filler="$(_spcd_fill "${length}" "${_SPCD_BANNER_HORIZONTAL}")"
if [ -n "${__SPCD_BANNER_MIDDLE}" ]; then
_spcd_banner_split
else
@ -299,10 +300,10 @@ spcd_split() {
spcd_step() {
if [ -n "${1}" ]; then
[ -n "${__SPCD_STEP_LEVEL}" ] || __SPCD_STEP_LEVEL=1
spcd_step__prefix="__SPCD_STEP_${__SPCD_STEP_LEVEL}"
spcd_step__index="${spcd_step__prefix}_INDEX"
eval "${spcd_step__index}=\$((${spcd_step__index} + 1))"
eval "${spcd_step__prefix}_LABEL=\"${1}\""
local prefix="__SPCD_STEP_${__SPCD_STEP_LEVEL}"
local index="${prefix}_INDEX"
eval "${index}=\$((${index} + 1))"
eval "${prefix}_LABEL=\"${1}\""
_spcd_banner_render
fi
}
@ -334,12 +335,14 @@ spcd_txt_get() {
spcd_txt_locale() {
# LANGUAGE
local name
local value
if [ -n "${1}" ]; then
spcd_step__locale__value="${1}"
value="${1}"
else
spcd_step__locale__value="${_SPCD_TXT_LOCALE_DEFAULT}"
value="${_SPCD_TXT_LOCALE_DEFAULT}"
fi
spcd_step__locale__value="${spcd_step__locale__value}.${_SPCD_TXT_CHARSET}"
value="${value}.${_SPCD_TXT_CHARSET}"
set -- \
"LANG" \
"LC_CTYPE" \
@ -354,8 +357,8 @@ spcd_txt_locale() {
"LC_TELEPHONE" \
"LC_MEASUREMENT" \
"LC_IDENTIFICATION"
for spcd_step__locale__name in "${@}"; do
export "${spcd_step__locale__name}=${spcd_step__locale__value}"
for name in "${@}"; do
export "${name}=${value}"
done
}
@ -408,11 +411,14 @@ spcd_step__environment_defaults_print() {
"URL_PYTHON" \
"URL_ROCKY" \
"URL_UBUNTU"
for spcd_step_edp__item in "${@}"; do
spcd_step_edp__name="SPCD_${spcd_step_edp__item}"
eval "spcd_step_edp__value=\"\${${spcd_step_edp__name}}\""
if [ -n "${spcd_step_edp__value}" ]; then
spcd_os_printenv "${spcd_step_edp__name}"
local item
local name
local value
for item in "${@}"; do
name="SPCD_${item}"
eval "value=\"\${${name}}\""
if [ -n "${value}" ]; then
spcd_os_printenv "${name}"
fi
done
}
@ -750,8 +756,7 @@ ${SPCD_PYTHON_VENV}/lib/${SPCD_PYTHON_COMMAND}/site-packages"
spcd_step__environment_list_workspace() {
spcd_step "List workspace"
spcd_lwd__path="$(realpath .)"
spcd_os_ls "${spcd_lwd__path}"
spcd_os_ls "$(realpath .)"
}
# ╭──────┬───────────╮
@ -771,11 +776,12 @@ spcd_clean_cache() {
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}")"
git clone "${spcd_gc__url}" "${spcd_gc__path}"
echo "${spcd_gc__path}"
local name path url
name="$(basename "${1}")"
path="${SPCD_DL}/${name}"
url="$(spcd_git_url "${1}")"
git clone "${url}" "${path}"
echo "${path}"
fi
}
@ -813,22 +819,23 @@ spcd_install_package() {
}
spcd_python_ln() {
spcd_python_ln__command="${1}"
if [ -n "${spcd_python_ln__command}" ]; then
echo "${SPCD_PYTHON_ALIAS}${spcd_python_ln__command}"
ln -f -s "${spcd_python_ln__command}" \
local command="${1}"
if [ -n "${command}" ]; then
echo "${SPCD_PYTHON_ALIAS}${command}"
ln -f -s "${command}" \
"/usr/bin/${SPCD_PYTHON_ALIAS}"
fi
}
spcd_python_pip() {
if [ -n "${1}" ]; then
spcd_pp__name="$(basename "${1}")"
spcd_pp__path="$(spcd_git_clone "${1}")"
spcd_pp__path="${spcd_pp__path}/${spcd_pp__name}"
spcd_pp__target="${SPCD_PYTHON_VENV_PACKAGES}"
cp --recursive "${spcd_pp__path}" "${spcd_pp__target}"
echo "${spcd_pp__target}/${spcd_pp__name}"
local name path target
name="$(basename "${1}")"
path="$(spcd_git_clone "${1}")"
path="${path}/${name}"
target="${SPCD_PYTHON_VENV_PACKAGES}"
cp --recursive "${path}" "${target}"
echo "${target}/${name}"
fi
}
@ -849,15 +856,16 @@ spcd_query_package() {
spcd_step__dns() {
spcd_step "DNS"
local index value text
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}\
nameserver ${spcd_sdr__value}
index=$((index + 1))
eval "value=\"\${SPCD_DNS_${index}}\""
[ -n "${value}" ] || break
text="${text}\
nameserver ${value}
"
done
spcd_os_write "/etc/resolv.conf" "${spcd_sdr__text}"
spcd_os_write "/etc/resolv.conf" "${text}"
}
# ╭──────┬──────────╮
@ -866,6 +874,7 @@ nameserver ${spcd_sdr__value}
spcd_step__packages_set_repositories() {
spcd_step "Set repositories"
local file
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}")
case "${SPCD_OS_VERSION}" in
@ -897,8 +906,8 @@ spcd_step__packages_set_repositories() {
;;
*) ;;
esac
for spcd_spr__file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/almalinux${spcd_spr__file}.repo" \
for file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/almalinux${file}.repo" \
"|^mirrorlist|#mirrorlist|" \
"|https://repo.almalinux.org|${SPCD_URL_ALMA}|" \
"|^# baseurl|baseurl|"
@ -928,14 +937,14 @@ deb ${SPCD_URL_DEBIAN}-security ${SPCD_OS_VERSION}-security main
"-updates-testing" \
"-updates" \
""
for spcd_spr__file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/fedora${spcd_spr__file}.repo" \
for file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/fedora${file}.repo" \
"|^metalink|#metalink|" "\
|http://download.example/pub/fedora/linux|${SPCD_URL_FEDORA}|" \
"|^#baseurl|baseurl|"
done
spcd_os_sed "/etc/yum.repos.d/fedora-cisco-openh264.repo" \
"|^enabled=1|#enabled=0|"
"|^enabled=1|enabled=0|"
;;
"${SPCD_OS_OPENSUSE}")
set -- \
@ -952,12 +961,12 @@ deb ${SPCD_URL_DEBIAN}-security ${SPCD_OS_VERSION}-security main
"source" \
"update-non-oss" \
"update"
for spcd_spr__file in "${@}"; do
spcd_os_sed "/etc/zypp/repos.d/repo-${spcd_spr__file}.repo" \
for file in "${@}"; do
spcd_os_sed "/etc/zypp/repos.d/repo-${file}.repo" \
"|http://download.opensuse.org|${SPCD_URL_OPENSUSE}|"
done
spcd_os_sed "/etc/zypp/repos.d/repo-openh264.repo" \
"|^enabled=1|#enabled=0|"
"|^enabled=1|enabled=0|"
;;
"${SPCD_OS_ROCKY}")
case "${SPCD_OS_VERSION}" in
@ -986,8 +995,8 @@ deb ${SPCD_URL_DEBIAN}-security ${SPCD_OS_VERSION}-security main
;;
*) ;;
esac
for spcd_spr__file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/${spcd_spr__file}.repo" \
for file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/${file}.repo" \
"|^mirrorlist|#mirrorlist|" \
"|http://dl.rockylinux.org|${SPCD_URL_ROCKY}|" \
"|^#baseurl|baseurl|"
@ -1045,28 +1054,29 @@ Dir::Etc::SourceParts \"\";
spcd_step__packages_trust_https() {
spcd_step "Trust HTTPS"
local path text
if [ -n "${SPCD_CA_1}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
spcd_pth__path="$(spcd_https_path)"
if [ -n "${spcd_pth__path}" ]; then
spcd_os_mkdir "$(dirname "${spcd_pth__path}")"
path="$(spcd_https_path)"
if [ -n "${path}" ]; then
spcd_os_mkdir "$(dirname "${path}")"
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_pth__text="\
"${SPCD_PM_APK}") text="\
--no-verify
" ;;
"${SPCD_PM_APT}") spcd_pth__text="\
"${SPCD_PM_APT}") text="\
Acquire::https::Verify-Peer False;
" ;;
"${SPCD_PM_DNF}") spcd_pth__text="\
"${SPCD_PM_DNF}") text="\
sslverify=False
" ;;
"${SPCD_PM_PACMAN}") spcd_pth__text="\
"${SPCD_PM_PACMAN}") text="\
SSLVerify = No
" ;;
"${SPCD_PM_ZYPPER}") ;;
*) ;;
esac
[ -n "${spcd_pth__text}" ] &&
spcd_os_write "${spcd_pth__path}" "${spcd_pth__text}"
[ -n "${text}" ] &&
spcd_os_write "${path}" "${text}"
fi
fi
}
@ -1102,30 +1112,31 @@ spcd_step__ca_install_package() {
spcd_step__ca_write_certificates() {
spcd_step "Write certificates"
local root index text path
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
spcd_wcc__root="/etc/pki/ca-trust/source/anchors"
root="/etc/pki/ca-trust/source/anchors"
;;
"${SPCD_OS_ALPINE}" | "${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
spcd_wcc__root="/usr/local/share/ca-certificates"
root="/usr/local/share/ca-certificates"
;;
"${SPCD_OS_ARCH}")
spcd_wcc__root="/etc/ca-certificates/trust-source/anchors"
root="/etc/ca-certificates/trust-source/anchors"
;;
"${SPCD_OS_OPENSUSE}")
spcd_wcc__root="/etc/pki/trust/anchors"
root="/etc/pki/trust/anchors"
;;
*) ;;
esac
spcd_os_mkdir "${spcd_wcc__root}"
spcd_os_mkdir "${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_wcc__root}/${spcd_wcc__index}.crt"
index=$((index + 1))
eval "text=\"\${SPCD_CA_${index}}\""
[ -n "${text}" ] || break
path="${root}/${index}.crt"
spcd_split
spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}"
spcd_openssl_x509 "${spcd_wcc__path}"
spcd_os_write "${path}" "${text}"
spcd_openssl_x509 "${path}"
done
}
@ -1154,9 +1165,10 @@ spcd_step__ca_update_certificates() {
spcd_step__packages_verify_https() {
spcd_step "Verify HTTPS"
spcd_pvh__path="$(spcd_https_path)"
if [ -n "${spcd_pvh__path}" ]; then
spcd_os_rm "${spcd_pvh__path}"
local path
path="$(spcd_https_path)"
if [ -n "${path}" ]; then
spcd_os_rm "${path}"
fi
}
@ -1168,21 +1180,20 @@ spcd_step__packages_install_locales() {
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_install_package "musl-locales" ;;
"${SPCD_PM_APT}")
unset spcd_step__pil__text
for spcd_step__pil__locale in "${@}"; do
spcd_step__pil__text="${spcd_step__pil__text}\
${spcd_step__pil__locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
local locale text
for locale in "${@}"; do
text="${text}\
${locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
"
done
spcd_os_write "/etc/locale.gen" "${spcd_step__pil__text}"
spcd_os_write "/etc/locale.gen" "${text}"
spcd_install_package "locales"
;;
"${SPCD_PM_DNF}")
for spcd_step__pil__locale in "${@}"; do
spcd_step__pil__lang="$(
echo "${spcd_step__pil__locale}" | cut -d _ -f 1
)"
spcd_install_package "glibc-langpack-${spcd_step__pil__lang}"
local locale language
for locale in "${@}"; do
language="$(echo "${locale}" | cut -d _ -f 1)"
spcd_install_package "glibc-langpack-${language}"
done
;;
"${SPCD_PM_PACMAN}") spcd_install_package "glibc-locales" ;;
@ -1247,31 +1258,33 @@ index-url = ${SPCD_URL_PYTHON}/simple
spcd_step__python_modules() {
spcd_step_in "Modules"
spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}"
local target path script check
target="${SPCD_PYTHON_VENV_PACKAGES}"
spcd_step "List"
spcd_os_ls "${spcd_ipm__target}"
spcd_os_ls "${target}"
spcd_step "Main"
spcd_ipm__path="$(spcd_python_pip "${SPCD_GIT_SPCD}")"
path="$(spcd_python_pip "${SPCD_GIT_SPCD}")"
# check matching of file and variable
spcd_step "Check"
spcd_ipm__script="${spcd_ipm__path}/bootstrap.sh"
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"
script="${path}/bootstrap.sh"
ls -l "${script}"
check="${script}.${SPCD_CMD_SUM}"
"${SPCD_CMD_SUM}" "${script}" >"${check}"
printf "%s" "${SPCD}" >"${script}"
ls -l "${script}"
dos2unix "${script}"
ls -l "${script}"
"${SPCD_CMD_SUM}" -c "${check}" || spcd_error_ci "SPCD"
spcd_step "Root"
spcd_python_pip "${SPCD_GIT_RWX}"
spcd_step "List"
spcd_os_ls "${spcd_ipm__target}"
spcd_os_ls "${target}"
spcd_step_out
}
spcd_step__install_packages() {
spcd_step_in "OS packages"
local file
# epel
spcd_step "EPEL"
case "${SPCD_OS_ID}" in
@ -1292,16 +1305,16 @@ spcd_step__install_packages() {
;;
*) ;;
esac
for spcd_spr__file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/epel${spcd_spr__file}.repo" \
for file in "${@}"; do
spcd_os_sed "/etc/yum.repos.d/epel${file}.repo" \
"|^metalink|#metalink|" \
"|https://download.example/pub/epel|${SPCD_URL_EPEL}|" \
"|^#baseurl|baseurl|"
done
spcd_spr__file="/etc/yum.repos.d/epel-cisco-openh264.repo"
file="/etc/yum.repos.d/epel-cisco-openh264.repo"
if [ -f "${spcd_spr__file}" ]; then
spcd_os_sed "${spcd_spr__file}" \
"|^enabled=1|#enabled=0|"
spcd_os_sed "${file}" \
"|^enabled=1|enabled=0|"
fi
;;
*) ;;
@ -1352,48 +1365,42 @@ spcd_step__install_packages() {
spcd_step__python_write_module() {
spcd_step "Write module"
for spcd_wpm__variable in \
local variable value text index root
for 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_os_printenv "SPCD_${spcd_wpm__variable}")"
spcd_wpm__text="${spcd_wpm__text}${spcd_wpm__value}
value="$(spcd_os_printenv "SPCD_${variable}")"
text="${text}${value}
"
done
spcd_wpm__index=$((__SPCD_STEP_1_INDEX + 1))
for spcd_wpm__root in \
index=$((__SPCD_STEP_1_INDEX + 1))
for root in \
"${SPCD_PYTHON_PACKAGES}" "${SPCD_PYTHON_VENV_PACKAGES}"; do
spcd_os_write "${spcd_wpm__root}/env.py" "${spcd_wpm__text}
SPCD_STEP = ${spcd_wpm__index}
spcd_os_write "${root}/env.py" "${text}
SPCD_STEP = ${index}
"
done
}
spcd_step__python_switch() {
spcd_step "Switch"
spcd_stp__name="$(basename "${SPCD_GIT_SPCD}")"
spcd_stp__path="$(realpath "${0}")"
local name path
name="$(basename "${SPCD_GIT_SPCD}")"
path="$(realpath "${0}")"
echo "\
${spcd_stp__path}
${path}
${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}"
${SPCD_PYTHON_ALIAS} / ${name}"
"${SPCD_PYTHON_ALIAS}" -m "${name}"
}
# ╭──────╮
# │ main │
# ╰──────╯
spcd_test_local() {
local local_variable="KO!"
non_local_variable="OK"
}
spcd_main() {
spcd_test_local
echo "local_variable = \"${local_variable}\""
echo "non_local_variable = \"${non_local_variable}\""
# environment
spcd_txt_locale
#