Compare commits
No commits in common. "70eaf4bba3b050471f2f73f3f100002b15c86882" and "f67a9478bb852cc3d1f8016834747207dc771183" have entirely different histories.
70eaf4bba3
...
f67a9478bb
1 changed files with 65 additions and 139 deletions
204
spcd/main.sh
204
spcd/main.sh
|
@ -1,42 +1,22 @@
|
|||
#! /usr/bin/env sh
|
||||
|
||||
# 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_DNS_1}" ] || SPCD_DNS_1="9.9.9.9"
|
||||
[ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd"
|
||||
[ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx"
|
||||
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
|
||||
[ -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 │
|
||||
# ╰───────╯
|
||||
[ -n "${SPCD_URL_PYTHON}" ] || SPCD_URL_PYTHON="https://pypi.org/simple"
|
||||
|
||||
# main
|
||||
spcd_main() {
|
||||
# env
|
||||
spcd_set_environment_variables
|
||||
#
|
||||
spcd_list_working_directory
|
||||
# pkg
|
||||
#
|
||||
spcd_set_packages_repositories
|
||||
spcd_set_packages_configuration
|
||||
#
|
||||
|
@ -44,17 +24,14 @@ spcd_main() {
|
|||
spcd_set_dns_resolving
|
||||
spcd_update_packages_catalog
|
||||
spcd_install_packages_tools
|
||||
# ca
|
||||
spcd_install_ca_certificates
|
||||
spcd_write_ca_certificates
|
||||
spcd_update_ca_certificates
|
||||
# pkg
|
||||
spcd_set_https_verification_on
|
||||
spcd_update_packages_catalog
|
||||
spcd_upgrade_packages
|
||||
spcd_install_dos2unix
|
||||
spcd_install_git
|
||||
# python
|
||||
spcd_install_python
|
||||
spcd_install_python_modules
|
||||
spcd_install_packages
|
||||
|
@ -62,9 +39,7 @@ spcd_main() {
|
|||
spcd_switch_to_python
|
||||
}
|
||||
|
||||
# ╭───────┬─────╮
|
||||
# │ steps │ env │
|
||||
# ╰───────┴─────╯
|
||||
# steps
|
||||
|
||||
spcd_set_environment_variables() {
|
||||
spcd_step "Set environment variables"
|
||||
|
@ -146,9 +121,9 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
|||
fi
|
||||
# check project variables
|
||||
case "${SPCD_PROJECT_BRANCH}" in
|
||||
"${SPCD_REF_RELEASE}" | \
|
||||
"${SPCD_REF_STAGING}" | \
|
||||
"${SPCD_REF_FEATURE}") ;;
|
||||
"${SPCD_BRANCH_RELEASE}" | \
|
||||
"${SPCD_BRANCH_STAGING}" | \
|
||||
"${SPCD_BRANCH_FEATURE}") ;;
|
||||
*) spcd_error_ci "SPCD_PROJECT_BRANCH" ;;
|
||||
esac
|
||||
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
|
||||
|
@ -553,10 +528,6 @@ spcd_list_working_directory() {
|
|||
spcd_ls "${spcd_lwd__path}"
|
||||
}
|
||||
|
||||
# ╭───────┬─────╮
|
||||
# │ steps │ pkg │
|
||||
# ╰───────┴─────╯
|
||||
|
||||
spcd_set_packages_repositories() {
|
||||
spcd_step "Set packages repositories"
|
||||
case "${SPCD_OS_ID}" in
|
||||
|
@ -671,10 +642,6 @@ spcd_install_packages_tools() {
|
|||
spcd_install_package "${SPCD_PKG_PKG}"
|
||||
}
|
||||
|
||||
# ╭───────┬────╮
|
||||
# │ steps │ ca │
|
||||
# ╰───────┴────╯
|
||||
|
||||
spcd_install_ca_certificates() {
|
||||
spcd_step "Install CA"
|
||||
spcd_install_package "${SPCD_PKG_CA}"
|
||||
|
@ -699,10 +666,6 @@ spcd_update_ca_certificates() {
|
|||
${SPCD_CMD_CA} || exit
|
||||
}
|
||||
|
||||
# ╭───────┬─────╮
|
||||
# │ steps │ pkg │
|
||||
# ╰───────┴─────╯
|
||||
|
||||
spcd_set_https_verification_on() {
|
||||
spcd_step "Set HTTPS verification on"
|
||||
spcd_rm "${SPCD_PM_HTTPS_PATH}"
|
||||
|
@ -723,10 +686,6 @@ spcd_install_git() {
|
|||
spcd_install_package "${SPCD_PKG_GIT}"
|
||||
}
|
||||
|
||||
# ╭───────┬────────╮
|
||||
# │ steps │ python │
|
||||
# ╰───────┴────────╯
|
||||
|
||||
spcd_install_python() {
|
||||
spcd_step "Install Python"
|
||||
spcd_install_package "${SPCD_PYTHON_PACKAGE}"
|
||||
|
@ -866,9 +825,49 @@ ${SPCD_PYTHON_ALIAS} / ${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__file="${1}"
|
||||
|
@ -901,6 +900,14 @@ 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() {
|
||||
if [ -n "${1}" ]; then
|
||||
spcd_gc__name="$(basename "${1}")"
|
||||
|
@ -1077,92 +1084,11 @@ SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin"
|
|||
SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
|
||||
|
||||
SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}"
|
||||
SPCD_DOWN="${SPCD_BOX_DOWN}${SPCD_HORIZONTAL}"
|
||||
SPCD_VERT="${SPCD_BOX_VERTICAL}"
|
||||
SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}"
|
||||
SPCD___UP="${SPCD_BOX_UP}${SPCD_HORIZONTAL}"
|
||||
SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}"
|
||||
|
||||
# ╭──────────╮
|
||||
# │ 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 │
|
||||
# ╰──────────┴─────╯
|
||||
|
||||
# run
|
||||
spcd_main
|
||||
|
|
Loading…
Reference in a new issue