Speedup portageq queries. Include FuzzyRay's patch to respect EMERGE_DEFAULT_OPTS.
authoridl0r <idl0r@gentoo.org>
Fri, 30 Oct 2009 14:02:08 +0000 (14:02 -0000)
committeridl0r <idl0r@gentoo.org>
Fri, 30 Oct 2009 14:02:08 +0000 (14:02 -0000)
svn path=/trunk/gentoolkit/; revision=697

ChangeLog
bin/revdep-rebuild

index 955a1ce1e8ff336f543179f36ba449db6f7ef4f3..b5b0442e41fb7c7db8548aabfbed4cde11dac903 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-10-30: Christian Ruppert <idl0r@gentoo.org>
+       * revdep-rebuild: Speedup portageq queries. Include FuzzyRay's patch to
+               respect EMERGE_DEFAULT_OPTS.
+
 2009-10-27: Christian Ruppert <idl0r@gentoo.org>
        * revdep-rebuild: Use realpath in get_file_owner to be able to get the
                package containing e.g. /lib/libreadline.so.6 on amd64, fixes bug 280341.
index b6d4eeda6be1c5e698f3edfdea39387e601cf936..55a4d6be4a0288720075eccb17bc51ba8f99ce6d 100755 (executable)
@@ -89,6 +89,7 @@ declare WORKING_DIR            # Working directory where cache files are kept
 
 main() {
        # preliminary setup
+       portage_settings
        get_opts "$@"
        setup_portage
        setup_search_paths_and_masks
@@ -280,7 +281,6 @@ normalize_emerge_opts() {
 setup_color() {
        # This should still work if NOCOLOR is set by the -C flag or in the user's
        # environment.
-       export NOCOLOR=$(portageq envvar NOCOLOR)
        [[ $NOCOLOR = yes || $NOCOLOR = true ]] && export RC_NOCOLOR=yes # HACK! (grr)
        . /etc/init.d/functions.sh
 }
@@ -971,12 +971,38 @@ show_unowned_files() {
                done < "$OWNERS_FILE" | gawk '!s[$0]++' # (omit dupes)
        fi
 }
+
+# Get multiple portage variables at once to speedup revdep-rebuild.
+portage_settings() {
+       local results=()
+
+       local query_vars=(
+               ROOT
+               PORTAGE_NICENESS
+               EMERGE_DEFAULT_OPTS
+               NOCOLOR
+               SEARCH_DIRS
+               SEARCH_DIRS_MASK
+               LD_LIBRARY_MASK
+       )
+
+       # one value per line
+       IFS=$'\n'
+       results=( $(unset SEARCH_DIRS; unset SEARCH_DIRS_MASK; unset LD_LIBRARY_MASK; portageq envvar ${query_vars[*]}) )
+       IFS=$OIFS
+
+       PORTAGE_ROOT=${results[0]}
+       PORTAGE_NICENESS=${results[1]}
+       EMERGE_DEFAULT_OPTS=${results[2]}
+       export NOCOLOR=${results[3]}
+       SEARCH_DIRS+=" "${results[4]}
+       SEARCH_DIRS_MASK+=" "${results[5]}
+       LD_LIBRARY_MASK+=" "${results[6]}
+}
+
 ##
 # Setup portage and the search paths
 setup_portage() {
-       local PORTAGE_NICENESS=$(portageq envvar PORTAGE_NICENESS)
-       PORTAGE_ROOT=$(portageq envvar ROOT)
-
        # Obey PORTAGE_NICENESS
        if [[ $PORTAGE_NICENESS ]]; then
                renice $PORTAGE_NICENESS $$ > /dev/null
@@ -1001,9 +1027,9 @@ setup_search_paths_and_masks() {
        # Read the incremental variables from environment and portage
        # Until such time as portage supports these variables as incrementals
        # The value will be what is in /etc/make.conf
-       SEARCH_DIRS+=" "$(unset SEARCH_DIRS; portageq envvar SEARCH_DIRS)
-       SEARCH_DIRS_MASK+=" "$(unset SEARCH_DIRS_MASK; portageq envvar SEARCH_DIRS_MASK)
-       LD_LIBRARY_MASK+=" "$(unset LD_LIBRARY_MASK; portageq envvar LD_LIBRARY_MASK)
+#      SEARCH_DIRS+=" "$(unset SEARCH_DIRS; portageq envvar SEARCH_DIRS)
+#      SEARCH_DIRS_MASK+=" "$(unset SEARCH_DIRS_MASK; portageq envvar SEARCH_DIRS_MASK)
+#      LD_LIBRARY_MASK+=" "$(unset LD_LIBRARY_MASK; portageq envvar LD_LIBRARY_MASK)
 
        # Add the defaults
        if [[ -d /etc/revdep-rebuild ]]; then
@@ -1056,7 +1082,7 @@ rebuild() {
        trap - SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
 
        einfo 'All prepared. Starting rebuild'
-       echo "emerge --oneshot ${EMERGE_OPTIONS[@]} $REBUILD_LIST"
+       echo "emerge --oneshot ${EMERGE_OPTIONS[@]} ${EMERGE_DEFAULT_OPTS} $REBUILD_LIST"
 
        is_real_merge && countdown 10
 
@@ -1065,7 +1091,7 @@ rebuild() {
 
        # Run in background to correctly handle Ctrl-C
        {
-               EMERGE_DEFAULT_OPTS="--oneshot ${EMERGE_OPTIONS[@]}" emerge $REBUILD_LIST <&6
+               emerge --oneshot ${EMERGE_OPTIONS[@]} ${EMERGE_DEFAULT_OPTS} $REBUILD_LIST <&6
                echo $? > "$STATUS_FILE"
        } &
        wait