Lines 1-6
Link Here
|
1 |
#!/bin/sh |
1 |
#!/bin/bash |
2 |
# Copyright 1999-2005 Gentoo Foundation |
2 |
# Copyright 1999-2007 Gentoo Foundation |
3 |
# $Header$ |
|
|
4 |
|
3 |
|
5 |
# revdep-rebuild: Reverse dependency rebuilder. |
4 |
# revdep-rebuild: Reverse dependency rebuilder. |
6 |
# Original Author: Stanislav Brabec |
5 |
# Original Author: Stanislav Brabec |
Lines 80-94
Link Here
|
80 |
|
79 |
|
81 |
-h, --help Print this usage |
80 |
-h, --help Print this usage |
82 |
-k, --keep-temp Do not delete temporary files on exit |
81 |
-k, --keep-temp Do not delete temporary files on exit |
83 |
-X, --package-names Emerge based on package names, not exact versions |
82 |
-e, --exact Emerge based on exact package version |
84 |
-L, --library NAME Emerge existing packages that use the library with NAME |
|
|
85 |
--library=NAME NAME can be a full path to the library or a basic |
86 |
regular expression (man grep) |
87 |
-l, --no-ld-path Do not set LD_LIBRARY_PATH |
83 |
-l, --no-ld-path Do not set LD_LIBRARY_PATH |
88 |
-C, --nocolor Turn off colored output |
84 |
-C, --nocolor Turn off colored output |
89 |
-i, --ignore Ignore temporary files from previous runs |
85 |
-i, --ignore Ignore temporary files from previous runs |
|
|
86 |
-o, --no-order Do not check the build order |
87 |
(Saves time, but may cause breakage.) |
90 |
-q, --quiet Be less verbose (also passed to emerge command) |
88 |
-q, --quiet Be less verbose (also passed to emerge command) |
91 |
-v, --verbose Be more verbose |
89 |
-v, --verbose Be more verbose |
|
|
90 |
-u, --no-util UTIL Do not use features provided by UTIL |
91 |
--no-util=UTIL UTIL can be one of portage-utils, pkgcore, or equery |
92 |
or it can be a *quoted* space-delimited list. |
93 |
-L, --library NAME Emerge existing packages that use the library with NAME |
94 |
--library=NAME NAME can be a full path to the library or a basic |
95 |
regular expression (man grep) |
92 |
|
96 |
|
93 |
Calls emerge, all other options are used for it (e. g. -p, --pretend). |
97 |
Calls emerge, all other options are used for it (e. g. -p, --pretend). |
94 |
|
98 |
|
Lines 158-187
Link Here
|
158 |
} |
162 |
} |
159 |
get_args() { |
163 |
get_args() { |
160 |
appname="${0##*/}" |
164 |
appname="${0##*/}" |
161 |
# Check if various utils are installed |
|
|
162 |
# TODO: give the user the option to turn off detection of various utils? |
163 |
if hash q 2> /dev/null; then |
164 |
PORTAGE_UTILS=1 |
165 |
elif hash pquery 2> /dev/null; then |
166 |
PKGCORE=1 |
167 |
elif hash equery 2> /dev/null; then |
168 |
# Well... if equery doesn't work something's definitely broken ;) |
169 |
EQUERY=1 |
170 |
fi |
171 |
echo_v() { echo "$@"; } |
165 |
echo_v() { echo "$@"; } |
172 |
unset PACKAGE_NAMES VERBOSE KEEP_TEMP EMERGE_OPTIONS CALLED_OPTIONS |
166 |
unset VERBOSE KEEP_TEMP EMERGE_OPTIONS |
|
|
167 |
order_packages=1 |
168 |
PACKAGE_NAMES=1 |
173 |
SONAME="not found" |
169 |
SONAME="not found" |
174 |
SEARCH_BROKEN=1 |
170 |
SEARCH_BROKEN=1 |
175 |
FULL_LD_PATH=1 |
171 |
FULL_LD_PATH=1 |
|
|
172 |
local avoid_utils |
176 |
while [[ $1 ]]; do |
173 |
while [[ $1 ]]; do |
177 |
case $1 in |
174 |
case $1 in |
178 |
-h|--help) |
175 |
-h|--help) |
179 |
print_usage |
176 |
print_usage |
180 |
exit 0 |
177 |
exit 0 |
181 |
;; |
178 |
;; |
182 |
-X|--package-names) |
179 |
-e|--exact) |
183 |
PACKAGE_NAMES=1 |
180 |
unset PACKAGE_NAMES |
184 |
CALLED_OPTIONS+=" --package_names" # TODO: inconsistency _ versus - ? |
181 |
;; |
|
|
182 |
-o|--no-order) |
183 |
unset order_packages |
185 |
;; |
184 |
;; |
186 |
-q|--quiet) |
185 |
-q|--quiet) |
187 |
echo_v() { : ; } |
186 |
echo_v() { : ; } |
Lines 191-217
Link Here
|
191 |
-L=*|--library=*|--soname=*|--soname-regexp=*) |
190 |
-L=*|--library=*|--soname=*|--soname-regexp=*) |
192 |
SONAME="${1#*=}" |
191 |
SONAME="${1#*=}" |
193 |
unset SEARCH_BROKEN |
192 |
unset SEARCH_BROKEN |
194 |
CALLED_OPTIONS+=" --library=$SONAME" |
|
|
195 |
;; |
193 |
;; |
196 |
-L|--library|--soname|--soname-regexp) |
194 |
-L|--library|--soname|--soname-regexp) |
197 |
[[ $2 = -* ]] && die 1 "Missing expected argument to $1" |
195 |
[[ $2 = -* ]] && die 1 "Missing expected argument to $1" |
198 |
shift |
196 |
shift |
199 |
SONAME="$1" |
197 |
SONAME="$1" |
200 |
unset SEARCH_BROKEN |
198 |
unset SEARCH_BROKEN |
201 |
CALLED_OPTIONS+=" --library=$SONAME" |
199 |
;; |
|
|
200 |
-u=*|--no-util=*) |
201 |
# TODO: check for invalid values |
202 |
avoid_utils="${1#*=}" |
203 |
;; |
204 |
-u|--no-util) |
205 |
[[ $2 = -* ]] && die 1 "Missing expected argument to $1" |
206 |
shift |
207 |
avoid_utils="$1" |
202 |
;; |
208 |
;; |
203 |
-nc|-C|--no-color|--nocolor) |
209 |
-nc|-C|--no-color|--nocolor) |
204 |
NOCOLOR=1 |
210 |
export NOCOLOR=1 |
205 |
;; |
211 |
;; |
206 |
-l|-np|--no-ld-path) |
212 |
-l|-np|--no-ld-path) |
207 |
unset FULL_LD_PATH |
213 |
unset FULL_LD_PATH |
208 |
CALLED_OPTIONS+=" --no-ld-path" |
|
|
209 |
;; |
214 |
;; |
210 |
-i|--ignore) |
215 |
-i|--ignore) |
211 |
rm -f $LIST* |
216 |
rm -f $LIST.* |
212 |
;; |
217 |
;; |
213 |
-k|--keep-temp) |
218 |
-k|--keep-temp) |
214 |
KEEPTEMP=1 |
219 |
KEEP_TEMP=1 |
215 |
;; |
220 |
;; |
216 |
-vv|--extra-verbose|-v|--verbose) |
221 |
-vv|--extra-verbose|-v|--verbose) |
217 |
VERBOSE=1 |
222 |
VERBOSE=1 |
Lines 224-229
Link Here
|
224 |
esac |
229 |
esac |
225 |
shift |
230 |
shift |
226 |
done |
231 |
done |
|
|
232 |
# Check if various utils are allowed and installed |
233 |
if [[ avoid_utils != *portage-utils* ]] && hash q 2> /dev/null; then |
234 |
PORTAGE_UTILS=1 |
235 |
elif [[ avoid_utils != *pkgcore* ]] && hash pquery 2> /dev/null; then |
236 |
PKGCORE=1 |
237 |
elif [[ avoid_utils != *equery* ]] && hash equery 2> /dev/null; then |
238 |
EQUERY=1 |
239 |
fi |
227 |
} |
240 |
} |
228 |
get_args "$@" |
241 |
get_args "$@" |
229 |
|
242 |
|
Lines 296-302
Link Here
|
296 |
die 1 "!!! Unable to find a satisfactory location for temporary files !!!" |
309 |
die 1 "!!! Unable to find a satisfactory location for temporary files !!!" |
297 |
fi |
310 |
fi |
298 |
|
311 |
|
299 |
CALLED_OPTIONS=$(clean_var "$CALLED_OPTIONS") |
|
|
300 |
function set_trap () { |
312 |
function set_trap () { |
301 |
trap "rm_temp $1" SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM |
313 |
trap "rm_temp $1" SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM |
302 |
} |
314 |
} |
Lines 335-355
Link Here
|
335 |
$( |
347 |
$( |
336 |
find -L "$LIST" -type f -mmin +1440 -print | |
348 |
find -L "$LIST" -type f -mmin +1440 -print | |
337 |
while read; do echo 1; break; done |
349 |
while read; do echo 1; break; done |
338 |
) ]] && rm -f $LIST* |
350 |
) ]] && rm -f $LIST.* |
339 |
|
351 |
|
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 |
if [[ -r $LIST.0_env ]]; then |
353 |
if [[ -r $LIST.0_env ]]; then |
342 |
oIFS="$IFS"; IFS=$'\a' |
354 |
oIFS="$IFS"; IFS=$'\a' |
343 |
PREVS=( $( |
355 |
PREVS=( $( |
344 |
source "$LIST.0_env" |
356 |
source "$LIST.0_env" |
345 |
echo "$SEARCH_DIRS"$'\a'"$SEARCH_DIRS_MASK"$'\a'"$LD_LIBRARY_MASK"$'\a'"$PORTAGE_ROOT"$'\a'"$CALLED_OPTIONS" |
357 |
echo "$SEARCH_DIRS"$'\a'"$SEARCH_DIRS_MASK"$'\a'"$LD_LIBRARY_MASK"$'\a'"$PORTAGE_ROOT" |
346 |
) ) |
358 |
) ) |
347 |
IFS="$oIFS" |
359 |
IFS="$oIFS" |
348 |
if [[ ${PREVS[0]} != $SEARCH_DIRS || |
360 |
if [[ ${PREVS[0]} != $SEARCH_DIRS || |
349 |
${PREVS[1]} != $SEARCH_DIRS_MASK || |
361 |
${PREVS[1]} != $SEARCH_DIRS_MASK || |
350 |
${PREVS[2]} != $LD_LIBRARY_MASK || |
362 |
${PREVS[2]} != $LD_LIBRARY_MASK || |
351 |
${PREVS[3]} != $PORTAGE_ROOT || |
363 |
${PREVS[3]} != $PORTAGE_ROOT ]]; then |
352 |
${PREVS[4]} != $CALLED_OPTIONS ]]; then |
|
|
353 |
echo 'Environment mismatch from previous run, deleting temporary files...' |
364 |
echo 'Environment mismatch from previous run, deleting temporary files...' |
354 |
rm -f $LIST* |
365 |
rm -f $LIST* |
355 |
fi |
366 |
fi |
Lines 362-368
Link Here
|
362 |
SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK" |
373 |
SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK" |
363 |
LD_LIBRARY_MASK="$LD_LIBRARY_MASK" |
374 |
LD_LIBRARY_MASK="$LD_LIBRARY_MASK" |
364 |
PORTAGE_ROOT="$PORTAGE_ROOT" |
375 |
PORTAGE_ROOT="$PORTAGE_ROOT" |
365 |
CALLED_OPTIONS="$CALLED_OPTIONS" |
|
|
366 |
EMERGE_OPTIONS="$EMERGE_OPTIONS" |
376 |
EMERGE_OPTIONS="$EMERGE_OPTIONS" |
367 |
EOF |
377 |
EOF |
368 |
|
378 |
|
Lines 583-589
Link Here
|
583 |
echo -e " done.\n ($LIST.4_ebuilds)" |
593 |
echo -e " done.\n ($LIST.4_ebuilds)" |
584 |
else |
594 |
else |
585 |
echo " Nothing to rebuild" |
595 |
echo " Nothing to rebuild" |
586 |
rm "$LIST.4_ebuilds" |
596 |
rm -f "$LIST.4_ebuilds" |
587 |
fi |
597 |
fi |
588 |
fi |
598 |
fi |
589 |
else |
599 |
else |
Lines 593-599
Link Here
|
593 |
echo " using existing $LIST.4_ebuilds." |
603 |
echo " using existing $LIST.4_ebuilds." |
594 |
else |
604 |
else |
595 |
if [[ -s $LIST.3_rebuild ]]; then |
605 |
if [[ -s $LIST.3_rebuild ]]; then |
596 |
rebuildList=$(awk '{print $2}' "$LIST.3_rebuild") |
606 |
rebuildList=" $(<"$LIST.3_rebuild") " |
|
|
607 |
rebuildList="${rebuildList//[[:space:]]obj[[:space:]]/ }" |
597 |
if [[ $PORTAGE_UTILS ]]; then |
608 |
if [[ $PORTAGE_UTILS ]]; then |
598 |
qfile -qvC $rebuildList # Don't put quotes around $rebuildList |
609 |
qfile -qvC $rebuildList # Don't put quotes around $rebuildList |
599 |
# elif [[ $PKGCORE ]]; then |
610 |
# elif [[ $PKGCORE ]]; then |
Lines 609-624
Link Here
|
609 |
echo -e " done.\n ($LIST.4_ebuilds)" |
620 |
echo -e " done.\n ($LIST.4_ebuilds)" |
610 |
else |
621 |
else |
611 |
echo " Nothing to rebuild" |
622 |
echo " Nothing to rebuild" |
612 |
rm > $LIST.4_ebuilds |
623 |
rm -f $LIST.4_ebuilds |
613 |
fi |
624 |
fi |
614 |
fi |
625 |
fi |
615 |
fi |
626 |
fi |
616 |
|
627 |
|
617 |
# TODO: let the user skip this step |
628 |
# TODO: let the user skip this step |
618 |
color_echo green -n $'\nEvaluating package order...' |
629 |
if [[ $order_packages ]]; then |
619 |
if [[ -r $LIST.5_order ]]; then |
630 |
color_echo green -n $'\nEvaluating package order...' |
|
|
631 |
if [[ -r $LIST.5_order ]]; then |
620 |
echo " using existing $LIST.5_order." |
632 |
echo " using existing $LIST.5_order." |
621 |
else |
633 |
else |
622 |
set_trap "$LIST.5_order" |
634 |
set_trap "$LIST.5_order" |
623 |
RAW_REBUILD_LIST=$(<"$LIST.4_ebuilds") |
635 |
RAW_REBUILD_LIST=$(<"$LIST.4_ebuilds") |
624 |
if [[ $RAW_REBUILD_LIST ]]; then |
636 |
if [[ $RAW_REBUILD_LIST ]]; then |
Lines 651-673
Link Here
|
651 |
fi |
663 |
fi |
652 |
[[ -f $LIST.5_order ]] && echo -e " done.\n ($LIST.5_order)" || |
664 |
[[ -f $LIST.5_order ]] && echo -e " done.\n ($LIST.5_order)" || |
653 |
echo -e " done.\n ($LIST.4_ebuilds)" |
665 |
echo -e " done.\n ($LIST.4_ebuilds)" |
|
|
666 |
fi |
667 |
else |
668 |
color_echo green "Skipping package ordering" |
654 |
fi |
669 |
fi |
655 |
|
670 |
|
656 |
# Clean up no longer needed environment variables |
671 |
# Clean up no longer needed environment variables |
657 |
unset COMPLETE_LD_LIBRARY_PATH SEARCH_DIRS SEARCH_DIRS_MASK LD_LIBRARY_MASK PORTAGE_ROOT CALLED_OPTIONS |
672 |
unset COMPLETE_LD_LIBRARY_PATH SEARCH_DIRS SEARCH_DIRS_MASK LD_LIBRARY_MASK PORTAGE_ROOT |
658 |
|
673 |
|
659 |
[[ -f $LIST.5_order ]] && REBUILD_LIST=$(<"$LIST.5_order") || |
674 |
[[ -f $LIST.5_order ]] && REBUILD_LIST=$(<"$LIST.5_order") || |
660 |
REBUILD_LIST=$(<"$LIST.4_ebuilds") |
675 |
REBUILD_LIST=$(<"$LIST.4_ebuilds") |
661 |
REBUILD_LIST="=${REBUILD_LIST//[[:space:]]/ =}" |
|
|
662 |
|
676 |
|
663 |
trap - SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM |
677 |
trap - SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM |
664 |
|
678 |
|
665 |
if [[ ! $REBUILD_LIST ]]; then |
679 |
if [[ ! $REBUILD_LIST ]]; then |
666 |
[[ $KEEPTEMP ]] || rm $LIST.?_* |
680 |
[[ $KEEP_TEMP ]] || rm $LIST.?_* |
667 |
set_color green |
681 |
set_color green |
668 |
die 0 $'\n'"$OK_TEXT... All done. " |
682 |
die 0 $'\n'"$OK_TEXT... All done. " |
669 |
fi |
683 |
fi |
670 |
|
684 |
|
|
|
685 |
REBUILD_LIST="=${REBUILD_LIST//[[:space:]]/ =}" |
686 |
|
671 |
IS_REAL_MERGE=1 |
687 |
IS_REAL_MERGE=1 |
672 |
for option in $EMERGE_OPTIONS; do |
688 |
for option in $EMERGE_OPTIONS; do |
673 |
case $option in |
689 |
case $option in |