--- revdep-rebuild.orig 2007-07-10 14:57:28.000000000 -0400 +++ revdep-rebuild 2007-07-10 16:13:56.000000000 -0400 @@ -84,7 +84,7 @@ -q, --quiet Be less verbose (also passed to emerge command) -v, --verbose Be more verbose -u, --no-util UTIL Do not use features provided by UTIL - --no-util=UTIL UTIL can be one of portage-utils, pkgcore, or equery + --no-util=UTIL UTIL can be one of portage-utils or pkgcore or it can be a *quoted* space-delimited list. -L, --library NAME Emerge existing packages that use the library with NAME --library=NAME NAME can be a full path to the library or a basic @@ -110,6 +110,9 @@ progress $@ fi } +# Get the name of a package owning a file on the filesystem using one of several +# utilities: This is a placeholder. The function is defined in get_args() +get_file_owner() { :; } # Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u # (If any libs have whitespace in their filenames, someone needs punishment.) clean_var() { @@ -204,12 +207,20 @@ shift done # Check if various utils are allowed and installed - if [[ $avoid_utils != *portage-utils* ]] && hash q 2> /dev/null; then - PORTAGE_UTILS=1 + if [[ $avoid_utils != *portage-utils* ]] && hash qfile 2> /dev/null; then + get_file_owner() { qfile -qvC "$@"; } elif [[ $avoid_utils != *pkgcore* ]] && hash pquery 2> /dev/null; then - PKGCORE=1 - elif [[ $avoid_utils != *equery* ]] && hash equery 2> /dev/null; then - EQUERY=1 + get_file_owner() { local IFS=,; pquery --nocolor --owns="$*"; } + # equery disabled for incompatibility with modern portage. + # elif [[ $avoid_utils != *equery* ]] && hash equery 2> /dev/null; then + # get_file_owner() { equery -q -C b $@; } + else + get_file_owner() { + local IFS=$'\n' + find /var/db/pkg -name CONTENTS -print0 | + xargs -0 grep -Fl "$*" | + sed 's:/var/db/pkg/\(.*\)/CONTENTS:\1:' + } fi EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-p/--pretend}) EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-f/--fetchonly}) @@ -519,19 +530,7 @@ set_trap "$LIST.4_packages*" rm -f $LIST.4* while read obj FILE; do - if [[ $PORTAGE_UTILS ]]; then - EXACT_PKG=$(qfile -qvC $FILE) - elif [[ $PKGCORE ]]; then - EXACT_PKG=$(pquery --nocolor --owns="$FILE") - elif [[ $EQUERY ]]; then - EXACT_PKG=$(equery -q -C b $FILE) - else - EXACT_PKG=$( - find /var/db/pkg -name CONTENTS | - xargs grep -Fl "obj $FILE " | - sed -e 's:/var/db/pkg/\(.*\)/CONTENTS:\1:g' - ) - fi + EXACT_PKG=$(get_file_owner $FILE) if [[ $EXACT_PKG ]]; then # Strip version information PKG="${EXACT_PKG%%-r[[:digit:]]*}" @@ -583,19 +582,7 @@ elif [[ -rs $LIST.3_rebuild ]]; then rebuildList=" $(<"$LIST.3_rebuild") " rebuildList=(${rebuildList//[[:space:]]obj[[:space:]]/ }) - if [[ $PORTAGE_UTILS ]]; then - qfile -qvC ${rebuildList[@]} - elif [[ $PKGCORE ]]; then - IFS=, - pquery --nocolor --owns="${rebuildList[*]}" - IFS="$oIFS" - elif [[ $EQUERY ]]; then - equery -q -C b ${rebuildList[@]} - else - find /var/db/pkg -name CONTENTS | - xargs grep -Fl "$rebuildList" | - sed 's:/var/db/pkg/\(.*\)/CONTENTS:=\1:' - fi > $LIST.4_ebuilds + get_file_owner "${rebuildList[@]}" > $LIST.4_ebuilds einfo "Generated new $LIST.4_ebuilds" else einfo 'Nothing to rebuild.'