Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 184042 | Differences between
and this patch

Collapse All | Expand All

(-)revdep-rebuild.orig (-34 / +37 lines)
Lines 84-90 Link Here
84
  -q, --quiet          Be less verbose (also passed to emerge command)
84
  -q, --quiet          Be less verbose (also passed to emerge command)
85
  -v, --verbose        Be more verbose
85
  -v, --verbose        Be more verbose
86
  -u, --no-util UTIL   Do not use features provided by UTIL
86
  -u, --no-util UTIL   Do not use features provided by UTIL
87
      --no-util=UTIL   UTIL can be one of portage-utils, pkgcore, or equery
87
      --no-util=UTIL   UTIL can be one of portage-utils or pkgcore
88
                       or it can be a *quoted* space-delimited list.
88
                       or it can be a *quoted* space-delimited list.
89
  -L, --library NAME   Emerge existing packages that use the library with NAME
89
  -L, --library NAME   Emerge existing packages that use the library with NAME
90
      --library=NAME   NAME can be a full path to the library or a basic
90
      --library=NAME   NAME can be a full path to the library or a basic
Lines 110-115 Link Here
110
		progress $@
110
		progress $@
111
	fi
111
	fi
112
}
112
}
113
# Get the name of a package owning a file on the filesystem using one of several
114
# utilities: This is a placeholder. The function is defined in get_args()
115
get_file_owner() { :; }
113
# Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u
116
# Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u
114
# (If any libs have whitespace in their filenames, someone needs punishment.)
117
# (If any libs have whitespace in their filenames, someone needs punishment.)
115
clean_var() {
118
clean_var() {
Lines 129-136 Link Here
129
# What to do when dynamic linking is consistent
132
# What to do when dynamic linking is consistent
130
clean_exit() {
133
clean_exit() {
131
	[[ $KEEP_TEMP ]] || rm $LIST.?_*
134
	[[ $KEEP_TEMP ]] || rm $LIST.?_*
132
	set_color green
135
	echo
133
	die 0 $'\n'"$OK_TEXT... All done. "
136
	einfo "$OK_TEXT... All done. "
137
	exit 0
134
}
138
}
135
get_args() {
139
get_args() {
136
	appname="${0##*/}"
140
	appname="${0##*/}"
Lines 204-215 Link Here
204
		shift
208
		shift
205
	done
209
	done
206
	# Check if various utils are allowed and installed
210
	# Check if various utils are allowed and installed
207
	if [[ $avoid_utils != *portage-utils* ]] && hash q 2> /dev/null; then
211
	if [[ $avoid_utils != *portage-utils* ]] && hash qfile 2> /dev/null; then
208
		PORTAGE_UTILS=1
212
		get_file_owner() { qfile -qvC "$@"; }
209
	elif [[ $avoid_utils != *pkgcore* ]] && hash pquery 2> /dev/null; then
213
	elif [[ $avoid_utils != *pkgcore* ]] && hash pquery 2> /dev/null; then
210
		PKGCORE=1
214
		get_file_owner() { local IFS=,; pquery --nocolor --owns="$*"; }
211
	elif [[ $avoid_utils != *equery* ]] && hash equery 2> /dev/null; then
215
	# equery disabled for incompatibility with modern portage.
212
		EQUERY=1
216
	# elif [[ $avoid_utils != *equery* ]] && hash equery 2> /dev/null; then
217
	# 	get_file_owner() { equery -q -C b $@; }
218
	else
219
		get_file_owner() {
220
			local IFS=$'\n'
221
			find /var/db/pkg -name CONTENTS -print0 |
222
				xargs -0 grep -Fl "$*" |
223
				sed 's:/var/db/pkg/\(.*\)/CONTENTS:\1:'
224
		}
213
	fi
225
	fi
214
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-p/--pretend})
226
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-p/--pretend})
215
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-f/--fetchonly})
227
	EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]/%-f/--fetchonly})
Lines 339-344 Link Here
339
	# Compare old and new environments
351
	# Compare old and new environments
340
	# Don't use our previous files if environment doesn't match
352
	# Don't use our previous files if environment doesn't match
341
	new_env=$(
353
	new_env=$(
354
		# We don't care if these options change
355
		EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]//--pretend/})
356
		EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]//--fetchonly/})
342
		cat <<- EOF
357
		cat <<- EOF
343
			SEARCH_DIRS="$SEARCH_DIRS"
358
			SEARCH_DIRS="$SEARCH_DIRS"
344
			SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK"
359
			SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK"
Lines 519-537 Link Here
519
		set_trap "$LIST.4_packages*"
534
		set_trap "$LIST.4_packages*"
520
		rm -f $LIST.4*
535
		rm -f $LIST.4*
521
		while read obj FILE; do
536
		while read obj FILE; do
522
			if [[ $PORTAGE_UTILS ]]; then
537
			EXACT_PKG=$(get_file_owner $FILE)
523
				EXACT_PKG=$(qfile -qvC $FILE)
524
			elif [[ $PKGCORE ]]; then
525
				EXACT_PKG=$(pquery --nocolor --owns="$FILE")
526
			elif [[ $EQUERY ]]; then
527
				EXACT_PKG=$(equery -q -C b $FILE)
528
			else
529
				EXACT_PKG=$(
530
					find /var/db/pkg -name CONTENTS |
531
						xargs grep -Fl "obj $FILE " |
532
						sed -e 's:/var/db/pkg/\(.*\)/CONTENTS:\1:g'
533
				)
534
			fi
535
			if [[ $EXACT_PKG ]]; then
538
			if [[ $EXACT_PKG ]]; then
536
				# Strip version information
539
				# Strip version information
537
				PKG="${EXACT_PKG%%-r[[:digit:]]*}"
540
				PKG="${EXACT_PKG%%-r[[:digit:]]*}"
Lines 547-552 Link Here
547
		done < "$LIST.3_rebuild"
550
		done < "$LIST.3_rebuild"
548
		einfo "Generated new $LIST.4_packages_raw and $LIST.4_package_owners"
551
		einfo "Generated new $LIST.4_packages_raw and $LIST.4_package_owners"
549
	fi
552
	fi
553
	# if we find '(none)' on every line, exit out
554
	if ! grep -qvF '(none)' "$LIST.4_package_owners"; then
555
		ewarn "Found some broken files, but none of them were associated with known packages"
556
		ewarn "Unable to proceed with automatic repairs."
557
		if [[ $VERBOSE ]]; then
558
			ewarn "The broken files are:"
559
			while read filename junk; do
560
				ewarn "  $filename"
561
			done < "$LIST.4_package_owners"
562
		fi
563
		exit 0 # FIXME: Should we exit 1 here?
564
	fi
550
}
565
}
551
clean_packages() {
566
clean_packages() {
552
	einfo 'Cleaning list of packages to rebuild'
567
	einfo 'Cleaning list of packages to rebuild'
Lines 583-601 Link Here
583
	elif [[ -rs $LIST.3_rebuild ]]; then
598
	elif [[ -rs $LIST.3_rebuild ]]; then
584
		rebuildList=" $(<"$LIST.3_rebuild") "
599
		rebuildList=" $(<"$LIST.3_rebuild") "
585
		rebuildList=(${rebuildList//[[:space:]]obj[[:space:]]/ })
600
		rebuildList=(${rebuildList//[[:space:]]obj[[:space:]]/ })
586
		if [[ $PORTAGE_UTILS ]]; then
601
		get_file_owner "${rebuildList[@]}" > $LIST.4_ebuilds
587
			qfile -qvC ${rebuildList[@]}
588
		elif [[ $PKGCORE ]]; then
589
			IFS=,
590
			pquery --nocolor --owns="${rebuildList[*]}"
591
			IFS="$oIFS"
592
		elif [[ $EQUERY ]]; then
593
			equery -q -C b ${rebuildList[@]}
594
		else
595
			find /var/db/pkg -name CONTENTS |
596
				xargs grep -Fl "$rebuildList" |
597
				sed 's:/var/db/pkg/\(.*\)/CONTENTS:=\1:'
598
		fi > $LIST.4_ebuilds
599
		einfo "Generated new $LIST.4_ebuilds"
602
		einfo "Generated new $LIST.4_ebuilds"
600
	else
603
	else
601
		einfo 'Nothing to rebuild.'
604
		einfo 'Nothing to rebuild.'

Return to bug 184042