Lines 29-34
Link Here
|
29 |
declare RM_OLD_TEMPFILES # ...remove tempfiles from prior runs |
29 |
declare RM_OLD_TEMPFILES # ...remove tempfiles from prior runs |
30 |
declare SEARCH_BROKEN # ...search for broken libraries and binaries |
30 |
declare SEARCH_BROKEN # ...search for broken libraries and binaries |
31 |
declare VERBOSE # ...give verbose output |
31 |
declare VERBOSE # ...give verbose output |
|
|
32 |
declare EMERGE_OWNER # ...emerge the owner of a soname |
32 |
|
33 |
|
33 |
# Globals that impact portage directly: |
34 |
# Globals that impact portage directly: |
34 |
declare EMERGE_DEFAULT_OPTS # String of options portage assumes to be set |
35 |
declare EMERGE_DEFAULT_OPTS # String of options portage assumes to be set |
Lines 62-67
Link Here
|
62 |
declare SONAME_SEARCH # Value of SONAME modified to match ldd's output |
63 |
declare SONAME_SEARCH # Value of SONAME modified to match ldd's output |
63 |
declare WORKING_TEXT # Feedback about the search |
64 |
declare WORKING_TEXT # Feedback about the search |
64 |
declare ENV_FILE # A file containing environment variables |
65 |
declare ENV_FILE # A file containing environment variables |
|
|
66 |
declare -a LIB_OWNERS # The packages owning the libraries specified |
67 |
# as arguments to --library |
65 |
|
68 |
|
66 |
rm() { |
69 |
rm() { |
67 |
local i |
70 |
local i |
Lines 126-131
Link Here
|
126 |
-l, --no-ld-path Do not set LD_LIBRARY_PATH |
129 |
-l, --no-ld-path Do not set LD_LIBRARY_PATH |
127 |
-o, --no-order Do not check the build order |
130 |
-o, --no-order Do not check the build order |
128 |
(Saves time, but may cause breakage.) |
131 |
(Saves time, but may cause breakage.) |
|
|
132 |
-O, --merge-owner Remerge the owner of the library being searched |
133 |
(Ignored if -L is not used.) |
129 |
-p, --pretend Do a trial run without actually emerging anything |
134 |
-p, --pretend Do a trial run without actually emerging anything |
130 |
(also passed to emerge command) |
135 |
(also passed to emerge command) |
131 |
-P, --no-progress Turn off the progress meter |
136 |
-P, --no-progress Turn off the progress meter |
Lines 158-163
Link Here
|
158 |
progress() { :; } |
163 |
progress() { :; } |
159 |
fi |
164 |
fi |
160 |
} |
165 |
} |
|
|
166 |
## |
167 |
# has item list |
168 |
# returns 0 if item is in list, 1 otherwise |
169 |
has() { |
170 |
local IFS=$'\a' |
171 |
[[ $@ != *${IFS}* ]] || |
172 |
die 1 "function has() fails miserably if any argument contains a BEL." |
173 |
local item="$1" |
174 |
shift |
175 |
local -a list=( "$@" ) |
176 |
# has() will reflect the exit code of the following: |
177 |
[[ "${IFS}${list[*]}${IFS}" = *"${IFS}${item}${IFS}"* ]] |
178 |
} |
161 |
# Usage: countdown n |
179 |
# Usage: countdown n |
162 |
# n: number of seconds to count |
180 |
# n: number of seconds to count |
163 |
countdown() { |
181 |
countdown() { |
Lines 297-302
Link Here
|
297 |
SONAME="$1" |
315 |
SONAME="$1" |
298 |
unset SEARCH_BROKEN;; |
316 |
unset SEARCH_BROKEN;; |
299 |
--no-ld-path) unset FULL_LD_PATH;; |
317 |
--no-ld-path) unset FULL_LD_PATH;; |
|
|
318 |
--emerge-owner) EMERGE_OWNER=1;; |
300 |
--no-order) unset ORDER_PKGS;; |
319 |
--no-order) unset ORDER_PKGS;; |
301 |
--no-progress) progress() { :; };; |
320 |
--no-progress) progress() { :; };; |
302 |
--pretend) EMERGE_OPTIONS+=("--pretend");; |
321 |
--pretend) EMERGE_OPTIONS+=("--pretend");; |
Lines 328-334
Link Here
|
328 |
# Get single-letter commandline options preceded by a single dash. |
347 |
# Get single-letter commandline options preceded by a single dash. |
329 |
get_shortopts() { |
348 |
get_shortopts() { |
330 |
local OPT OPTSTRING OPTARG OPTIND |
349 |
local OPT OPTSTRING OPTARG OPTIND |
331 |
while getopts ":CdehikL:loPpqu:vX" OPT; do |
350 |
while getopts ":CdehikL:lOoPpqu:vX" OPT; do |
332 |
case "$OPT" in |
351 |
case "$OPT" in |
333 |
C) # TODO: Match syntax with the rest of gentoolkit |
352 |
C) # TODO: Match syntax with the rest of gentoolkit |
334 |
export NOCOLOR="yes";; |
353 |
export NOCOLOR="yes";; |
Lines 342-347
Link Here
|
342 |
SONAME="${OPTARG#*=}" |
361 |
SONAME="${OPTARG#*=}" |
343 |
unset SEARCH_BROKEN;; |
362 |
unset SEARCH_BROKEN;; |
344 |
l) unset FULL_LD_PATH;; |
363 |
l) unset FULL_LD_PATH;; |
|
|
364 |
O) EMERGE_OWNER=1;; |
345 |
o) unset ORDER_PKGS;; |
365 |
o) unset ORDER_PKGS;; |
346 |
P) progress() { :; };; |
366 |
P) progress() { :; };; |
347 |
p) EMERGE_OPTIONS+=("--pretend");; |
367 |
p) EMERGE_OPTIONS+=("--pretend");; |
Lines 516-521
Link Here
|
516 |
fi |
536 |
fi |
517 |
local uuid="${SONAME##*/}" |
537 |
local uuid="${SONAME##*/}" |
518 |
uuid="${uuid//[[:space:]]}" |
538 |
uuid="${uuid//[[:space:]]}" |
|
|
539 |
uuid="${uuid//\*}" |
519 |
LIST+="_$uuid" |
540 |
LIST+="_$uuid" |
520 |
HEAD_TEXT="using $SONAME" |
541 |
HEAD_TEXT="using $SONAME" |
521 |
OK_TEXT="There are no dynamic links to $SONAME" |
542 |
OK_TEXT="There are no dynamic links to $SONAME" |
Lines 668-682
Link Here
|
668 |
else |
689 |
else |
669 |
# FIXME: I hate duplicating code |
690 |
# FIXME: I hate duplicating code |
670 |
# Only rebuild for direct dependencies |
691 |
# Only rebuild for direct dependencies |
671 |
MISSING_LIBS=$( |
692 |
# FIXME: If the grep matches more than one line it'll screw up the |
672 |
expr="/$SONAME_SEARCH/s/^[[:space:]]*\([^[:space:]]*\).*$/\1/p" |
693 |
# LIB_OWNERS array. |
673 |
sort -u <<< "$ldd_output" | sed -n "$expr" |
694 |
local soname_matchline=( $( |
674 |
) |
695 |
sort -u <<< "$ldd_output" | grep "$SONAME_SEARCH" |
|
|
696 |
) ) |
697 |
if [[ ! ${SEARCH_BROKEN}${EMERGE_OWNER} ]]; then |
698 |
# The third item in soname_matchline should be the full path to the |
699 |
# soname that we're searching for |
700 |
if [[ ${#soname_matchline[@]} -eq 4 && ${soname_matchline[2]} ]] |
701 |
then |
702 |
local owner=$(get_file_owner "${soname_matchline[2]}") |
703 |
has "$owner" "${LIB_OWNERS[@]}" || LIB_OWNERS+=("$owner") |
704 |
fi |
705 |
fi |
675 |
REQUIRED_LIBS=$( |
706 |
REQUIRED_LIBS=$( |
676 |
expr='s/^[[:space:]]*NEEDED[[:space:]]*\([^[:space:]]*\).*/\1/p'; |
707 |
expr='s/^[[:space:]]*NEEDED[[:space:]]*\([^[:space:]]*\).*/\1/p'; |
677 |
objdump -x "$target_file" | grep NEEDED | sed "$expr" | sort -u |
708 |
objdump -x "$target_file" | grep NEEDED | sed "$expr" | sort -u |
678 |
) |
709 |
) |
679 |
MISSING_LIBS=$(grep -F "$REQUIRED_LIBS" <<< "$MISSING_LIBS") |
710 |
MISSING_LIBS=$(grep -F "$REQUIRED_LIBS" <<< "${soname_matchline[0]}") |
680 |
if [[ $MISSING_LIBS ]]; then |
711 |
if [[ $MISSING_LIBS ]]; then |
681 |
echo "obj $target_file" >> "$LIST.3_rebuild" |
712 |
echo "obj $target_file" >> "$LIST.3_rebuild" |
682 |
if [[ $SEARCH_BROKEN ]]; then |
713 |
if [[ $SEARCH_BROKEN ]]; then |
Lines 740-745
Link Here
|
740 |
while read obj target_file; do |
771 |
while read obj target_file; do |
741 |
EXACT_PKG=$(get_file_owner $target_file) |
772 |
EXACT_PKG=$(get_file_owner $target_file) |
742 |
if [[ $EXACT_PKG ]]; then |
773 |
if [[ $EXACT_PKG ]]; then |
|
|
774 |
# Skip packages owned by the SONAME searched. |
775 |
# http://bugs.gentoo.org/30095 |
776 |
if [[ $LIB_OWNERS ]] && has "$EXACT_PKG" "${LIB_OWNERS[@]}"; then |
777 |
[[ $VERBOSE ]] && einfo " $target_file -> $EXACT_PKG (skipped)" |
778 |
continue |
779 |
fi |
743 |
# Strip version information |
780 |
# Strip version information |
744 |
PKG="${EXACT_PKG%%-r[[:digit:]]*}" |
781 |
PKG="${EXACT_PKG%%-r[[:digit:]]*}" |
745 |
PKG="${PKG%-*}" |
782 |
PKG="${PKG%-*}" |