View | Details | Raw Unified
Collapse All | Expand All

(-) revdep-rebuild.orig (-34 / +37 lines)
 Lines 84-90    Link Here 
  -q, --quiet          Be less verbose (also passed to emerge command)
  -q, --quiet          Be less verbose (also passed to emerge command)
  -v, --verbose        Be more verbose
  -v, --verbose        Be more verbose
  -u, --no-util UTIL   Do not use features provided by UTIL
  -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.
                       or it can be a *quoted* space-delimited list.
  -L, --library NAME   Emerge existing packages that use the library with NAME
  -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
      --library=NAME   NAME can be a full path to the library or a basic
 Lines 110-115    Link Here 
		progress $@
		progress $@
	fi
	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
# Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u
# (If any libs have whitespace in their filenames, someone needs punishment.)
# (If any libs have whitespace in their filenames, someone needs punishment.)
clean_var() {
clean_var() {
 Lines 129-136    Link Here 
# What to do when dynamic linking is consistent
# What to do when dynamic linking is consistent
clean_exit() {
clean_exit() {
	[[ $KEEP_TEMP ]] || rm $LIST.?_*
	[[ $KEEP_TEMP ]] || rm $LIST.?_*
	set_color green
	echo
	die 0 $'\n'"$OK_TEXT... All done. "
	einfo "$OK_TEXT... All done. "
	exit 0
}
}
get_args() {
get_args() {
	appname="${0##*/}"
	appname="${0##*/}"
 Lines 204-215    Link Here 
		shift
		shift
	done
	done
	# Check if various utils are allowed and installed
	# Check if various utils are allowed and installed
	if [[ $avoid_utils != *portage-utils* ]] && hash q 2> /dev/null; then
	if [[ $avoid_utils != *portage-utils* ]] && hash qfile 2> /dev/null; then
		PORTAGE_UTILS=1
		get_file_owner() { qfile -qvC "$@"; }
	elif [[ $avoid_utils != *pkgcore* ]] && hash pquery 2> /dev/null; then
	elif [[ $avoid_utils != *pkgcore* ]] && hash pquery 2> /dev/null; then
		PKGCORE=1
		get_file_owner() { local IFS=,; pquery --nocolor --owns="$*"; }
	elif [[ $avoid_utils != *equery* ]] && hash equery 2> /dev/null; then
	# equery disabled for incompatibility with modern portage.
		EQUERY=1
	# 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
	fi
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-p/--pretend})
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-p/--pretend})
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-f/--fetchonly})
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-f/--fetchonly})
 Lines 339-344    Link Here 
	# Compare old and new environments
	# Compare old and new environments
	# Don't use our previous files if environment doesn't match
	# Don't use our previous files if environment doesn't match
	new_env=$(
	new_env=$(
		# We don't care if these options change
		EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]//--pretend/})
		EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]//--fetchonly/})
		cat <<- EOF
		cat <<- EOF
			SEARCH_DIRS="$SEARCH_DIRS"
			SEARCH_DIRS="$SEARCH_DIRS"
			SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK"
			SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK"
 Lines 519-537    Link Here 
		set_trap "$LIST.4_packages*"
		set_trap "$LIST.4_packages*"
		rm -f $LIST.4*
		rm -f $LIST.4*
		while read obj FILE; do
		while read obj FILE; do
			if [[ $PORTAGE_UTILS ]]; then
			EXACT_PKG=$(get_file_owner $FILE)
				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
			if [[ $EXACT_PKG ]]; then
			if [[ $EXACT_PKG ]]; then
				# Strip version information
				# Strip version information
				PKG="${EXACT_PKG%%-r[[:digit:]]*}"
				PKG="${EXACT_PKG%%-r[[:digit:]]*}"
 Lines 547-552    Link Here 
		done < "$LIST.3_rebuild"
		done < "$LIST.3_rebuild"
		einfo "Generated new $LIST.4_packages_raw and $LIST.4_package_owners"
		einfo "Generated new $LIST.4_packages_raw and $LIST.4_package_owners"
	fi
	fi
	# if we find '(none)' on every line, exit out
	if ! grep -qvF '(none)' "$LIST.4_package_owners"; then
		ewarn "Found some broken files, but none of them were associated with known packages"
		ewarn "Unable to proceed with automatic repairs."
		if [[ $VERBOSE ]]; then
			ewarn "The broken files are:"
			while read filename junk; do
				ewarn "  $filename"
			done < "$LIST.4_package_owners"
		fi
		exit 0 # FIXME: Should we exit 1 here?
	fi
}
}
clean_packages() {
clean_packages() {
	einfo 'Cleaning list of packages to rebuild'
	einfo 'Cleaning list of packages to rebuild'
 Lines 583-601    Link Here 
	elif [[ -rs $LIST.3_rebuild ]]; then
	elif [[ -rs $LIST.3_rebuild ]]; then
		rebuildList=" $(<"$LIST.3_rebuild") "
		rebuildList=" $(<"$LIST.3_rebuild") "
		rebuildList=(${rebuildList//[[:space:]]obj[[:space:]]/ })
		rebuildList=(${rebuildList//[[:space:]]obj[[:space:]]/ })
		if [[ $PORTAGE_UTILS ]]; then
		get_file_owner "${rebuildList[@]}" > $LIST.4_ebuilds
			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
		einfo "Generated new $LIST.4_ebuilds"
		einfo "Generated new $LIST.4_ebuilds"
	else
	else
		einfo 'Nothing to rebuild.'
		einfo 'Nothing to rebuild.'