Changeset 860 in MondoRescue for branches


Ignore:
Timestamp:
Sep 30, 2006, 12:53:33 AM (18 years ago)
Author:
Bruno Cornec
Message:

Create function ReadAllLink in mindi used by LocateFile now to try to optimize it. Hope mindi will now get all libraries correctly

Location:
branches/stable/mindi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi/deplist.txt

    r859 r860  
    99# 4. If you want to add something, just add it on its own line. K.I.S.S.
    1010# 5. You must _not_ put a semicolon & comment after an entry. e.g. 'foo; #bar'.
    11 # 6. All these worlds are yours except Europa. Attempt no landing there.
    1211
    1312#------------------------- STUFF ADDED BY THE USER ----------------------------
  • branches/stable/mindi/mindi

    r859 r860  
    11031103        elif [ -h "$fname" ] && [ -x "$fname" ] ; then
    11041104            echo "$fname is softlink" >> $LOGFILE
    1105 #            echo "$fname will not be LDD'd. It is a softlink to `WhatSoftlinkPointsTo $fname`, which should already be in queue to be analyzed." >> $LOGFILE
    1106 #            echo "$fname"
    11071105        else
    11081106            ldd $fname 2> /dev/null | ProcessLDD $fname
     
    11111109}
    11121110
     1111# Give all symlinks recursively of a full path name
     1112ReadAllLink() {
     1113    file="$1"
     1114
     1115    if [ ! -h $file ]; then
     1116        echo "$file"
     1117        return 0
     1118    fi
     1119
     1120    link=`readlink $file`
     1121    if [ "`dirname $link | cut -c1`" = "/" ]; then
     1122        echo "$link `ReadAllLink $link`"
     1123    else
     1124            echo "$link `dirname $file`/`ReadAllLink $link`"
     1125    fi 
     1126}
    11131127
    11141128
     
    11161130    local i path fname_to_find location output resolved tmp stub cache_id loclist
    11171131    fname_to_find="$1"
    1118     if [ "$FILE_CACHE" ] ; then
    1119         touch $FILE_CACHE
    1120         output=""; cache_id=`echo $fname_to_find | md5sum`
    1121         output=`sed -n -e "s/^$cache_id //p" $FILE_CACHE`
    1122         if [ ! "$output" = "" ] ; then
    1123             echo "$output"
    1124             return 0
    1125         fi
    1126     fi
    11271132    if echo "$fname_to_find" | grep -x "/.*" ; then
    11281133        output="$fname_to_find"
    1129         location="$fname_to_find"
    1130         while [ -h "$location" ] ; do
    1131             resolved=`WhatSoftlinkPointsTo $location`
    1132             location=$resolved
    1133             output="$location $output"
    1134         done
     1134        if [ -h "$output" ] ; then
     1135            output="`ReadAllLink $output` $output"
     1136        fi
    11351137        echo "$output"
    11361138        return 0
     
    11391141    for path in /etc /usr /usr/bin /usr/sbin /bin /usr/X11R6/bin /sbin /usr/local/bin /usr/local/sbin /usr/lib /usr/lib64 /usr/lib64/* /lib /lib64 /lib64/* /usr/local/lib /usr/local/lib64 /usr/local/lib64/* /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/lib64/* ; do
    11401142        [ ! -d "$path" ] && continue
    1141         location=`echo "$path/$fname_to_find" | tr -s '/' '/'`
    1142         if echo "$location" | grep "lib/lib" 2> /dev/null ; then
    1143             loclist=`find $path -maxdepth 1 | grep -F "$fname_to_find"`
    1144         else
    1145             loclist=$location
    1146         fi
    1147         for location in $loclist ; do
     1143        for location in "$path/$fname_to_find" ; do
    11481144            [ ! -e "$location" ] && continue
    11491145            output="$location $output"
    1150             copies_found=$(($copies_found+1))
    1151             while [ -h "$location" ] ; do
    1152                 resolved=`WhatSoftlinkPointsTo $location`
    1153                 location=$resolved
    1154                 output="$location $output"
    1155             done
    1156 #       resolved=`file $location | $AWK '{print $NF;}'`
    1157 #       if [ "`echo "$resolved" | grep -F "/"`" = "" ] ; then
    1158 #           stub=`dirname $location`
    1159 #           output="/$stub/$resolved $output"
    1160 #       fi
    1161 #       fi
     1146            if [ -h "$location" ] ; then
     1147                output="`ReadAllLink $location` $location $output"
     1148            fi
    11621149        done
    11631150    done
    11641151    if [ "$output" = "" ] ; then
    1165 #   echo "$fname_to_find not found" >> /dev/stderr
    1166     return 1
     1152        return 1
    11671153    fi
    11681154    echo "$output"
    1169     [ "$FILE_CACHE" ] && echo -ne "$cache_id $output\n" >> $FILE_CACHE
    11701155    return 0
    11711156}
     
    23472332        incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*\(\/.*\)/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
    23482333        for f in `echo "$incoming"` ; do
     2334            echo "$f"
    23492335            if [ -h "$f" ]; then
    23502336                g=`readlink $f`
    23512337                if [ -e "$g" ]; then
    2352                     echo "$f $g"
     2338                    echo "$g"
    23532339                else
    2354                     echo "Problem with ldd on $f"
    2355                     echo "$f"
     2340                    if [ "`echo $g | cut -c1`" != "/" ] ; then
     2341                        # that link is in the same dir
     2342                        g="`dirname $f`/$g"
     2343                        if -e "$g" ]; then
     2344                            echo "$g"
     2345                        else
     2346                            echo "Problem with ldd on $f" >> $LOGFILE
     2347                        fi
     2348                    else
     2349                        echo "Problem with ldd on $f" >> $LOGFILE
     2350                    fi
    23562351                fi
    23572352            else
    2358                 if [ -e "$f" ]; then
    2359                     echo "$f"
    2360                 else
    2361                     echo "Problem with ldd on $f"
     2353                if [ ! -e "$f" ]; then
     2354                    echo "Problem with ldd on $f" >> $LOGFILE
    23622355                fi
    23632356            fi
     
    24262419    cd $old_pwd
    24272420}
    2428 
    2429 
    2430 
    2431 EliminateRelatives() {
    2432 # eliminate /../../..... from path string
    2433     local orig i old_i newo
    2434     newo=$1
    2435     while [ "`echo "$newo" | grep "\.\."`" ] ; do
    2436         orig="`echo "$newo" | tr -s '/' '/'`"
    2437 #        echo "orig=$orig"
    2438         newo="/"
    2439         old_i=""
    2440         for i in `echo "$orig" | tr '/' ' '` ; do
    2441             if [ ! "$old_i" ] ; then
    2442                 old_i=$i
    2443                 continue
    2444             fi
    2445             if [ "$old_i" ] && [ "$i" = ".." ] ; then
    2446                 if [ "$old_i" = ".." ] ; then
    2447                     newo="$newo"$old_i/
    2448 #                    echo "two --- $old_i $i"
    2449                     old_i="$i"
    2450                     continue
    2451 #                else
    2452 #                    echo "swallowing ($old_i $i)"
    2453                 fi
    2454             elif [ "$old_i" != ".." ] ; then
    2455                 newo="$newo"$old_i/
    2456             fi
    2457             old_i=$i
    2458         done
    2459         newo="$newo"$i
    2460     done
    2461     echo "$newo"
    2462 }
    2463 
    2464 
    2465 WhatSoftlinkPointsTo() {
    2466     local orig new resolved
    2467         orig=$1
    2468         new=`ls -l $orig | tr -s ' ' '\t' | $AWK '{printf $NF;}'`
    2469         if [ "`echo "$new" | cut -d'/' -f1`" ] ; then
    2470             resolved=`dirname $orig`/$new
    2471         else
    2472             resolved=$new
    2473         fi
    2474     EliminateRelatives $resolved
    2475 }
    2476 
    2477 
    2478 
    24792421
    24802422
     
    25102452    resolved=$1
    25112453    while [ -h "$resolved" ] ; do
    2512         resolved=`WhatSoftlinkPointsTo $resolved`
     2454        resolved=`readlink -f $resolved`
    25132455    done
    25142456    echo "$resolved"
     
    32453187done
    32463188
    3247 FILE_CACHE=$TMP_ROOT/mindi-file-loc-cache
    32483189KERN_DISK_MADE=""
    32493190
Note: See TracChangeset for help on using the changeset viewer.