Compare commits
No commits in common. "428d6aebf414c99250084878a6ed88ea6e59e016" and "979dc07d982835418f76e4eef3bf4d561aac33a0" have entirely different histories.
428d6aebf4
...
979dc07d98
2 changed files with 138 additions and 135 deletions
|
@ -213,8 +213,11 @@ Handle project workflows in a unified way:
|
|||
|
||||
### Shell
|
||||
|
||||
* banner
|
||||
* constants for characters
|
||||
* dynamic substeps
|
||||
* comment
|
||||
* drawing characters constants
|
||||
* frame corners
|
||||
* packages
|
||||
* configure
|
||||
* apk
|
||||
|
|
|
@ -5,18 +5,13 @@
|
|||
# ╰──────────╯
|
||||
|
||||
[ -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}" ] ||
|
||||
|
@ -36,55 +31,56 @@
|
|||
[ -n "${SPCD_URL_UBUNTU}" ] ||
|
||||
SPCD_URL_UBUNTU="https://ubuntu.mirrors.ovh.net"
|
||||
|
||||
# ╭───────────╮
|
||||
# │ internals │
|
||||
# ╰───────────╯
|
||||
#╶──────────────────────────────────────╴
|
||||
|
||||
_spcd_fill() {
|
||||
_spcd_fill__index=${1}
|
||||
while [ "${_spcd_fill__index}" -gt 0 ]; do
|
||||
# ╭──────────╮
|
||||
# │ internal │
|
||||
# ╰──────────╯
|
||||
|
||||
spcd_fill() {
|
||||
spcd_fill__index=${1}
|
||||
while [ "${spcd_fill__index}" -gt 0 ]; do
|
||||
printf "%s" "${2}"
|
||||
_spcd_fill__index=$((_spcd_fill__index - 1))
|
||||
spcd_fill__index=$((spcd_fill__index - 1))
|
||||
done
|
||||
unset _spcd_fill__index
|
||||
}
|
||||
|
||||
# ╭───────────┬────────╮
|
||||
# │ internals │ banner │
|
||||
# ╰───────────┴────────╯
|
||||
# ╭──────────┬────────╮
|
||||
# │ internal │ banner │
|
||||
# ╰──────────┴────────╯
|
||||
|
||||
_SPCD_BANNER_DOWN_AND_HORIZONTAL="┬"
|
||||
_SPCD_BANNER_DOWN_AND_LEFT="╮"
|
||||
_SPCD_BANNER_DOWN_AND_RIGHT="╭"
|
||||
_SPCD_BANNER_HORIZONTAL="─"
|
||||
_SPCD_BANNER_UP_AND_HORIZONTAL="┴"
|
||||
_SPCD_BANNER_UP_AND_LEFT="╯"
|
||||
_SPCD_BANNER_UP_AND_RIGHT="╰"
|
||||
_SPCD_BANNER_VERTICAL="│"
|
||||
SPCD_BANNER_DOWN_AND_HORIZONTAL="┬"
|
||||
SPCD_BANNER_DOWN_AND_LEFT="╮"
|
||||
SPCD_BANNER_DOWN_AND_RIGHT="╭"
|
||||
SPCD_BANNER_HORIZONTAL="─"
|
||||
SPCD_BANNER_UP_AND_HORIZONTAL="┴"
|
||||
SPCD_BANNER_UP_AND_LEFT="╯"
|
||||
SPCD_BANNER_UP_AND_RIGHT="╰"
|
||||
SPCD_BANNER_VERTICAL="│"
|
||||
|
||||
_spcd_banner_add() {
|
||||
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_HORIZONTAL}"
|
||||
spcd_fill "${spcd_ba__length}" "${SPCD_BANNER_HORIZONTAL}"
|
||||
)"
|
||||
if [ -n "${__SPCD_BANNER_MIDDLE}" ]; then
|
||||
_spcd_banner_split
|
||||
if [ -n "${SPCD_BANNER_MIDDLE}" ]; then
|
||||
spcd_banner_split
|
||||
else
|
||||
_spcd_banner_open
|
||||
spcd_banner_open
|
||||
fi
|
||||
_spcd_banner_append \
|
||||
spcd_banner_append \
|
||||
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
|
||||
fi
|
||||
}
|
||||
|
||||
_spcd_banner_add_index() {
|
||||
spcd_banner_add_index() {
|
||||
unset spcd_bai__label
|
||||
unset spcd_bai__level
|
||||
while true; do
|
||||
spcd_bai__level=$((spcd_bai__level + 1))
|
||||
eval "spcd_bai__value=\"\${__SPCD_STEP_${spcd_bai__level}_INDEX}\""
|
||||
eval "spcd_bai__value=\"\${SPCD_STEP_${spcd_bai__level}_INDEX}\""
|
||||
[ -n "${spcd_bai__value}" ] || break
|
||||
if [ -n "${spcd_bai__label}" ]; then
|
||||
spcd_bai__label="${spcd_bai__label}.${spcd_bai__value}"
|
||||
|
@ -92,125 +88,126 @@ _spcd_banner_add_index() {
|
|||
spcd_bai__label="${spcd_bai__value}"
|
||||
fi
|
||||
done
|
||||
_spcd_banner_add "${spcd_bai__label}"
|
||||
spcd_banner_add "${spcd_bai__label}"
|
||||
}
|
||||
|
||||
_spcd_banner_append() {
|
||||
spcd_banner_append() {
|
||||
if [ -n "${3}" ]; then
|
||||
__SPCD_BANNER_TOP="${__SPCD_BANNER_TOP}${1}"
|
||||
__SPCD_BANNER_MIDDLE="${__SPCD_BANNER_MIDDLE}${2}"
|
||||
__SPCD_BANNER_BOTTOM="${__SPCD_BANNER_BOTTOM}${3}"
|
||||
SPCD_BANNER_TOP="${SPCD_BANNER_TOP}${1}"
|
||||
SPCD_BANNER_MIDDLE="${SPCD_BANNER_MIDDLE}${2}"
|
||||
SPCD_BANNER_BOTTOM="${SPCD_BANNER_BOTTOM}${3}"
|
||||
fi
|
||||
}
|
||||
|
||||
_spcd_banner_echo() {
|
||||
spcd_banner_close() {
|
||||
spcd_banner_append \
|
||||
"${SPCD_BANNER_DOWN_AND_LEFT}" \
|
||||
"${SPCD_BANNER_VERTICAL}" \
|
||||
"${SPCD_BANNER_UP_AND_LEFT}"
|
||||
}
|
||||
|
||||
spcd_banner_echo() {
|
||||
echo "\
|
||||
${__SPCD_BANNER_TOP}
|
||||
${__SPCD_BANNER_MIDDLE}
|
||||
${__SPCD_BANNER_BOTTOM}"
|
||||
${SPCD_BANNER_TOP}
|
||||
${SPCD_BANNER_MIDDLE}
|
||||
${SPCD_BANNER_BOTTOM}"
|
||||
}
|
||||
|
||||
_spcd_banner_open() {
|
||||
_spcd_banner_append \
|
||||
"${_SPCD_BANNER_DOWN_AND_RIGHT}" \
|
||||
"${_SPCD_BANNER_VERTICAL}" \
|
||||
"${_SPCD_BANNER_UP_AND_RIGHT}"
|
||||
spcd_banner_open() {
|
||||
spcd_banner_append \
|
||||
"${SPCD_BANNER_DOWN_AND_RIGHT}" \
|
||||
"${SPCD_BANNER_VERTICAL}" \
|
||||
"${SPCD_BANNER_UP_AND_RIGHT}"
|
||||
}
|
||||
|
||||
_spcd_banner_render() {
|
||||
_spcd_banner_wipe
|
||||
_spcd_banner_add "S"
|
||||
_spcd_banner_add_index
|
||||
spcd_banner_render() {
|
||||
spcd_banner_unset
|
||||
spcd_banner_add_index
|
||||
spcd_banner_add "S"
|
||||
#
|
||||
unset spcd_br__level
|
||||
while true; do
|
||||
spcd_br__level=$((spcd_br__level + 1))
|
||||
eval "spcd_br__value=\"\${__SPCD_STEP_${spcd_br__level}_LABEL}\""
|
||||
eval "spcd_br__value=\"\${SPCD_STEP_${spcd_br__level}_LABEL}\""
|
||||
[ -n "${spcd_br__value}" ] || break
|
||||
_spcd_banner_add "${spcd_br__value}"
|
||||
spcd_banner_add "${spcd_br__value}"
|
||||
done
|
||||
#
|
||||
_spcd_banner_shut
|
||||
_spcd_banner_echo
|
||||
_spcd_banner_wipe
|
||||
spcd_banner_close
|
||||
spcd_banner_echo
|
||||
spcd_banner_unset
|
||||
}
|
||||
|
||||
_spcd_banner_shut() {
|
||||
_spcd_banner_append \
|
||||
"${_SPCD_BANNER_DOWN_AND_LEFT}" \
|
||||
"${_SPCD_BANNER_VERTICAL}" \
|
||||
"${_SPCD_BANNER_UP_AND_LEFT}"
|
||||
spcd_banner_split() {
|
||||
spcd_banner_append \
|
||||
"${SPCD_BANNER_DOWN_AND_HORIZONTAL}" \
|
||||
"${SPCD_BANNER_VERTICAL}" \
|
||||
"${SPCD_BANNER_UP_AND_HORIZONTAL}"
|
||||
}
|
||||
|
||||
_spcd_banner_split() {
|
||||
_spcd_banner_append \
|
||||
"${_SPCD_BANNER_DOWN_AND_HORIZONTAL}" \
|
||||
"${_SPCD_BANNER_VERTICAL}" \
|
||||
"${_SPCD_BANNER_UP_AND_HORIZONTAL}"
|
||||
}
|
||||
|
||||
_spcd_banner_wipe() {
|
||||
spcd_banner_unset() {
|
||||
unset \
|
||||
__SPCD_BANNER_TOP \
|
||||
__SPCD_BANNER_MIDDLE \
|
||||
__SPCD_BANNER_BOTTOM
|
||||
SPCD_BANNER_TOP \
|
||||
SPCD_BANNER_MIDDLE \
|
||||
SPCD_BANNER_BOTTOM
|
||||
}
|
||||
|
||||
# ╭───────────┬───────╮
|
||||
# │ internals │ error │
|
||||
# ╰───────────┴───────╯
|
||||
# ╭──────────┬───────╮
|
||||
# │ internal │ error │
|
||||
# ╰──────────┴───────╯
|
||||
|
||||
_SPCD_ERROR_CI=1
|
||||
_SPCD_ERROR_OS=2
|
||||
SPCD_ERROR_CI=1
|
||||
SPCD_ERROR_OS=2
|
||||
|
||||
# ╭───────────┬───────╮
|
||||
# │ internals │ frame │
|
||||
# ╰───────────┴───────╯
|
||||
# ╭──────────┬───────╮
|
||||
# │ internal │ frame │
|
||||
# ╰──────────┴───────╯
|
||||
|
||||
_SPCD_FRAME_TOP="╭╴"
|
||||
_SPCD_FRAME_BOTTOM="╰╴"
|
||||
SPCD_FRAME_DOWN_AND_RIGHT="╭"
|
||||
SPCD_FRAME_UP_AND_RIGHT="╰"
|
||||
|
||||
_spcd_frame_open() {
|
||||
echo "${_SPCD_FRAME_TOP}${1}"
|
||||
spcd_frame_open() {
|
||||
echo "${SPCD_FRAME_DOWN_AND_RIGHT}${1}"
|
||||
}
|
||||
|
||||
_spcd_frame_shut() {
|
||||
echo "${_SPCD_FRAME_BOTTOM}${1}"
|
||||
spcd_frame_shut() {
|
||||
echo "${SPCD_FRAME_UP_AND_RIGHT}${1}"
|
||||
}
|
||||
|
||||
# ╭───────────┬────╮
|
||||
# │ internals │ os │
|
||||
# ╰───────────┴────╯
|
||||
# ╭──────────┬────╮
|
||||
# │ internal │ os │
|
||||
# ╰──────────┴────╯
|
||||
|
||||
_spcd_os_cat() {
|
||||
if [ -n "${1}" ]; then
|
||||
_spcd_frame_open "${1}"
|
||||
cat "${1}"
|
||||
_spcd_frame_shut "${1}"
|
||||
spcd_os_cat() {
|
||||
spcd_cat__file="${1}"
|
||||
if [ -n "${spcd_cat__file}" ]; then
|
||||
spcd_frame_open "${spcd_cat__file}"
|
||||
cat "${spcd_cat__file}"
|
||||
spcd_frame_shut "${spcd_cat__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
# ╭───────────┬──────╮
|
||||
# │ internals │ rule │
|
||||
# ╰───────────┴──────╯
|
||||
# ╭──────────┬──────╮
|
||||
# │ internal │ rule │
|
||||
# ╰──────────┴──────╯
|
||||
|
||||
_SPCD_RULE_LEFT="╶"
|
||||
_SPCD_RULE_MIDDLE="─"
|
||||
_SPCD_RULE_RIGHT="╴"
|
||||
SPCD_RULE_HORIZONTAL="─"
|
||||
SPCD_RULE_LEFT="╴"
|
||||
SPCD_RULE_RIGHT="╶"
|
||||
|
||||
# ╭───────────┬──────╮
|
||||
# │ internals │ step │
|
||||
# ╰───────────┴──────╯
|
||||
# ╭──────────┬──────╮
|
||||
# │ internal │ step │
|
||||
# ╰──────────┴──────╯
|
||||
|
||||
_spcd_step_wipe() {
|
||||
SPCD_STEP_LEVEL=1
|
||||
|
||||
spcd_step_wipe() {
|
||||
unset \
|
||||
"__SPCD_STEP_${__SPCD_STEP_LEVEL}_INDEX" \
|
||||
"__SPCD_STEP_${__SPCD_STEP_LEVEL}_LABEL"
|
||||
"SPCD_STEP_${SPCD_STEP_LEVEL}_INDEX" \
|
||||
"SPCD_STEP_${SPCD_STEP_LEVEL}_LABEL"
|
||||
}
|
||||
|
||||
# ╭───────────╮
|
||||
# │ functions │
|
||||
# ╰───────────╯
|
||||
#╶──────────────────────────────────────╴
|
||||
|
||||
# ╭───────────┬───────╮
|
||||
# │ functions │ error │
|
||||
|
@ -218,14 +215,14 @@ _spcd_step_wipe() {
|
|||
|
||||
spcd_error_ci() {
|
||||
echo "× CI: ${*}"
|
||||
exit "${_SPCD_ERROR_CI}"
|
||||
exit "${SPCD_ERROR_CI}"
|
||||
}
|
||||
|
||||
spcd_error_os() {
|
||||
spcd_error_os__variable="${1}"
|
||||
printf "× OS: "
|
||||
spcd_os_printenv "${spcd_error_os__variable}"
|
||||
exit "${_SPCD_ERROR_OS}"
|
||||
exit "${SPCD_ERROR_OS}"
|
||||
}
|
||||
|
||||
# ╭───────────┬─────╮
|
||||
|
@ -280,9 +277,9 @@ spcd_os_grep() {
|
|||
spcd_os_ls() {
|
||||
spcd_os_ls__path="${1}"
|
||||
if [ -n "${spcd_os_ls__path}" ]; then
|
||||
_spcd_frame_open "${spcd_os_ls__path}"
|
||||
spcd_frame_open "${spcd_os_ls__path}"
|
||||
ls -a -l "${spcd_os_ls__path}"
|
||||
_spcd_frame_shut "${spcd_os_ls__path}"
|
||||
spcd_frame_shut "${spcd_os_ls__path}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -305,9 +302,10 @@ spcd_os_printenv() {
|
|||
}
|
||||
|
||||
spcd_os_rm() {
|
||||
if [ -e "${1}" ]; then
|
||||
echo "← ${1}"
|
||||
rm -r "${1}"
|
||||
spcd_os_rm__path="${1}"
|
||||
if [ -e "${spcd_os_rm__path}" ]; then
|
||||
echo "← ${spcd_os_rm__path}"
|
||||
rm -r "${spcd_os_rm__path}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -315,10 +313,10 @@ spcd_os_sed() {
|
|||
spcd_os_sed__file="${1}"
|
||||
shift
|
||||
if [ -f "${spcd_os_sed__file}" ]; then
|
||||
_spcd_os_cat "${spcd_os_sed__file}"
|
||||
spcd_os_cat "${spcd_os_sed__file}"
|
||||
for spcd_os_sed__regex in "${@}"; do
|
||||
sed --in-place "s${spcd_os_sed__regex}g" "${spcd_os_sed__file}" &&
|
||||
_spcd_os_cat "${spcd_os_sed__file}"
|
||||
spcd_os_cat "${spcd_os_sed__file}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
@ -328,10 +326,10 @@ spcd_os_write() {
|
|||
spcd_os_write__text="${2}"
|
||||
if [ -n "${spcd_os_write__file}" ]; then
|
||||
[ -f "${spcd_os_write__file}" ] &&
|
||||
_spcd_os_cat "${spcd_os_write__file}"
|
||||
spcd_os_cat "${spcd_os_write__file}"
|
||||
echo "→ ${spcd_os_write__file}"
|
||||
printf "%s" "${spcd_os_write__text}" >"${spcd_os_write__file}"
|
||||
_spcd_os_cat "${spcd_os_write__file}"
|
||||
spcd_os_cat "${spcd_os_write__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -364,7 +362,7 @@ spcd_python_pip() {
|
|||
# ╰───────────┴───────╯
|
||||
|
||||
spcd_split() {
|
||||
echo "${_SPCD_RULE_LEFT}${_SPCD_RULE_MIDDLE}${_SPCD_RULE_RIGHT}"
|
||||
echo "${SPCD_RULE_RIGHT}${SPCD_RULE_HORIZONTAL}${SPCD_RULE_LEFT}"
|
||||
}
|
||||
|
||||
# ╭───────────┬──────╮
|
||||
|
@ -373,29 +371,26 @@ 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__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
|
||||
spcd_banner_render
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_step_in() {
|
||||
[ -n "${1}" ] && spcd_step "${1}"
|
||||
__SPCD_STEP_LEVEL=$((__SPCD_STEP_LEVEL + 1))
|
||||
_spcd_step_wipe
|
||||
SPCD_STEP_LEVEL=$((SPCD_STEP_LEVEL + 1))
|
||||
spcd_step_wipe
|
||||
}
|
||||
|
||||
spcd_step_out() {
|
||||
_spcd_step_wipe
|
||||
__SPCD_STEP_LEVEL=$((__SPCD_STEP_LEVEL - 1))
|
||||
spcd_step_wipe
|
||||
SPCD_STEP_LEVEL=$((SPCD_STEP_LEVEL - 1))
|
||||
}
|
||||
|
||||
# ╭───────╮
|
||||
# │ steps │
|
||||
# ╰───────╯
|
||||
#╶──────────────────────────────────────╴
|
||||
|
||||
# ╭───────┬───────────╮
|
||||
# │ steps │ constants │
|
||||
|
@ -943,8 +938,10 @@ installonly_limit=3
|
|||
skip_if_unavailable=False
|
||||
"
|
||||
;;
|
||||
"${SPCD_PM_APK}") ;;
|
||||
"${SPCD_PM_PACMAN}") ;;
|
||||
"${SPCD_PM_APK}")
|
||||
;;
|
||||
"${SPCD_PM_PACMAN}")
|
||||
;;
|
||||
"${SPCD_PM_APT}")
|
||||
spcd_os_write "/etc/apt/apt.conf.d/apt.conf" "\
|
||||
Acquire::Check-Valid-Until True;
|
||||
|
@ -954,7 +951,8 @@ APT::Install-Suggests False;
|
|||
Dir::Etc::SourceParts \"\";
|
||||
"
|
||||
;;
|
||||
"${SPCD_PM_ZYPPER}") ;;
|
||||
"${SPCD_PM_ZYPPER}")
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
case "${SPCD_OS_ID}" in
|
||||
|
@ -1211,7 +1209,7 @@ spcd_python_write_module() {
|
|||
spcd_wpm__text="${spcd_wpm__text}${spcd_wpm__value}
|
||||
"
|
||||
done
|
||||
spcd_wpm__index=$((__SPCD_STEP_1_INDEX + 1))
|
||||
spcd_wpm__index=$((SPCD_STEP_1_INDEX + 1))
|
||||
for spcd_wpm__root in \
|
||||
"${SPCD_PYTHON_PACKAGES}" "${SPCD_PYTHON_VENV_PACKAGES}"; do
|
||||
spcd_os_write "${spcd_wpm__root}/env.py" "${spcd_wpm__text}
|
||||
|
@ -1230,6 +1228,8 @@ ${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
|
|||
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}"
|
||||
}
|
||||
|
||||
#╶──────────────────────────────────────╴
|
||||
|
||||
# ╭──────╮
|
||||
# │ main │
|
||||
# ╰──────╯
|
||||
|
|
Loading…
Reference in a new issue