From ac844019f439c6f3290d0a1f78b2b4964d300b63 Mon Sep 17 00:00:00 2001 From: jbu Date: Mon, 20 Jul 2015 15:25:21 +0200 Subject: [PATCH] purge_distfile.sh: Print info if percent changes --- common/xbps-src/shutils/purge_distfiles.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/xbps-src/shutils/purge_distfiles.sh b/common/xbps-src/shutils/purge_distfiles.sh index 215b6ce7bb2..ebcc978978d 100755 --- a/common/xbps-src/shutils/purge_distfiles.sh +++ b/common/xbps-src/shutils/purge_distfiles.sh @@ -23,6 +23,7 @@ purge_distfiles() { msg_error "No srcpkgs/*/template files found. Wrong working directory?" exit 1 fi + percent=-1 for template in ${templates[@]}; do pkg="$(echo "$template" | cut -d / -f 2)" if [ ! -L "srcpkgs/$pkg" ]; then @@ -37,7 +38,11 @@ purge_distfiles() { done fi cur=$((cur + 1)) - printf "\rScanning templates : %3d%% (%d/%d)" $((100*$cur/$max)) $cur $max + pnew=$((100 * cur / max)) + if [ $pnew -ne $percent ]; then + percent=$pnew + printf "\rScanning templates : %3d%% (%d/%d)" $percent $cur $max + fi done echo echo "Number of hashes : ${#my_hashes[@]}" @@ -49,6 +54,7 @@ purge_distfiles() { distfiles=($XBPS_SRCDISTDIR/*/*) max=${#distfiles[@]} cur=0 + percent=-1 for distfile in ${distfiles[@]}; do inode=$(stat "$distfile" --printf "%i") if [ -z "${inodes[$inode]}" ]; then @@ -57,7 +63,11 @@ purge_distfiles() { inodes[$inode]+="|$distfile" fi cur=$((cur + 1)) - printf "\rCollecting inodes : %3d%% (%d/%d)" $((100*$cur/$max)) $cur $max + pnew=$((100 * cur / max)) + if [ $pnew -ne $percent ]; then + percent=$pnew + printf "\rCollecting inodes : %3d%% (%d/%d)" $percent $cur $max + fi done echo