Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/lib/version/check.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/version/check.sh')
-rw-r--r--src/lib/version/check.sh49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/lib/version/check.sh b/src/lib/version/check.sh
index ddd400d..fba2d1a 100644
--- a/src/lib/version/check.sh
+++ b/src/lib/version/check.sh
@@ -8,6 +8,8 @@ DEVTOOLS_INCLUDE_VERSION_CHECK_SH=1
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
# shellcheck source=src/lib/common.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
+# shellcheck source=src/lib/util/term.sh
+source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/term.sh
source /usr/share/makepkg/util/message.sh
@@ -37,11 +39,12 @@ _EOF_
pkgctl_version_check() {
local path
local pkgbases=()
- local path pkgbase upstream_version result
+ local status_file path pkgbase upstream_version result
local up_to_date=()
local out_of_date=()
local failure=()
+ local current_item=0
local section_separator=''
while (( $# )); do
@@ -78,6 +81,10 @@ pkgctl_version_check() {
fi
fi
+ # start a terminal spinner as checking versions takes time
+ status_dir=$(mktemp --tmpdir="${WORKDIR}" --directory pkgctl-version-check-spinner.XXXXXXXXXX)
+ term_spinner_start "${status_dir}"
+
for path in "${pkgbases[@]}"; do
pushd "${path}" >/dev/null
@@ -85,6 +92,16 @@ pkgctl_version_check() {
die "No PKGBUILD found for ${path}"
fi
+ # update the current terminal spinner status
+ (( ++current_item ))
+ pkgctl_version_check_spinner \
+ "${status_dir}" \
+ "${#up_to_date[@]}" \
+ "${#out_of_date[@]}" \
+ "${#failure[@]}" \
+ "${current_item}" \
+ "${#pkgbases[@]}"
+
# reset common PKGBUILD variables
unset pkgbase pkgname arch source pkgver pkgrel validpgpkeys
# shellcheck source=contrib/makepkg/PKGBUILD.proto
@@ -120,6 +137,9 @@ pkgctl_version_check() {
popd >/dev/null
done
+ # stop the terminal spinner after all checks
+ term_spinner_stop "${status_dir}"
+
if (( ${#failure[@]} > 0 )); then
printf "%sFailure%s\n" "${section_separator}${BOLD}${UNDERLINE}" "${ALL_OFF}"
section_separator=$'\n'
@@ -256,3 +276,30 @@ pkgctl_version_check_summary() {
msg_warn " Out-of-date: ${BOLD}${out_of_date_count}${ALL_OFF}" 2>&1
fi
}
+
+pkgctl_version_check_spinner() {
+ local status_dir=$1
+ local up_to_date_count=$2
+ local out_of_date_count=$3
+ local failure_count=$4
+ local current=$5
+ local total=$6
+
+ local percentage=$(( 100 * current / total ))
+ local tmp_file="${status_dir}/tmp"
+ local status_file="${status_dir}/status"
+
+ # print the current summary
+ pkgctl_version_check_summary \
+ "${up_to_date_count}" \
+ "${out_of_date_count}" \
+ "${failure_count}" > "${tmp_file}"
+
+ # print the progress status
+ printf "📡 Checking: %s/%s [%s] %%spinner%%" \
+ "${BOLD}${current}" "${total}" "${percentage}%${ALL_OFF}" \
+ >> "${tmp_file}"
+
+ # swap the status file
+ mv "${tmp_file}" "${status_file}"
+}