Compare commits

..

33 commits

Author SHA1 Message Date
428d6aebf4
__/banner
All checks were successful
/ job (push) Successful in 10m6s
2024-08-26 16:38:46 +02:00
ad23eb5180
rm/1 2024-08-26 16:33:15 +02:00
96ec535b83
;; 2024-08-26 16:28:37 +02:00
5e86e7368b
__/level 2024-08-26 16:27:44 +02:00
3a35802eb8
__/step 2024-08-26 16:19:21 +02:00
c823709b4f
_/banner 2024-08-26 16:06:14 +02:00
008312a322
cat/1 2024-08-26 15:59:25 +02:00
a3b2abb004
_/os 2024-08-26 15:20:30 +02:00
82468ed374
_/ci 2024-08-26 15:19:31 +02:00
ea06b2f3ff
wipe 2024-08-26 15:17:58 +02:00
068e1153ac
_/render 2024-08-26 15:13:28 +02:00
9e059a986b
_/echo 2024-08-26 15:09:16 +02:00
70537dde13
_/open 2024-08-26 15:07:53 +02:00
eee9247959
_/unset 2024-08-26 15:04:38 +02:00
54d86066e8
_/split 2024-08-26 15:01:45 +02:00
24fc9ca044
mv 2024-08-26 15:00:11 +02:00
544e53c301
_/shut 2024-08-26 14:59:46 +02:00
33480c3702
_/append 2024-08-26 14:58:34 +02:00
060f5f5f5b
_/add_index 2024-08-26 14:56:40 +02:00
edfe4dd55a
_/add 2024-08-26 14:51:20 +02:00
3305069fea
unset 2024-08-26 14:48:36 +02:00
535d3479a6
_/fill 2024-08-26 14:47:50 +02:00
ceeb7337a2
defaults 2024-08-26 14:42:24 +02:00
bf680b6fda
internals 2024-08-26 14:39:29 +02:00
f5402050c0
−rules 2024-08-26 14:37:50 +02:00
04a6a0c15e
_/wipe 2024-08-26 14:34:01 +02:00
95a1c81f39
_/level 2024-08-26 14:33:12 +02:00
54cbb59542
rule/rename 2024-08-26 14:25:48 +02:00
34222be571
_/rule 2024-08-26 14:23:48 +02:00
e6dcf63631
_/cat 2024-08-26 14:22:25 +02:00
3d64af5378
_/frame 2024-08-26 14:19:59 +02:00
0dd882da0d
frame/top,bottom 2024-08-26 14:07:01 +02:00
a83a128587
↕/↔ 2024-08-26 14:02:45 +02:00
2 changed files with 135 additions and 138 deletions

View file

@ -213,11 +213,8 @@ Handle project workflows in a unified way:
### Shell ### Shell
* banner
* constants for characters
* dynamic substeps
* comment * comment
* frame corners * drawing characters constants
* packages * packages
* configure * configure
* apk * apk

View file

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