Changeset 861 in MondoRescue for branches/stable/mindi/mindi


Ignore:
Timestamp:
Sep 30, 2006, 1:19:52 AM (18 years ago)
Author:
Bruno Cornec
Message:

Fix bugs on ReadAllLink and use it more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi/mindi

    r860 r861  
    526526        resolved=$vanilla_lib_name
    527527        echo "Adding $resolved to filelist" >> $LOGFILE
    528         while [ -h "$resolved" ] ; do
    529             resolved=`readlink $resolved`
    530             echo "Adding $resolved to filelist" >> $LOGFILE
    531         done
     528        resolved=`ReadAllLink $resolved`
     529        echo "Adding $resolved to filelist" >> $LOGFILE
    532530        mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
    533531        rmdir $outdir$optimized_lib_name > /dev/null 2> /dev/null
     
    740738    noof_lines=$2
    741739    while [ "$incoming" != "" ] ; do
    742     if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
    743 #       echo "Skipping '$incoming'"
    744         incoming=`ReadLine`
    745         continue
    746     fi
    747     if [ "$incoming" = "LVMFILES:" ] ; then
    748         break
    749     fi
    750 #   echo "Processing '$incoming'."
    751 #   sleep 1
     740        if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
     741#           echo "Skipping '$incoming'"
     742            incoming=`ReadLine`
     743            continue
     744        fi
     745        if [ "$incoming" = "LVMFILES:" ] ; then
     746            break
     747        fi
     748#       echo "Processing '$incoming'."
     749#       sleep 1
    752750        filelist=`GenerateListForFile "$incoming"`
    753751        r=$?
    754752        [ "$r" -ne "0" ] && LogIt "$incoming not found\n"
    755753        res=$(($res+$r))
    756 #   echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
     754#       echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
    757755        for fname in $filelist ; do
    758             [ "$fname" != "" ] && echo "$fname" >> $tempfile
    759     done
    760     progress=$(($progress+1))
    761     echo -en "\r\t\t\t\t\t\t\t\t"
    762     i=$(($progress*100))
    763     i=$(($i/$noof_lines))
    764     echo -en "$i"
    765     echo -en "%"
    766     modres=$(($progress%4))
    767     [ "$modres" -eq "0" ] && echo -en "\t/"
    768     [ "$modres" -eq "1" ] && echo -en "\t-"
    769     [ "$modres" -eq "2" ] && echo -en "\t\\"
    770     [ "$modres" -eq "3" ] && echo -en "\t|"
    771         incoming=`ReadLine`
    772     done
    773     if  [ "$incoming" = "LVMFILES:" ] ; then
    774         incoming=`ReadLine`
    775         lvmversion=""
    776     while [ "$incoming" != "" ] ; do
    777         if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
    778             incoming=`ReadLine`
    779             continue
    780         fi
    781         filelist=`GenerateListForFile "$incoming"`
    782         for tool in $filelist ; do
    783             lvmresolved=`ResolveSoftlink $tool`
    784             if [ "$tool" == "$lvmresolved" ]; then
    785                 echo "$tool" >> $tempfile
    786             elif echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
    787                 if [ "$lvmversion" = "" ] ; then
    788                     lvmversion=`$lvmresolved`
    789                     echo "$lvmresolved" >> $tempfile
    790                 fi
    791                 toolstripped=`echo $tool | $AWK -F / '{print $NF;}'`
    792                 if [ "$lvmversion" == "200" ]; then
    793                     # pvdata and lvmcreate_initrd don't exist in LVM2
    794                     case "$toolstripped" in
    795                     "pvdata")
    796                         continue
    797                         ;;
    798                     "lvmcreate_initrd")
    799                         continue
    800                         ;;
    801                     esac
    802                 fi
    803                 toolpath="/sbin/lvm-"$lvmversion"/"$toolstripped
    804                 if [ -e "$toolpath" ] ; then
    805                     echo "$toolpath" >> $tempfile
    806                     echo "$tool" >> $tempfile
    807                 else
    808                     toolpath="/lib/lvm-"$lvmversion"/"$toolstripped
    809                 fi
    810                 if [ -e "$toolpath" ] ; then
    811                     echo "$toolpath" >> $tempfile
    812                     echo "$tool" >> $tempfile
    813                 else
    814                     echo "Where are your LVM-Tools? Couldn't find $tool"
    815                 fi
    816             else
    817                 echo "$tool" >> $tempfile
    818             fi
     756            [ "$fname" != "" ] && echo "$fname" >> $tempfile
    819757        done
    820758        progress=$(($progress+1))
     
    831769        incoming=`ReadLine`
    832770    done
     771    if  [ "$incoming" = "LVMFILES:" ] ; then
     772        incoming=`ReadLine`
     773        lvmversion=""
     774        while [ "$incoming" != "" ] ; do
     775            if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
     776                incoming=`ReadLine`
     777                continue
     778            fi
     779            filelist=`GenerateListForFile "$incoming"`
     780            for tool in $filelist ; do
     781                lvmresolved=`readlink -f $tool`
     782                if [ "$tool" == "$lvmresolved" ]; then
     783                    echo "$tool" >> $tempfile
     784                elif echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
     785                    if [ "$lvmversion" = "" ] ; then
     786                        lvmversion=`$lvmresolved`
     787                        echo "$lvmresolved" >> $tempfile
     788                    fi
     789                    toolstripped=`echo $tool | $AWK -F / '{print $NF;}'`
     790                    if [ "$lvmversion" == "200" ]; then
     791                        # pvdata and lvmcreate_initrd don't exist in LVM2
     792                        case "$toolstripped" in
     793                        "pvdata")
     794                            continue
     795                            ;;
     796                        "lvmcreate_initrd")
     797                            continue
     798                            ;;
     799                        esac
     800                    fi
     801                    toolpath="/sbin/lvm-"$lvmversion"/"$toolstripped
     802                    if [ -e "$toolpath" ] ; then
     803                        echo "$toolpath" >> $tempfile
     804                        echo "$tool" >> $tempfile
     805                    else
     806                        toolpath="/lib/lvm-"$lvmversion"/"$toolstripped
     807                    fi
     808                    if [ -e "$toolpath" ] ; then
     809                        echo "$toolpath" >> $tempfile
     810                        echo "$tool" >> $tempfile
     811                    else
     812                        echo "Where are your LVM-Tools? Couldn't find $tool"
     813                    fi
     814                else
     815                    echo "$tool" >> $tempfile
     816                fi
     817            done
     818            progress=$(($progress+1))
     819            echo -en "\r\t\t\t\t\t\t\t\t"
     820            i=$(($progress*100))
     821            i=$(($i/$noof_lines))
     822            echo -en "$i"
     823            echo -en "%"
     824            modres=$(($progress%4))
     825            [ "$modres" -eq "0" ] && echo -en "\t/"
     826            [ "$modres" -eq "1" ] && echo -en "\t-"
     827            [ "$modres" -eq "2" ] && echo -en "\t\\"
     828            [ "$modres" -eq "3" ] && echo -en "\t|"
     829            incoming=`ReadLine`
     830        done
    833831    fi
    834832    echo -en "$DONE\nMaking complete dependency list"
     
    11221120        echo "$link `ReadAllLink $link`"
    11231121    else
    1124             echo "$link `dirname $file`/`ReadAllLink $link`"
     1122        d=`dirname $file`
     1123        echo "$link `ReadAllLink $d/$link`"
    11251124    fi 
    11261125}
     
    11451144            output="$location $output"
    11461145            if [ -h "$location" ] ; then
    1147                 output="`ReadAllLink $location` $location $output"
     1146                output="`ReadAllLink $location` $output"
    11481147            fi
    11491148        done
     
    13311330        [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue
    13321331        if [ -h "$c_p" ] && [ "`echo "$c_p" | grep -F "/dev/hd"`" = "" ] && [ "`echo "$c_p" | grep -F "/dev/sd"`" = "" ] && [ "`echo "$c_p" | grep -F "/dev/md"`" = "" ] ; then
    1333             current_partition=`ResolveSoftlink $c_p`
     1332            current_partition=`readlink -f $c_p`
    13341333            [ "`echo "$current_partition" | grep -F "/dev/mapper"`" != "" ] && current_partition="$c_p"
    13351334            [ "`echo "$useless_dev" | grep -F "$current_partition"`" ] && continue
     
    13391338        [ "$c_p" = "none" ] && continue
    13401339        redhat_label=""
    1341         absolute_partition=`ResolveSoftlink $c_p`
     1340        absolute_partition=`readlink -f $c_p`
    13421341        partition_mountpt=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $2}' | head -n1`
    13431342
     
    22752274#        [ "$?" -ne "0" ] && echo "Failed to save $i's MBR to bigdir" >> $LOGFILE
    22762275    j=$i
    2277     [ -h "$j" ] && j=`ResolveSoftlink $j`
     2276    [ -h "$j" ] && j=`readlink -f $j`
    22782277    LogIt "Creating /dev/boot_device ($j)\n"
    22792278    mkdir -p $bigdir/dev
     
    24442443    return 0
    24452444}
    2446 
    2447 
    2448 
    2449 
    2450 ResolveSoftlink() {
    2451     local resolved new
    2452     resolved=$1
    2453     while [ -h "$resolved" ] ; do
    2454         resolved=`readlink -f $resolved`
    2455     done
    2456     echo "$resolved"
    2457 }
    2458 
    2459 
    24602445
    24612446
Note: See TracChangeset for help on using the changeset viewer.