Compare commits

..

No commits in common. "351c9742ef29283df0b9a0f02343612e70037ab0" and "31ca2c6117fd9726944205e63f20163b207d570a" have entirely different histories.

2 changed files with 121 additions and 129 deletions

View file

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

View file

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