Compare commits

..

No commits in common. "f92d49fe82572ce69b794259c8108bfa7176c401" and "f3f19abad038751621faa60ebb136d35a7b58ddb" have entirely different histories.

View file

@ -1,5 +1,7 @@
#! /usr/bin/env sh #! /usr/bin/env sh
#╶──────────────────────────────────────╴
# ╭──────────╮ # ╭──────────╮
# │ defaults │ # │ defaults │
# ╰──────────╯ # ╰──────────╯
@ -182,7 +184,7 @@ spcd_os_cat() {
spcd_cat__file="${1}" spcd_cat__file="${1}"
if [ -n "${spcd_cat__file}" ]; then if [ -n "${spcd_cat__file}" ]; then
spcd_frame_open "${spcd_cat__file}" spcd_frame_open "${spcd_cat__file}"
cat "${spcd_cat__file}" cat "${spcd_cat__file}" || exit
spcd_frame_shut "${spcd_cat__file}" spcd_frame_shut "${spcd_cat__file}"
fi fi
} }
@ -249,19 +251,6 @@ spcd_git_url() {
fi fi
} }
# ╭───────────┬─────────╮
# │ functions │ openssl │
# ╰───────────┴─────────╯
spcd_openssl_x509() {
spcd_openssl_x509__file="${1}"
if [ -f "${spcd_openssl_x509__file}" ]; then
openssl x509 \
-in "${spcd_openssl_x509__file}" \
-noout -text
fi
}
# ╭───────────┬────╮ # ╭───────────┬────╮
# │ functions │ os │ # │ functions │ os │
# ╰───────────┴────╯ # ╰───────────┴────╯
@ -305,7 +294,7 @@ spcd_os_rm() {
spcd_os_rm__path="${1}" spcd_os_rm__path="${1}"
if [ -e "${spcd_os_rm__path}" ]; then if [ -e "${spcd_os_rm__path}" ]; then
echo "${spcd_os_rm__path}" echo "${spcd_os_rm__path}"
rm -r "${spcd_os_rm__path}" rm -r "${spcd_os_rm__path}" || exit
fi fi
} }
@ -342,7 +331,7 @@ spcd_python_ln() {
if [ -n "${spcd_python_ln__command}" ]; then if [ -n "${spcd_python_ln__command}" ]; then
echo "${SPCD_PYTHON_ALIAS}${spcd_python_ln__command}" echo "${SPCD_PYTHON_ALIAS}${spcd_python_ln__command}"
ln -f -s "${spcd_python_ln__command}" \ ln -f -s "${spcd_python_ln__command}" \
"/usr/bin/${SPCD_PYTHON_ALIAS}" "/usr/bin/${SPCD_PYTHON_ALIAS}" || exit
fi fi
} }
@ -419,12 +408,12 @@ SPCD_PM_ZYPPER="zypper"
SPCD_PYTHON_VENV="/opt/venv" SPCD_PYTHON_VENV="/opt/venv"
SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin" SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin"
# ╭───────┬───────────── # ╭───────┬─────
# │ steps │ environment # │ steps │ env
# ╰───────┴───────────── # ╰───────┴─────
spcd_environment_set_variables() { spcd_set_environment_variables() {
spcd_step "Set variables" spcd_step "Set environment variables"
# check script first # check script first
[ -n "${SPCD}" ] || spcd_error_ci "SPCD" [ -n "${SPCD}" ] || spcd_error_ci "SPCD"
# continuous integration / github → gitea → forgejo # continuous integration / github → gitea → forgejo
@ -904,47 +893,18 @@ ${SPCD_PYTHON_VENV}/lib/${SPCD_PYTHON_COMMAND}/site-packages"
spcd_os_printenv "SPCD_CA" "SPCD_DL" spcd_os_printenv "SPCD_CA" "SPCD_DL"
} }
spcd_environment_list_workspace() { spcd_list_working_directory() {
spcd_step "List workspace" spcd_step "List working directory"
spcd_lwd__path="$(realpath .)" spcd_lwd__path="$(realpath .)"
spcd_os_ls "${spcd_lwd__path}" spcd_os_ls "${spcd_lwd__path}"
} }
# ╭───────┬───────────╮
# │ steps │ functions │
# ╰───────┴───────────╯
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
}
# ╭───────┬─────╮ # ╭───────┬─────╮
# │ steps │ dns # │ steps │ pkg │
# ╰───────┴─────╯ # ╰───────┴─────╯
spcd_dns() { spcd_set_packages_repositories() {
spcd_step "DNS" spcd_step "Set packages repositories"
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}
"
done
spcd_os_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}"
}
# ╭───────┬──────────╮
# │ steps │ packages │
# ╰───────┴──────────╯
spcd_packages_set_repositories() {
spcd_step "Set repositories"
case "${SPCD_OS_ID}" in case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}") "${SPCD_OS_ALMA}")
case "${SPCD_OS_VERSION}" in case "${SPCD_OS_VERSION}" in
@ -1010,8 +970,8 @@ deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-security main universe
esac esac
} }
spcd_packages_set_configuration() { spcd_set_packages_configuration() {
spcd_step "Set configuration" spcd_step "Set packages configuration"
spcd_os_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}" spcd_os_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}"
case "${SPCD_OS_ID}" in case "${SPCD_OS_ID}" in
"${SPCD_OS_ARCH}") "${SPCD_OS_ARCH}")
@ -1024,21 +984,36 @@ spcd_packages_set_configuration() {
esac esac
} }
spcd_packages_trust_https() { # agnostic steps
spcd_step "Trust HTTPS"
spcd_set_https_verification_off() {
if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
spcd_step "Set HTTPS verification off"
spcd_os_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")" spcd_os_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")"
spcd_os_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}" spcd_os_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}"
fi fi
} }
spcd_packages_update_catalog() { spcd_set_dns_resolving() {
spcd_step "Update catalog" spcd_step "Set DNS resolving"
${SPCD_PM_UPDATE} 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}
"
done
spcd_os_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}"
} }
spcd_packages_install_tools() { spcd_update_packages_catalog() {
spcd_step "Install tools" spcd_step "Update packages catalog"
${SPCD_PM_UPDATE} || exit
}
spcd_install_packages_tools() {
spcd_step "Install packages tools"
spcd_install_package "${SPCD_PKG_PKG}" spcd_install_package "${SPCD_PKG_PKG}"
} }
@ -1061,35 +1036,35 @@ spcd_write_ca_certificates() {
spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt" spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt"
spcd_split spcd_split
spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}" spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}"
spcd_openssl_x509 "${spcd_wcc__path}" spcd_openssl "${spcd_wcc__path}"
done done
} }
spcd_update_ca_certificates() { spcd_update_ca_certificates() {
spcd_step "Update CA certificates" spcd_step "Update CA certificates"
${SPCD_CMD_CA} ${SPCD_CMD_CA} || exit
} }
# ╭───────┬────────── # ╭───────┬─────
# │ steps │ packages # │ steps │ pkg
# ╰───────┴────────── # ╰───────┴─────
spcd_packages_verify_https() { spcd_set_https_verification_on() {
spcd_step "Verify HTTPS" spcd_step "Set HTTPS verification on"
spcd_os_rm "${SPCD_PM_HTTPS_PATH}" spcd_os_rm "${SPCD_PM_HTTPS_PATH}"
} }
spcd_packages_upgrade_system() { spcd_upgrade_packages() {
spcd_step "Upgrade system" spcd_step "Upgrade packages"
${SPCD_PM_UPGRADE} ${SPCD_PM_UPGRADE} || exit
} }
spcd_packages_install_dos2unix() { spcd_install_dos2unix() {
spcd_step "Install dos2unix" spcd_step "Install dos2unix"
spcd_install_package "${SPCD_PKG_DOS2UNIX}" spcd_install_package "${SPCD_PKG_DOS2UNIX}"
} }
spcd_packages_install_git() { spcd_install_git() {
spcd_step "Install Git" spcd_step "Install Git"
spcd_install_package "${SPCD_PKG_GIT}" spcd_install_package "${SPCD_PKG_GIT}"
} }
@ -1098,8 +1073,8 @@ spcd_packages_install_git() {
# │ steps │ python │ # │ steps │ python │
# ╰───────┴────────╯ # ╰───────┴────────╯
spcd_python_install() { spcd_install_python() {
spcd_step "Install package" spcd_step_in "Install Python"
spcd_install_package "${SPCD_PYTHON_PACKAGE}" spcd_install_package "${SPCD_PYTHON_PACKAGE}"
spcd_step "Link alias to command" spcd_step "Link alias to command"
spcd_python_ln "${SPCD_PYTHON_COMMAND}" spcd_python_ln "${SPCD_PYTHON_COMMAND}"
@ -1123,10 +1098,11 @@ index-url = ${SPCD_URL_PYTHON}
export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}" export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}"
export VIRTUAL_ENV="${SPCD_PYTHON_VENV}" export VIRTUAL_ENV="${SPCD_PYTHON_VENV}"
spcd_step_out spcd_step_out
spcd_step_out
} }
spcd_python_modules() { spcd_install_python_modules() {
spcd_step_in "Modules" spcd_step_in "Python modules"
spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}" spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}"
spcd_step "List" spcd_step "List"
spcd_os_ls "${spcd_ipm__target}" spcd_os_ls "${spcd_ipm__target}"
@ -1134,7 +1110,7 @@ spcd_python_modules() {
spcd_ipm__path="$(spcd_python_pip "${SPCD_GIT_MAIN}")" spcd_ipm__path="$(spcd_python_pip "${SPCD_GIT_MAIN}")"
# check matching of file and variable # check matching of file and variable
spcd_step "Check" spcd_step "Check"
spcd_ipm__script="${spcd_ipm__path}/bootstrap.sh" spcd_ipm__script="${spcd_ipm__path}/main.sh"
ls -l "${spcd_ipm__script}" ls -l "${spcd_ipm__script}"
spcd_ipm__check="${spcd_ipm__script}.${SPCD_CMD_SUM}" spcd_ipm__check="${spcd_ipm__script}.${SPCD_CMD_SUM}"
"${SPCD_CMD_SUM}" "${spcd_ipm__script}" >"${spcd_ipm__check}" "${SPCD_CMD_SUM}" "${spcd_ipm__script}" >"${spcd_ipm__check}"
@ -1213,8 +1189,8 @@ spcd_install_packages() {
spcd_step_out spcd_step_out
} }
spcd_python_write_module() { spcd_write_python_module() {
spcd_step "Write module" spcd_step "Write Python module"
for spcd_wpm__variable in \ for spcd_wpm__variable in \
OS_ID OS_VERSION \ OS_ID OS_VERSION \
PROJECT_ROOT PROJECT_PATH PROJECT_NAME \ PROJECT_ROOT PROJECT_PATH PROJECT_NAME \
@ -1232,8 +1208,8 @@ SPCD_STEP = $((SPCD_STEP + 1))
done done
} }
spcd_python_switch() { spcd_switch_to_python() {
spcd_step "Switch" spcd_step "Switch to Python"
spcd_stp__name="$(basename "${SPCD_GIT_MAIN}")" spcd_stp__name="$(basename "${SPCD_GIT_MAIN}")"
echo "\ echo "\
${SPCD_PATH} ${SPCD_PATH}
@ -1244,45 +1220,62 @@ ${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
#╶──────────────────────────────────────╴ #╶──────────────────────────────────────╴
# ╭───────────╮
# │ functions │
# ╰───────────╯
spcd_install_package() {
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
}
spcd_openssl() {
spcd_openssl__file="${1}"
if [ -f "${spcd_openssl__file}" ]; then
openssl x509 \
-in "${spcd_openssl__file}" \
-noout -text ||
exit
fi
}
#╶──────────────────────────────────────╴
# ╭──────╮ # ╭──────╮
# │ main │ # │ main │
# ╰──────╯ # ╰──────╯
spcd_main() { spcd_main() {
# environment # env
spcd_step_in "Environment" spcd_set_environment_variables
spcd_environment_set_variables spcd_list_working_directory
spcd_environment_list_workspace # pkg
spcd_step_out spcd_set_packages_repositories
# dns spcd_set_packages_configuration
spcd_dns #
# packages spcd_set_https_verification_off
spcd_step_in "Packages" spcd_set_dns_resolving
spcd_packages_set_repositories spcd_update_packages_catalog
spcd_packages_set_configuration spcd_install_packages_tools
spcd_packages_trust_https
spcd_packages_update_catalog
spcd_packages_install_tools
spcd_step_out
# ca # ca
spcd_install_ca_certificates spcd_install_ca_certificates
spcd_write_ca_certificates spcd_write_ca_certificates
spcd_update_ca_certificates spcd_update_ca_certificates
# packages # pkg
spcd_step_in "Packages" spcd_set_https_verification_on
spcd_packages_verify_https spcd_update_packages_catalog
spcd_packages_update_catalog spcd_upgrade_packages
spcd_packages_upgrade_system spcd_install_dos2unix
spcd_packages_install_dos2unix spcd_install_git
spcd_packages_install_git
spcd_step_out
# python # python
spcd_step_in "Python" spcd_install_python
spcd_python_install spcd_install_python_modules
spcd_python_modules
spcd_install_packages spcd_install_packages
spcd_python_write_module spcd_write_python_module
spcd_python_switch spcd_switch_to_python
} }
spcd_main spcd_main