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

Collapse All | Expand All

(-)src/revdep-rebuild/revdep-rebuild (-6 / +54 lines)
Lines 87-92 Link Here
87
declare WORKING_TEXT           # Feedback about the search
87
declare WORKING_TEXT           # Feedback about the search
88
declare WORKING_DIR            # Working directory where cache files are kept
88
declare WORKING_DIR            # Working directory where cache files are kept
89
89
90
# Who's root?
91
declare ROOT_UID		# User ID of root
92
ROOT_UID=`python -c 'import sys; import portage; import portage.const, portage.exception, portage.output; print portage.const_autotool.rootuid;'`
93
90
main() {
94
main() {
91
	# preliminary setup
95
	# preliminary setup
92
	get_opts "$@"
96
	get_opts "$@"
Lines 98-104 Link Here
98
	# Search for broken binaries
103
	# Search for broken binaries
99
	get_files
104
	get_files
100
	get_ldpath
105
	get_ldpath
101
	main_checks
106
	case `python -c 'import platform; print platform.system()'` in
107
		Darwin)
108
			darwin_main_checks
109
			;;
110
		*)
111
			main_checks
112
			;;
113
	esac
102
114
103
	# Associate broken binaries with packages to rebuild
115
	# Associate broken binaries with packages to rebuild
104
	if [[ $PACKAGE_NAMES ]]; then
116
	if [[ $PACKAGE_NAMES ]]; then
Lines 430-436 Link Here
430
	normalize_emerge_opts
442
	normalize_emerge_opts
431
443
432
	# If the user is not super, add --pretend to EMERGE_OPTIONS
444
	# If the user is not super, add --pretend to EMERGE_OPTIONS
433
	if [[ ${EMERGE_OPTIONS[@]} != *--pretend* && $UID -ne 0 ]]; then
445
	if [[ ${EMERGE_OPTIONS[@]} != *--pretend* && $UID -ne ${ROOT_UID} ]]; then
434
		ewarn "You are not superuser. Adding --pretend to emerge options."
446
		ewarn "You are not superuser. Adding --pretend to emerge options."
435
		EMERGE_OPTIONS+=(--pretend)
447
		EMERGE_OPTIONS+=(--pretend)
436
	fi
448
	fi
Lines 525-533 Link Here
525
get_search_env() {
537
get_search_env() {
526
	local new_env
538
	local new_env
527
	local old_env
539
	local old_env
528
	local uid=$(python -c 'import os; import pwd; print pwd.getpwuid(os.getuid())[0]')
540
	local uid=$(python -c 'import os; import pwd; print os.getuid()')
529
	# Find a place to put temporary files
541
	# Find a place to put temporary files
530
	if [[ "$uid" == "root" ]]; then
542
	if [[ $uid -eq ${ROOT_UID} ]]; then
531
		local tmp_target="@GENTOO_PORTAGE_EPREFIX@/var/cache/${APP_NAME}"
543
		local tmp_target="@GENTOO_PORTAGE_EPREFIX@/var/cache/${APP_NAME}"
532
	else
544
	else
533
		local tmp_target="$(mktemp -d -t revdep-rebuild.XXXXXXXXXX)"
545
		local tmp_target="$(mktemp -d -t revdep-rebuild.XXXXXXXXXX)"
Lines 653-661 Link Here
653
		COMPLETE_LD_LIBRARY_PATH=(
665
		COMPLETE_LD_LIBRARY_PATH=(
654
			@GENTOO_PORTAGE_EPREFIX@/lib*
666
			@GENTOO_PORTAGE_EPREFIX@/lib*
655
			@GENTOO_PORTAGE_EPREFIX@/usr/lib*
667
			@GENTOO_PORTAGE_EPREFIX@/usr/lib*
656
			$(sed '/^#/d;s/#.*$//' < /etc/ld.so.conf)
668
			$(sed '/^#/d;s/#.*$//' 2>/dev/null < /etc/ld.so.conf )
657
			$(sed 's:/[^/]*$::' < "$FILES_FILE" | sort -ru)
669
			$(sed 's:/[^/]*$::' < "$FILES_FILE" | sort -ru)
658
		)
670
		) 
659
		IFS=':'
671
		IFS=':'
660
		COMPLETE_LD_LIBRARY_PATH="${COMPLETE_LD_LIBRARY_PATH[*]}"
672
		COMPLETE_LD_LIBRARY_PATH="${COMPLETE_LD_LIBRARY_PATH[*]}"
661
		IFS="$OIFS"
673
		IFS="$OIFS"
Lines 663-668 Link Here
663
		einfo "Generated new $LDPATH_FILE"
675
		einfo "Generated new $LDPATH_FILE"
664
	fi
676
	fi
665
}
677
}
678
679
darwin_main_checks() {
680
	local master_file
681
	local dep_file
682
	local master_version
683
	local i=0
684
	local numFiles=$(wc -l ${FILES_FILE} | cut -d ' ' -f 1)
685
	einfo "Checking dynamic linking $WORKING_TEXT"
686
	if [[ -r "$BROKEN_FILE" && -s "$BROKEN_FILE" ]]; then
687
		einfo "Found existing $BROKEN_FILE."
688
	else
689
	( 
690
		while read master_file; do 
691
			#
692
			# Read what libraries we depend upon and whether these
693
			# files exist and contain the same compatibility
694
			# version as referenced in the master file
695
			#
696
			otool -L "${master_file}" 2>>${ERRORS_FILE} | \
697
			grep -v @executable_path | \
698
			(test -z "${SEARCH_BROKEN}" -o "${SEARCH_BROKEN}" != "1" && grep "${SONAME}" || cat) | \
699
			grep 'compatibility version' | \
700
			sed 's!^[   ]*\([^ ][^(]*\) (compatibility version \([^,]*\).*!\1 \2!' | \
701
			while read dep_file master_version; do 
702
				if ! test -e "${dep_file}" || ! otool -L "${dep_file}" 2>>${ERRORS_FILE} | grep "${dep_file} (compatibility version ${master_version}" >/dev/null; then 
703
					echo obj ${master_file} >&3
704
					break
705
				fi
706
			done
707
			[[ $VERBOSE ]] &&
708
				progress $((++i)) $numFiles $master_file ||
709
				progress $((++i)) $numFiles
710
		done
711
	) < "${FILES_FILE}" 3> "${BROKEN_FILE}"
712
	fi
713
}
714
666
main_checks() {
715
main_checks() {
667
	local target_file
716
	local target_file
668
	local -a files
717
	local -a files

Return to bug 268853