Fix incorrect flag status display if a flag appears multiple times in a single location
authorgenone <genone@gentoo.org>
Thu, 10 May 2007 11:49:39 +0000 (11:49 -0000)
committergenone <genone@gentoo.org>
Thu, 10 May 2007 11:49:39 +0000 (11:49 -0000)
svn path=/; revision=398

trunk/ChangeLog
trunk/src/euse/euse

index 65512dc3af188dff33830ae629bfe143b55c881f..7890e8e938577b8a284f271c03e3916366b48816 100644 (file)
@@ -1,3 +1,7 @@
+2007-05-10: Marius Mauch <genone@gentoo.org>
+       * euse: Fix incorrect flag status display when a flag appears multiple
+       times in a single location
+
 2007-04-25: Paul Varner <fuzzyray@gentoo.org>
        * echangelog: Re-added subversion/git support with fixes from genstef.
        (Bug #136048)
index 4bb3e6fe7ce52b9bd6ccca1fcd380a2533d2f9c3..8814e287a8a1694e4c8285429603c97329887d27 100755 (executable)
@@ -111,6 +111,26 @@ showversion() {
        echo "This is free software; see the source for copying conditions."
 }
 
+# remove duplicate flags from the given list in both positive and negative forms
+# (but unlike portage always keep the last value even if it's negative)
+# Otherwise the status flags could be incorrect if a flag appers multiple times in
+# one location (like make.conf).
+# Using python here as bash sucks for list handling.
+reduce_incrementals() {
+       echo $@ | python -c "import sys
+r=[]
+for x in sys.stdin.read().split():
+       if x[0] == '-' and x[1:] in r:
+               r.remove(x[1:])
+               r.append(x)
+       elif x[0] != '-' and '-'+x in r:
+               r.remove('-'+x)
+               r.append(x)
+       elif x not in r:
+               r.append(x)
+print ' '.join(r)" 
+}
+
 # the following function creates a bash array ACTIVE_FLAGS that contains the
 # global use flags, indexed by origin: 0: environment, 1: make.conf, 
 # 2: make.defaults, 3: make.globals
@@ -121,18 +141,18 @@ get_useflags() {
        # backup portdir so get_portdir() doesn't give false results later
        portdir_backup="${PORTDIR}"
 
-       ACTIVE_FLAGS[0]="${USE}"
+       ACTIVE_FLAGS[0]="$(reduce_incrementals ${USE})"
        USE=""
        source "${MAKE_CONF_PATH}"
-       ACTIVE_FLAGS[1]="${USE}"
+       ACTIVE_FLAGS[1]="$(reduce_incrementals ${USE})"
        USE=""
        for x in $(get_all_make_defaults); do
                source "${x}"
-               ACTIVE_FLAGS[2]="${ACTIVE_FLAGS[2]} ${USE}"
+               ACTIVE_FLAGS[2]="$(reduce_incrementals ${ACTIVE_FLAGS[2]} ${USE})"
        done
        USE=""
        source "${MAKE_GLOBALS_PATH}"
-       ACTIVE_FLAGS[3]="${USE}"
+       ACTIVE_FLAGS[3]="$(reduce_incrementals ${USE})"
 
        # restore saved env variables
        USE="${ACTIVE_FLAGS[0]}"