From a0c0f11aae721ef37dff7a54e6298a7db5544d70 Mon Sep 17 00:00:00 2001 From: Levon Gevorgyan Date: Tue, 21 Oct 2025 11:52:17 -0500 Subject: [PATCH] add spinner to builds --- lib/build.sh | 12 +++++++++--- lib/docker.sh | 13 ++++++++++--- lib/utils.sh | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/lib/build.sh b/lib/build.sh index 76d228e..7c2cebc 100644 --- a/lib/build.sh +++ b/lib/build.sh @@ -375,7 +375,7 @@ do_build() { do_build "${dep}" || return 1 done get_build_conf "${build}" || return 1 - echo_info "building ${build}" + echo_info -n "building ${build} " pushd "$extracted_dir" >/dev/null || return 1 # check for any patches for patch in "${PATCHES_DIR}/${build}"/*.patch; do @@ -383,9 +383,15 @@ do_build() { echo_if_fail patch -p1 -i "${patch}" || return 1 done export LOGNAME="${build}" - local timeBefore=$EPOCHSECONDS - echo_if_fail build_"${build}" + local timeBefore=${EPOCHSECONDS} + echo_if_fail build_"${build}" & + local buildPid=$! + spinner & + local spinPid=$! + wait ${buildPid} retval=$? + kill ${spinPid} + spinner reset popd >/dev/null || return 1 test ${retval} -eq 0 || return ${retval} echo_pass "built ${build} in $((EPOCHSECONDS - timeBefore)) seconds" diff --git a/lib/docker.sh b/lib/docker.sh index e7c7f77..9b1a89b 100644 --- a/lib/docker.sh +++ b/lib/docker.sh @@ -142,16 +142,23 @@ docker_build_image() { echo "RUN ${pkg_mgr_upgrade}" printf "RUN ${pkg_install} %s\n" "${req_pkgs[@]}" fi + # pipx echo 'RUN pipx install virtualenv' echo 'RUN pipx ensurepath' + # rust echo 'ENV CARGO_HOME="/root/.cargo"' echo 'ENV RUSTUP_HOME="/root/.rustup"' echo 'ENV PATH="/root/.cargo/bin:$PATH"' local rustupVersion='1.28.2' local rustcVersion='1.88.0' + local rustupTarball="${DOCKER_DIR}/rustup.tar.gz" + if [[ ! -f ${rustupTarball} ]]; then + wget https://github.com/rust-lang/rustup/archive/refs/tags/${rustupVersion}.tar.gz -O "${rustupTarball}" + fi + + echo "ADD ./rustup.tar.gz /tmp/" local cargoInst='' - cargoInst+="cd tmp && wget https://github.com/rust-lang/rustup/archive/refs/tags/${rustupVersion}.tar.gz -O rustup.tar.gz" - cargoInst+=" && tar -xf rustup.tar.gz && cd rustup-${rustupVersion}" + cargoInst+="cd /tmp/rustup-${rustupVersion}" cargoInst+=" && bash rustup-init.sh -y --default-toolchain=${rustcVersion}" cargoInst+=" && rm -rf /tmp/*" echo "RUN ${cargoInst}" @@ -169,7 +176,7 @@ docker_build_image() { --platform "${PLATFORM}" \ -t "${image_tag}" \ -f "${dockerfile}" \ - . || return 1 + "${DOCKER_DIR}" || return 1 # if a docker registry is defined, push to it if [[ ${DOCKER_REGISTRY} != '' ]]; then diff --git a/lib/utils.sh b/lib/utils.sh index 9128ccf..5a25028 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -10,10 +10,18 @@ YELLOW='\e[0;33m' NC='\e[0m' # echo wrappers -echo_fail() { echo -e "${RED}FAIL${NC}:" "$@"; } -echo_info() { echo -e "${CYAN}INFO${NC}:" "$@"; } -echo_pass() { echo -e "${GREEN}PASS${NC}:" "$@"; } -echo_warn() { echo -e "${YELLOW}WARN${NC}:" "$@"; } +echo_wrapper() { + local args + if [[ $1 == '-n' ]]; then + args=("$1") + shift + fi + echo -e "${args[@]}" "${color}${word}${NC}" "$@" +} +echo_fail() { color="${RED}" word="FAIL" echo_wrapper "$@"; } +echo_info() { color="${CYAN}" word="INFO" echo_wrapper "$@"; } +echo_pass() { color="${GREEN}" word="PASS" echo_wrapper "$@"; } +echo_warn() { color="${YELLOW}" word="WARN" echo_wrapper "$@"; } echo_exit() { echo_fail "$@" exit 1 @@ -269,3 +277,23 @@ bash_sort() { printf '%s\n' "${arr[@]}" } + +spinner() { + if [[ $1 == 'reset' ]]; then + echo -ne ' \n' + return 0 + fi + + local spinChars=( + "-" + '\' + "|" + "/" + ) + while true; do + for ((ind = 0; ind < "${#spinChars[@]}"; ind++)); do + echo -ne "${spinChars[${ind}]}" '\b\b' + sleep .25 + done + done +}