--- revdep-rebuild.orig 2007-07-19 10:37:38.000000000 -0400 +++ revdep-rebuild 2007-07-19 11:58:06.000000000 -0400 @@ -141,7 +141,7 @@ # Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u # (If any libs have whitespace in their filenames, someone needs punishment.) clean_var() { - local a=$(echo ${@%%-\**}) # Deliberately unquoted + local a=$(echo ${@%%[[:space:]]-\*[[:space:]]*}) # Deliberately unquoted # A benchmark shows this loop is faster than piping to sed, # as long as there aren't more than a handful of '/' chars. while [[ $a = *//* ]]; do a="${a//\/\///}"; done @@ -317,29 +317,25 @@ # Use the color preference from portage NOCOLOR=$(portageq envvar NOCOLOR) -# Find a place to put temporary files -# TODO; let the user choose where to put tempfiles -# gfind $HOME/ /var/tmp/ /tmp/ -writable -print -quit -# TODO: This is a rather noisy, but portable way to implement -quit -LIST=$( - find $HOME/ /var/tmp/ /tmp/ -writable | while read LIST; do - echo "$LIST.$appname" - break - done -) -if [[ $LIST = .$appname ]]; then - die 1 "!!! Unable to find a satisfactory location for temporary files !!!" -fi -[[ $remove_old_tempfiles ]] && rm -f $LIST.* - -function set_trap () { +set_trap() { trap "rm_temp $1" SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM } -function rm_temp () { +rm_temp() { rm $1 die 1 $' ...terminated. Removing incomplete '"$1." } get_search_env() { + # Find a place to put temporary files + # TODO; let the user choose where to put tempfiles + # gfind $HOME/ /var/tmp/ /tmp/ -writable -print -quit + # HACK: This is a rather noisy, but portable way to implement -quit + while read LIST; do + break # Set LIST + done < <(find $HOME/ /var/tmp/ /tmp/ -writable) + [[ $LIST ]] || + die 1 "Unable to find a satisfactory location for temporary files" + + LIST+=".$appname" if [[ $SEARCH_BROKEN ]]; then SONAME_SEARCH="$SONAME" HEAD_TEXT="broken by a package update" @@ -364,19 +360,18 @@ unset WORKING_TEXT fi - [[ $LIST ]] || die 1 $LIST IS NOT DEFINED - # If any of our temporary files are older than 1 day, remove them all - [[ ! $keep_tempfiles && -r $LIST && - $( - find -L "$LIST" -type f -mmin +1440 -print | - while read; do echo 1; break; done - ) ]] && rm -f $LIST.* + if [[ ! $keep_tempfiles ]]; then + while read; do + remove_old_tempfiles=1 + break + done < <(find -L "$LIST."* -maxdepth 0 -type f -mmin +1440 -print) + fi # Compare old and new environments # Don't use our previous files if environment doesn't match new_env=$( - # We don't care if these options change + # We don't care if these emerge options change EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]//--pretend/}) EMERGE_OPTIONS=(${EMERGE_OPTIONS[@]//--fetchonly/}) cat <<- EOF @@ -393,13 +388,16 @@ old_env=$(<"$LIST.0_env") if [[ $old_env != $new_env ]]; then ewarn 'Environment mismatch from previous run, deleting temporary files...' - rm -f "$LIST"* + remove_old_tempfiles=1 fi else # No 0_env file found, silently delete any other tempfiles that may exist - rm -f "$LIST"* + remove_old_tempfiles=1 fi + # If we should remove old tempfiles, do so + [[ $remove_old_tempfiles ]] && rm -f "$LIST."* + # Save the environment in a file for next time echo "$new_env" > "$LIST.0_env"