Compare commits

..

21 commits

Author SHA1 Message Date
70eaf4bba3
steps/ca,pkg,python
Some checks failed
/ job (push) Failing after 5s
2024-08-24 17:11:03 +02:00
a014410c7f
steps/env,pkg 2024-08-24 16:54:07 +02:00
ba4b428ede
steps 2024-08-24 16:40:59 +02:00
d7d6f37648
functions 2024-08-24 16:40:19 +02:00
21b91211ec
spcd_fill 2024-08-24 16:35:32 +02:00
35123c72c1
internal/banner,run 2024-08-24 16:32:20 +02:00
31a0b4d257
internal 2024-08-24 16:20:05 +02:00
6fd8e23029
urls 2024-08-24 16:11:41 +02:00
5633916895
refs 2024-08-24 16:10:36 +02:00
5dd39bc1cb
refs 2024-08-24 15:12:13 +02:00
4be8512ffc
banner/s 2024-08-24 13:15:06 +02:00
5604fb2be7
spcd_banner_add 2024-08-24 13:14:55 +02:00
f1f5004e2a
spcd_banner_append 2024-08-24 13:08:10 +02:00
e87d66c3a9
spcd_banner_unset 2024-08-24 13:05:37 +02:00
517b5b0f68
spcd_banner_echo 2024-08-24 13:04:49 +02:00
b2e3a5db4c
mv 2024-08-24 13:00:25 +02:00
3784d4d6a6
purge 2024-08-24 12:27:25 +02:00
89998d8a65
spcd_banner_wipe 2024-08-24 12:16:43 +02:00
37668ac488
spcd_banner_open 2024-08-24 12:14:22 +02:00
f7ae3796d9
spcd_banner_close 2024-08-24 12:09:33 +02:00
d587944e95
spcd_banner_split 2024-08-24 12:08:30 +02:00

View file

@ -1,22 +1,42 @@
#! /usr/bin/env sh #! /usr/bin/env sh
# defaults # defaults
[ -n "${SPCD_BRANCH_RELEASE}" ] || SPCD_BRANCH_RELEASE="main"
[ -n "${SPCD_BRANCH_STAGING}" ] || SPCD_BRANCH_STAGING="dev"
[ -n "${SPCD_BRANCH_FEATURE}" ] || SPCD_BRANCH_FEATURE="f"
[ -n "${SPCD_CMD_SUM}" ] || SPCD_CMD_SUM="sha512sum" [ -n "${SPCD_CMD_SUM}" ] || SPCD_CMD_SUM="sha512sum"
[ -n "${SPCD_DNS_1}" ] || SPCD_DNS_1="9.9.9.9" [ -n "${SPCD_DNS_1}" ] || SPCD_DNS_1="9.9.9.9"
[ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd" [ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd"
[ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx" [ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx"
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2" [ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
[ -n "${SPCD_URL_PYTHON}" ] || SPCD_URL_PYTHON="https://pypi.org/simple" [ -n "${SPCD_REF_FEATURE}" ] || SPCD_REF_FEATURE="f"
[ -n "${SPCD_REF_RELEASE}" ] || SPCD_REF_RELEASE="main"
[ -n "${SPCD_REF_STAGING}" ] || SPCD_REF_STAGING="dev"
[ -n "${SPCD_URL_ALPINE}" ] ||
SPCD_URL_ALPINE="https://dl-cdn.alpinelinux.org"
[ -n "${SPCD_URL_ARCH}" ] ||
SPCD_URL_ARCH="https://geo.mirror.pkgbuild.com"
[ -n "${SPCD_URL_DEBIAN}" ] ||
SPCD_URL_DEBIAN="https://deb.debian.org"
[ -n "${SPCD_URL_EPEL}" ] ||
SPCD_URL_EPEL="https://dl.fedoraproject.org"
[ -n "${SPCD_URL_FEDORA}" ] ||
SPCD_URL_FEDORA="https://rpmfind.net"
[ -n "${SPCD_URL_OPENSUSE}" ] ||
SPCD_URL_OPENSUSE="https://download.opensuse.org"
[ -n "${SPCD_URL_PYTHON}" ] ||
SPCD_URL_PYTHON="https://pypi.org/simple"
[ -n "${SPCD_URL_ROCKY}" ] ||
SPCD_URL_ROCKY="https://dl.rockylinux.org"
[ -n "${SPCD_URL_UBUNTU}" ] ||
SPCD_URL_UBUNTU="https://ubuntu.mirrors.ovh.net"
# ╭───────╮
# │ steps │
# ╰───────╯
# main
spcd_main() { spcd_main() {
# env
spcd_set_environment_variables spcd_set_environment_variables
#
spcd_list_working_directory spcd_list_working_directory
# # pkg
spcd_set_packages_repositories spcd_set_packages_repositories
spcd_set_packages_configuration spcd_set_packages_configuration
# #
@ -24,14 +44,17 @@ spcd_main() {
spcd_set_dns_resolving spcd_set_dns_resolving
spcd_update_packages_catalog spcd_update_packages_catalog
spcd_install_packages_tools spcd_install_packages_tools
# 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
# pkg
spcd_set_https_verification_on spcd_set_https_verification_on
spcd_update_packages_catalog spcd_update_packages_catalog
spcd_upgrade_packages spcd_upgrade_packages
spcd_install_dos2unix spcd_install_dos2unix
spcd_install_git spcd_install_git
# python
spcd_install_python spcd_install_python
spcd_install_python_modules spcd_install_python_modules
spcd_install_packages spcd_install_packages
@ -39,7 +62,9 @@ spcd_main() {
spcd_switch_to_python spcd_switch_to_python
} }
# steps # ╭───────┬─────╮
# │ steps │ env │
# ╰───────┴─────╯
spcd_set_environment_variables() { spcd_set_environment_variables() {
spcd_step "Set environment variables" spcd_step "Set environment variables"
@ -121,9 +146,9 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
fi fi
# check project variables # check project variables
case "${SPCD_PROJECT_BRANCH}" in case "${SPCD_PROJECT_BRANCH}" in
"${SPCD_BRANCH_RELEASE}" | \ "${SPCD_REF_RELEASE}" | \
"${SPCD_BRANCH_STAGING}" | \ "${SPCD_REF_STAGING}" | \
"${SPCD_BRANCH_FEATURE}") ;; "${SPCD_REF_FEATURE}") ;;
*) spcd_error_ci "SPCD_PROJECT_BRANCH" ;; *) spcd_error_ci "SPCD_PROJECT_BRANCH" ;;
esac esac
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT" [ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
@ -528,6 +553,10 @@ spcd_list_working_directory() {
spcd_ls "${spcd_lwd__path}" spcd_ls "${spcd_lwd__path}"
} }
# ╭───────┬─────╮
# │ steps │ pkg │
# ╰───────┴─────╯
spcd_set_packages_repositories() { spcd_set_packages_repositories() {
spcd_step "Set packages repositories" spcd_step "Set packages repositories"
case "${SPCD_OS_ID}" in case "${SPCD_OS_ID}" in
@ -642,6 +671,10 @@ spcd_install_packages_tools() {
spcd_install_package "${SPCD_PKG_PKG}" spcd_install_package "${SPCD_PKG_PKG}"
} }
# ╭───────┬────╮
# │ steps │ ca │
# ╰───────┴────╯
spcd_install_ca_certificates() { spcd_install_ca_certificates() {
spcd_step "Install CA" spcd_step "Install CA"
spcd_install_package "${SPCD_PKG_CA}" spcd_install_package "${SPCD_PKG_CA}"
@ -666,6 +699,10 @@ spcd_update_ca_certificates() {
${SPCD_CMD_CA} || exit ${SPCD_CMD_CA} || exit
} }
# ╭───────┬─────╮
# │ steps │ pkg │
# ╰───────┴─────╯
spcd_set_https_verification_on() { spcd_set_https_verification_on() {
spcd_step "Set HTTPS verification on" spcd_step "Set HTTPS verification on"
spcd_rm "${SPCD_PM_HTTPS_PATH}" spcd_rm "${SPCD_PM_HTTPS_PATH}"
@ -686,6 +723,10 @@ spcd_install_git() {
spcd_install_package "${SPCD_PKG_GIT}" spcd_install_package "${SPCD_PKG_GIT}"
} }
# ╭───────┬────────╮
# │ steps │ python │
# ╰───────┴────────╯
spcd_install_python() { spcd_install_python() {
spcd_step "Install Python" spcd_step "Install Python"
spcd_install_package "${SPCD_PYTHON_PACKAGE}" spcd_install_package "${SPCD_PYTHON_PACKAGE}"
@ -825,49 +866,9 @@ ${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}" "${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}"
} }
# functions # ╭───────────╮
# │ functions │
spcd_banner() { # ╰───────────╯
unset SPCD_BANNER_1 SPCD_BANNER_2 SPCD_BANNER_3
spcd_banner_add_123 "${SPCD_BOX_DOWN}" "${SPCD_VERT}" "${SPCD_BOX_UP}"
#
spcd_banner__index="${SPCD_STEP}"
[ -n "${SPCD_SUBSTEP}" ] &&
spcd_banner__index="${spcd_banner__index}.${SPCD_SUBSTEP}"
spcd_banner_add "${spcd_banner__index}"
#
for spcd_banner__item in "${SPCD_STEP_TEXT}" "${SPCD_SUBSTEP_TEXT}"; do
if [ -n "${spcd_banner__item}" ]; then
spcd_banner_add_123 "┬" "${SPCD_VERT}" "┴"
spcd_banner_add "${spcd_banner__item}"
fi
done
#
spcd_banner_add_123 "╮" "${SPCD_VERT}" "╯"
#
echo "\
${SPCD_BANNER_1}
${SPCD_BANNER_2}
${SPCD_BANNER_3}"
}
spcd_banner_add() {
if [ -n "${1}" ]; then
spcd_ba__text=" ${1} "
spcd_ba__length=${#spcd_ba__text}
spcd_ba__filler="$(spcd_fill "${spcd_ba__length}")"
spcd_banner_add_123 \
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
fi
}
spcd_banner_add_123() {
if [ -n "${3}" ]; then
SPCD_BANNER_1="${SPCD_BANNER_1}${1}"
SPCD_BANNER_2="${SPCD_BANNER_2}${2}"
SPCD_BANNER_3="${SPCD_BANNER_3}${3}"
fi
}
spcd_cat() { spcd_cat() {
spcd_cat__file="${1}" spcd_cat__file="${1}"
@ -900,14 +901,6 @@ spcd_error_os() {
exit "${SPCD_ERROR_OS}" exit "${SPCD_ERROR_OS}"
} }
spcd_fill() {
spcd_fill__index=${1}
while [ "${spcd_fill__index}" -gt 0 ]; do
printf "%s" "${2}"
spcd_fill__index=$((spcd_fill__index - 1))
done
}
spcd_git_clone() { spcd_git_clone() {
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
spcd_gc__name="$(basename "${1}")" spcd_gc__name="$(basename "${1}")"
@ -1084,11 +1077,92 @@ SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin"
SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈" SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}" SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}"
SPCD_DOWN="${SPCD_BOX_DOWN}${SPCD_HORIZONTAL}"
SPCD_VERT="${SPCD_BOX_VERTICAL}" SPCD_VERT="${SPCD_BOX_VERTICAL}"
SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}" SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}"
SPCD___UP="${SPCD_BOX_UP}${SPCD_HORIZONTAL}"
SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}" SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}"
# run # ╭──────────╮
# │ internal │
# ╰──────────╯
spcd_fill() {
spcd_fill__index=${1}
while [ "${spcd_fill__index}" -gt 0 ]; do
printf "%s" "${2}"
spcd_fill__index=$((spcd_fill__index - 1))
done
}
# ╭──────────┬────────╮
# │ internal │ banner │
# ╰──────────┴────────╯
spcd_banner() {
spcd_banner_unset
spcd_banner_open
#
spcd_banner__index="${SPCD_STEP}"
[ -n "${SPCD_SUBSTEP}" ] &&
spcd_banner__index="${spcd_banner__index}.${SPCD_SUBSTEP}"
spcd_banner_add "${spcd_banner__index}"
#
spcd_banner_add "S"
#
for spcd_banner__item in "${SPCD_STEP_TEXT}" "${SPCD_SUBSTEP_TEXT}"; do
[ -n "${spcd_banner__item}" ] &&
spcd_banner_add "${spcd_banner__item}"
done
#
spcd_banner_close
#
spcd_banner_echo
spcd_banner_unset
}
spcd_banner_add() {
if [ -n "${1}" ]; then
spcd_ba__text=" ${1} "
spcd_ba__length=${#spcd_ba__text}
spcd_ba__filler="$(spcd_fill "${spcd_ba__length}")"
spcd_banner_split
spcd_banner_append \
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
fi
}
spcd_banner_append() {
if [ -n "${3}" ]; then
SPCD_BANNER_1="${SPCD_BANNER_1}${1}"
SPCD_BANNER_2="${SPCD_BANNER_2}${2}"
SPCD_BANNER_3="${SPCD_BANNER_3}${3}"
fi
}
spcd_banner_close() {
spcd_banner_append "╮" "${SPCD_VERT}" "╯"
}
spcd_banner_echo() {
echo "\
${SPCD_BANNER_1}
${SPCD_BANNER_2}
${SPCD_BANNER_3}"
}
spcd_banner_open() {
spcd_banner_append "${SPCD_BOX_DOWN}" "${SPCD_VERT}" "${SPCD_BOX_UP}"
}
spcd_banner_split() {
spcd_banner_append "┬" "${SPCD_VERT}" "┴"
}
spcd_banner_unset() {
unset SPCD_BANNER_1 SPCD_BANNER_2 SPCD_BANNER_3
}
# ╭──────────┬─────╮
# │ internal │ run │
# ╰──────────┴─────╯
spcd_main spcd_main