diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -632,7 +632,6 @@ QUIETREDIR="/dev/stderr" QUIETFLAG=" " STATSREDIR="/dev/stderr" - DDSTATS=".." XARGST="-t" NDEBUG=" " ;; @@ -640,7 +639,6 @@ QUIETREDIR="" QUIETFLAG="" STATSREDIR="/dev/null" - DDSTATS=".." XARGST="" NDEBUG="" ;; @@ -648,7 +646,6 @@ QUIETREDIR="/dev/null" QUIETFLAG="-q" STATSREDIR="/dev/stdout" - DDSTATS="" XARGST="" NDEBUG="-n" ;; @@ -1186,16 +1183,26 @@ # Print user-friendly progress statistics fetch_progress () { - LNC=0 + # Prompt + local FPMPT="$1" + # Total count + local FCNT=$2 + # Local variables + local LNC=0 + local _pstr="" + printf "%s... " "${FPMPT}" while read x; do - LNC=$(($LNC + 1)) - if [ $(($LNC % 10)) = 0 ]; then - echo -n $LNC - elif [ $(($LNC % 2)) = 0 ]; then - echo -n . + if [ "${VERBOSELEVEL}" != "nostats" ]; then + LNC=$(($LNC + 1)) + if [ $(($LNC % 2)) = 0 ]; then + _pstr=`printf "%s... %d/%d" "${FPMPT}" ${LNC} ${FCNT}` + printf "\r%-${#_pstr}s\r%s" "" "${_pstr}" + fi fi done - echo -n " " + # Print length-of-last-progress-string number of spaces followed + # by the final string. + printf "\r%-${#_pstr}s\r%s... done.\n" "" "${FPMPT}" } # Function for asking the user if everything is ok @@ -1438,13 +1445,12 @@ if [ -s patchlist ]; then # Attempt to fetch metadata patches - echo -n "Fetching `wc -l < patchlist | tr -d ' '` " - echo ${NDEBUG} "metadata patches.${DDSTATS}" + local _totalf=`wc -l < patchlist | tr -d ' '` + local _pmpt="Fetching ${_totalf} metadata patches" tr '|' '-' < patchlist | lam -s "${FETCHDIR}/tp/" - -s ".gz" | xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \ - 2>${STATSREDIR} | fetch_progress - echo "done." + 2>${STATSREDIR} | fetch_progress "${_pmpt}" ${_totalf} # Attempt to apply metadata patches echo -n "Applying metadata patches... " @@ -1979,13 +1985,12 @@ fetch_files () { # Attempt to fetch patches if [ -s patchlist ]; then - echo -n "Fetching `wc -l < patchlist | tr -d ' '` " - echo ${NDEBUG} "patches.${DDSTATS}" + local _totalf=`wc -l < patchlist | tr -d ' '` + local _pmpt="Fetching ${_totalf} patches" tr '|' '-' < patchlist | lam -s "${PATCHDIR}/" - | xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \ - 2>${STATSREDIR} | fetch_progress - echo "done." + 2>${STATSREDIR} | fetch_progress "${_pmpt}" ${_totalf} # Attempt to apply patches echo -n "Applying patches... " @@ -2013,12 +2018,13 @@ done < files.wanted > filelist if [ -s filelist ]; then - echo -n "Fetching `wc -l < filelist | tr -d ' '` " - echo ${NDEBUG} "files... " + local _totalf=`wc -l < filelist | tr -d ' '` + local _pmpt="Fetching ${_totalf} files" lam -s "${FETCHDIR}/f/" - -s ".gz" < filelist | xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \ - 2>${STATSREDIR} | fetch_progress + 2>${STATSREDIR} | fetch_progress "${_pmpt}" ${_totalf} + echo -n "Extracting patches and verifying checksums... " while read Y; do if ! [ -f ${Y}.gz ]; then echo "failed."