Fix progress bar to only update when there is a change (Bug #186945)
authorfuzzyray <fuzzyray@gentoo.org>
Wed, 8 Aug 2007 14:53:25 +0000 (14:53 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Wed, 8 Aug 2007 14:53:25 +0000 (14:53 -0000)
svn path=/; revision=431

trunk/ChangeLog
trunk/src/revdep-rebuild/revdep-rebuild-rewrite

index 8a71eaca6102beab248999e01b9a5124402ddadd..e6385a7423a1bd47ba50503828ca5109e08df865 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-08: Paul Varner <fuzzyray@gentoo.org>
+       * revdep-rebuild: Fix progress bar to only update when there is a
+       change (Bug #186945)
+       * revdep-rebuild: Ensure that we source functions.sh before calling
+       ewarn, etc.
+
 2007-08-06: Paul Varner <fuzzyray@gentoo.org>
        * revdep-rebuild: Fix processing of .la files (Bug #187453)
        * revdep-rebuild: Add -X option back for backwards compatibilty (Bug
index ac3feae48e51d6bf187cda855e365c9864d8ef5f..9d9aa6a0235fe8ab08055295d9e8d05c296a14ff 100755 (executable)
@@ -70,6 +70,7 @@ declare SEARCH_DIRS      # List of dirs to search for executables and libraries
 declare SEARCH_DIRS_MASK # List of dirs not to search
 
 # Other globals:
+declare OLDPROG                # Previous pass through the progress meter
 declare EXACT_PKG              # Versionated atom to emerge
 declare HEAD_TEXT              # Feedback string about the search
 declare LIST                   # Prefix for temporary filenames
@@ -162,9 +163,11 @@ progress() {
                progress() { :; }
        else
                progress() {
+                       local curProg=$(( $1 * 100 / $2 ))
+                       (( curProg == OLDPROG )) && return # no change, output nothing
+                       OLDPROG="$curProg" # must be a global variable
                        (( $1 == $2 )) && local lb=$'\n'
-                       echo -ne '\r                         \r'
-                       echo -n "[ $(( $1 * 100 / $2 ))% ] $lb"
+                       echo -ne '\r                         \r'"[ $curProg% ] $lb"
                }
                progress $@
        fi
@@ -295,6 +298,12 @@ get_args() {
                                sed 's:/var/db/pkg/\(.*\)/CONTENTS:\1:'
                }
        fi
+
+       # Use the color preference from portage
+       export NOCOLOR=$(portageq envvar NOCOLOR)
+       [[ $NOCOLOR = yes || $NOCOLOR = true ]] && export RC_NOCOLOR=yes # HACK! (grr)
+       source /etc/init.d/functions.sh
+       
        # Normalize some EMERGE_OPTIONS
        EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-p/--pretend})
        EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-f/--fetchonly})
@@ -309,10 +318,6 @@ is_real_merge() [[
 ]]
 
 get_args "$@"
-# Use the color preference from portage
-export NOCOLOR=$(portageq envvar NOCOLOR)
-[[ $NOCOLOR = yes || $NOCOLOR = true ]] && export RC_NOCOLOR=yes # HACK! (grr)
-source /etc/init.d/functions.sh
 
 einfo "Configuring search environment for $APP_NAME"