Changeset 863 in MondoRescue for trunk/mindi/mindi


Ignore:
Timestamp:
Oct 2, 2006, 12:26:44 AM (18 years ago)
Author:
Bruno Cornec
Message:

merge -r838:862 $SVN_M/branches/stable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mindi/mindi

    r839 r863  
    129129IDE_MODS="ide ide-generic ide-detect ide-mod ide-disk ide-cd ide_cd ide-cs ide-core ide_core libata edd paride ata_piix libata via82cxxx generic"
    130130PCMCIA_MODS="pcmcia_core ds yenta_socket"
    131 USB_MODS="usb-storage usb-ohci usb-uhci usbcore usb_storage hid uhci_hcd ehci_hcd uhci-hcd ehci-hcd usbkbd"
     131USB_MODS="usb-storage usb-ohci usb-uhci usbcore usb_storage hid uhci_hcd ehci_hcd uhci-hcd ehci-hcd usbkbd usbhid"
    132132CDROM_MODS="$TAPE_MODS $FLOPPY_MODS $IDE_MODS af_packet cdrom isocd isofs inflate_fs nls_iso8859-1 nls_cp437 sg sr_mod zlib_inflate $USB_MODS $PCMCIA_MODS"
    133133NET_MODS="sunrpc nfs nfs_acl lockd loop mii 3c59x e100 bcm5700 bnx2 e1000 eepro100 ne2k-pci tg3 pcnet32 8139cp 8139too 8390 vmxnet"
     
    571571    list_of_optimized_libraries=`grep "lib/i[5-7]86/" $filelist`
    572572    if [ "$list_of_optimized_libraries" = "" ] ; then
    573     return 0
     573        return 0
    574574    fi
    575575    echo -en "Dropping i686-optimized libraries if appropriate"
    576576    for optimized_lib_name in $list_of_optimized_libraries ; do
    577     echo -en "."
    578     reason=""
    579     vanilla_lib_name=`echo "$optimized_lib_name" | sed s/i[5-7]86// | tr -s '/' '/'`
    580     echo "$vanilla_lib_name" >> $filelist
    581     resolved=$vanilla_lib_name
    582     echo "Adding $resolved to filelist" >> $LOGFILE
    583     while [ -h "$resolved" ] ; do
    584         resolved=`ls $resolved -l|tr -s ' ' '\t'|$AWK '{printf $NF;}'`
    585         LocateFile $resolved >> $filelist
     577        echo -en "."
     578        reason=""
     579        vanilla_lib_name=`echo "$optimized_lib_name" | sed s/i[5-7]86// | tr -s '/' '/'`
     580        echo "$vanilla_lib_name" >> $filelist
     581        resolved=$vanilla_lib_name
    586582        echo "Adding $resolved to filelist" >> $LOGFILE
    587     done
    588     mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
    589     rmdir $outdir$optimized_lib_name > /dev/null 2> /dev/null
    590     ln -sf $vanilla_lib_name $outdir$optimized_lib_name
    591     echo "Excluding $optimized_lib_name" >> $LOGFILE
    592     grep -Fvx "$optimized_lib_name $filelist" > $filelist.tmp
    593     echo "Replacing it with $vanilla_lib_name" >> $LOGFILE
    594     echo "$vanilla_lib_name" >> $filelist.tmp
    595     mv -f $filelist.tmp $filelist
     583        resolved=`ReadAllLink $resolved`
     584        echo "Adding $resolved to filelist" >> $LOGFILE
     585        mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
     586        rmdir $outdir$optimized_lib_name > /dev/null 2> /dev/null
     587        ln -sf $vanilla_lib_name $outdir$optimized_lib_name
     588        echo "Excluding $optimized_lib_name" >> $LOGFILE
     589        grep -Fvx "$optimized_lib_name $filelist" > $filelist.tmp
     590        echo "Replacing it with $vanilla_lib_name" >> $LOGFILE
     591        echo "$vanilla_lib_name" >> $filelist.tmp
     592        mv -f $filelist.tmp $filelist
    596593    done
    597594    sort $filelist | $AWK '{ print $1; }' | uniq > $filelist.tmp
     
    796793    noof_lines=$2
    797794    while [ "$incoming" != "" ] ; do
    798     if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
    799 #       echo "Skipping '$incoming'"
    800         incoming=`ReadLine`
    801         continue
    802     fi
    803     if [ "$incoming" = "LVMFILES:" ] ; then
    804         break
    805     fi
    806 #   echo "Processing '$incoming'."
    807 #   sleep 1
     795        if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
     796#           echo "Skipping '$incoming'"
     797            incoming=`ReadLine`
     798            continue
     799        fi
     800        if [ "$incoming" = "LVMFILES:" ] ; then
     801            break
     802        fi
     803#       echo "Processing '$incoming'."
     804#       sleep 1
    808805        filelist=`GenerateListForFile "$incoming"`
    809806        r=$?
    810807        [ "$r" -ne "0" ] && LogIt "$incoming not found\n"
    811808        res=$(($res+$r))
    812 #   echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
     809#       echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
    813810        for fname in $filelist ; do
    814             [ "$fname" != "" ] && echo "$fname" >> $tempfile
    815     done
    816     progress=$(($progress+1))
    817     echo -en "\r\t\t\t\t\t\t\t\t"
    818     i=$(($progress*100))
    819     i=$(($i/$noof_lines))
    820     echo -en "$i"
    821     echo -en "%"
    822     modres=$(($progress%4))
    823     [ "$modres" -eq "0" ] && echo -en "\t/"
    824     [ "$modres" -eq "1" ] && echo -en "\t-"
    825     [ "$modres" -eq "2" ] && echo -en "\t\\"
    826     [ "$modres" -eq "3" ] && echo -en "\t|"
    827         incoming=`ReadLine`
    828     done
    829     if  [ "$incoming" = "LVMFILES:" ] ; then
    830         incoming=`ReadLine`
    831         lvmversion=""
    832     while [ "$incoming" != "" ] ; do
    833         if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
    834             incoming=`ReadLine`
    835             continue
    836         fi
    837         filelist=`GenerateListForFile "$incoming"`
    838         for tool in $filelist ; do
    839             lvmresolved=`ResolveSoftlink $tool`
    840             if [ "$tool" == "$lvmresolved" ]; then
    841                 echo "$tool" >> $tempfile
    842             elif echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
    843                 if [ "$lvmversion" = "" ] ; then
    844                     lvmversion=`$lvmresolved`
    845                     echo "$lvmresolved" >> $tempfile
    846                 fi
    847                 toolstripped=`echo $tool | $AWK -F / '{print $NF;}'`
    848                 if [ "$lvmversion" == "200" ]; then
    849                     # pvdata and lvmcreate_initrd don't exist in LVM2
    850                     case "$toolstripped" in
    851                     "pvdata")
    852                         continue
    853                         ;;
    854                     "lvmcreate_initrd")
    855                         continue
    856                         ;;
    857                     esac
    858                 fi
    859                 toolpath="/sbin/lvm-"$lvmversion"/"$toolstripped
    860                 if [ -e "$toolpath" ] ; then
    861                     echo "$toolpath" >> $tempfile
    862                     echo "$tool" >> $tempfile
    863                 else
    864                     toolpath="/lib/lvm-"$lvmversion"/"$toolstripped
    865                 fi
    866                 if [ -e "$toolpath" ] ; then
    867                     echo "$toolpath" >> $tempfile
    868                     echo "$tool" >> $tempfile
    869                 else
    870                     echo "Where are your LVM-Tools? Couldn't find $tool"
    871                 fi
    872             else
    873                 echo "$tool" >> $tempfile
    874             fi
     811            [ "$fname" != "" ] && echo "$fname" >> $tempfile
    875812        done
    876813        progress=$(($progress+1))
     
    887824        incoming=`ReadLine`
    888825    done
     826    if  [ "$incoming" = "LVMFILES:" ] ; then
     827        incoming=`ReadLine`
     828        lvmversion=""
     829        while [ "$incoming" != "" ] ; do
     830            if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
     831                incoming=`ReadLine`
     832                continue
     833            fi
     834            filelist=`GenerateListForFile "$incoming"`
     835            for tool in $filelist ; do
     836                lvmresolved=`readlink -f $tool`
     837                if [ "$tool" == "$lvmresolved" ]; then
     838                    echo "$tool" >> $tempfile
     839                elif echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
     840                    if [ "$lvmversion" = "" ] ; then
     841                        lvmversion=`$lvmresolved`
     842                        echo "$lvmresolved" >> $tempfile
     843                    fi
     844                    toolstripped=`echo $tool | $AWK -F / '{print $NF;}'`
     845                    if [ "$lvmversion" == "200" ]; then
     846                        # pvdata and lvmcreate_initrd don't exist in LVM2
     847                        case "$toolstripped" in
     848                        "pvdata")
     849                            continue
     850                            ;;
     851                        "lvmcreate_initrd")
     852                            continue
     853                            ;;
     854                        esac
     855                    fi
     856                    toolpath="/sbin/lvm-"$lvmversion"/"$toolstripped
     857                    if [ -e "$toolpath" ] ; then
     858                        echo "$toolpath" >> $tempfile
     859                        echo "$tool" >> $tempfile
     860                    else
     861                        toolpath="/lib/lvm-"$lvmversion"/"$toolstripped
     862                    fi
     863                    if [ -e "$toolpath" ] ; then
     864                        echo "$toolpath" >> $tempfile
     865                        echo "$tool" >> $tempfile
     866                    else
     867                        echo "Where are your LVM-Tools? Couldn't find $tool"
     868                    fi
     869                else
     870                    echo "$tool" >> $tempfile
     871                fi
     872            done
     873            progress=$(($progress+1))
     874            echo -en "\r\t\t\t\t\t\t\t\t"
     875            i=$(($progress*100))
     876            i=$(($i/$noof_lines))
     877            echo -en "$i"
     878            echo -en "%"
     879            modres=$(($progress%4))
     880            [ "$modres" -eq "0" ] && echo -en "\t/"
     881            [ "$modres" -eq "1" ] && echo -en "\t-"
     882            [ "$modres" -eq "2" ] && echo -en "\t\\"
     883            [ "$modres" -eq "3" ] && echo -en "\t|"
     884            incoming=`ReadLine`
     885        done
    889886    fi
    890887    echo -en "$DONE\nMaking complete dependency list"
     
    11561153        elif [ -h "$fname" ] && [ -x "$fname" ] ; then
    11571154            echo "$fname is softlink" >> $LOGFILE
    1158 #            echo "$fname will not be LDD'd. It is a softlink to `WhatSoftlinkPointsTo $fname`, which should already be in queue to be analyzed." >> $LOGFILE
    1159 #            echo "$fname"
    11601155        else
    11611156            ldd $fname 2> /dev/null | ProcessLDD $fname
     
    11641159}
    11651160
    1166 
     1161# Give all symlinks recursively of a full path name
     1162ReadAllLink() {
     1163    file="$1"
     1164
     1165    if [ ! -h $file ]; then
     1166        echo "$file"
     1167        return 0
     1168    fi
     1169
     1170    link=`readlink $file`
     1171    d=`dirname $file`
     1172    if [ ! -e "$link" -a ! -e "$d/$link" ]; then
     1173        echo "Problem with dead link on $file -> $link" >> $LOGFILE
     1174    fi
     1175    if [ "`echo $link | cut -c1`" = "/" ]; then
     1176        echo "$link `ReadAllLink $link`"
     1177    else
     1178        d=`dirname $file`
     1179        echo "$link `ReadAllLink $d/$link`"
     1180    fi 
     1181}
    11671182
    11681183LocateFile() {
    11691184    local i path fname_to_find location output resolved tmp stub cache_id loclist
    11701185    fname_to_find="$1"
    1171     if [ "$FILE_CACHE" ] ; then
    1172         touch $FILE_CACHE
    1173         output=""; cache_id=`echo $fname_to_find | md5sum`
    1174         output=`sed -n -e "s/^$cache_id //p" $FILE_CACHE`
    1175         if [ ! "$output" = "" ] ; then
    1176             echo "$output"
    1177             return 0
    1178         fi
    1179     fi
    11801186    if echo "$fname_to_find" | grep -x "/.*" ; then
    1181     output="$fname_to_find"
    1182     location="$fname_to_find"
    1183     while [ -h "$location" ] ; do
    1184         resolved=`WhatSoftlinkPointsTo $location`
    1185         location=$resolved
    1186         output="$location $output"
    1187     done
    1188     echo "$output"
    1189     return 0
     1187        output="$fname_to_find"
     1188        if [ -h "$output" ] ; then
     1189            output="`ReadAllLink $output` $output"
     1190        fi
     1191        echo "$output"
     1192        return 0
    11901193    fi
    11911194    output=""
    11921195    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
    1193     [ ! -d "$path" ] && continue
    1194     location=`echo "$path/$fname_to_find" | tr -s '/' '/'`
    1195     if echo "$location" | grep "lib/lib" 2> /dev/null ; then
    1196         loclist=`find $path -maxdepth 1 | grep -F "$fname_to_find"`
    1197     else
    1198         loclist=$location
    1199     fi
    1200     for location in $loclist ; do
    1201         [ ! -e "$location" ] && continue
    1202         output="$location $output"
    1203         copies_found=$(($copies_found+1))
    1204         while [ -h "$location" ] ; do
    1205                 resolved=`WhatSoftlinkPointsTo $location`
    1206                 location=$resolved
    1207                 output="$location $output"
    1208             done
    1209 #       resolved=`file $location | $AWK '{print $NF;}'`
    1210 #       if [ "`echo "$resolved" | grep -F "/"`" = "" ] ; then
    1211 #           stub=`dirname $location`
    1212 #           output="/$stub/$resolved $output"
    1213 #       fi
    1214 #       fi
    1215     done
     1196        [ ! -d "$path" ] && continue
     1197        for location in "$path/$fname_to_find" ; do
     1198            [ ! -e "$location" ] && continue
     1199            output="$location $output"
     1200            if [ -h "$location" ] ; then
     1201                output="`ReadAllLink $location` $output"
     1202            fi
     1203        done
    12161204    done
    12171205    if [ "$output" = "" ] ; then
    1218 #   echo "$fname_to_find not found" >> /dev/stderr
    1219     return 1
     1206        return 1
    12201207    fi
    12211208    echo "$output"
    1222     [ "$FILE_CACHE" ] && echo -ne "$cache_id $output\n" >> $FILE_CACHE
    12231209    return 0
    12241210}
     
    13991385        [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue
    14001386        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
    1401             current_partition=`ResolveSoftlink $c_p`
     1387            current_partition=`readlink -f $c_p`
    14021388            [ "`echo "$current_partition" | grep -F "/dev/mapper"`" != "" ] && current_partition="$c_p"
    14031389            [ "`echo "$useless_dev" | grep -F "$current_partition"`" ] && continue
     
    14071393        [ "$c_p" = "none" ] && continue
    14081394        redhat_label=""
    1409         absolute_partition=`ResolveSoftlink $c_p`
     1395        absolute_partition=`readlink -f $c_p`
    14101396        partition_mountpt=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $2}' | head -n1`
    14111397
     
    14221408            redhat_label=`echo "$current_partition" | /bin/cut -d'=' -f2`
    14231409            actual_dev=""
     1410
     1411            # 1st try, findfs - the RHEL way of finding labels and their partitions
     1412            if [ -x "/sbin/findfs" ]; then
     1413                actual_dev=`/sbin/findfs LABEL=${redhat_label} 2> /dev/null`
     1414            fi
    14241415   
    1425             # 1st try : blkid, the good way for all LABEL except swap
    1426             if [ -x "/sbin/blkid" ]; then
     1416            # 2nd try : blkid, the good way for all LABEL except swap
     1417            if [ "x$actual_dev" = "x" -a -x "/sbin/blkid" ]; then
    14271418                actual_dev=`/sbin/blkid | /bin/grep "$redhat_label" | grep LABEL= | /bin/cut -d':' -f1`
    14281419                # For LVM FS it will give a /dev/dm-# which should then be converted
     
    14411432            fi
    14421433   
    1443             # 2nd try, which works on a standard partition (ext2/3), but not on swap
     1434            # 3rd try, which works on a standard partition (ext2/3), but not on swap
    14441435            # For LVM gives a /dev/mapper entry
    14451436            if [ "x$actual_dev" = "x" ]; then
     
    14471438            fi
    14481439   
    1449             # 3rd try, with vol_id
     1440            # 4th try, with vol_id
    14501441            # SWAP only
    14511442            if [ "x$actual_dev" = "x" -a -x "/sbin/vol_id" ]; then
     
    14601451            fi
    14611452
    1462             # 4th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice or SW-mydevice. e.g. : LABEL=SWAP-hda5
     1453            # 5th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice or SW-mydevice. e.g. : LABEL=SWAP-hda5
    14631454            # LABEL=SW-cciss/c0d0p3 (RDP)
     1455            # or could be a string that isn't a complete device name (eg. LABEL =SWAP-cciss/c0d0p)
    14641456            # SWAP only
    14651457            if [ "x$actual_dev" = "x" -a  _"`echo $current_partition | /bin/grep -iE 'LABEL=SWAP|LABEL=SW-'`" != _"" ]; then
    1466                 try_dev="`echo "$redhat_label" | /bin/cut -d '-' -f2`"
    1467                 present_dev="`/bin/cat /proc/swaps | /bin/grep -w /dev/$try_dev`"
    1468                 if [ "x$present_dev" != "x" ] ; then
    1469                     actual_dev="/dev/$try_dev"
    1470                 fi
     1458                    for try_dev in `tail +2 /proc/swaps | cut -d' ' -f1`
     1459                    do
     1460                        # Location of the swap label for kernel 2.6
     1461                        try_dev_label=`dd bs=1 count=16 skip=1052 if=$try_dev 2> /dev/null`
     1462                        if [ "x$try_dev_label" = "x$redhat_label" ]; then
     1463                            actual_dev=$try_dev
     1464                        fi
     1465                    done
    14711466            fi
    14721467
     
    14751470                current_partition=$actual_dev
    14761471            else
    1477                 Die "Your system uses a labelled partition ($current_partition), but you lack the tool to support it.\nPlease replace labels with their correct devices in /etc/fstab or install blkid|vol_id\n"
     1472                    Die "Your system uses a labelled partition ($current_partition), but you lack the tool to support it.\nPlease replace labels with their correct devices in /etc/fstab or install findfs|blkid|vol_id\n"
    14781473            fi
    14791474        else
     
    22842279#        [ "$?" -ne "0" ] && echo "Failed to save $i's MBR to bigdir" >> $LOGFILE
    22852280    j=$i
    2286     [ -h "$j" ] && j=`ResolveSoftlink $j`
     2281    [ -h "$j" ] && j=`readlink -f $j`
    22872282    LogIt "Creating /dev/boot_device ($j)\n"
    22882283    mkdir -p $bigdir/dev
     
    23382333    read incoming
    23392334    while [ "$incoming" != "" ] ; do
    2340         incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*\(.*\)[[:blank:]]*=>[[:blank:]]*\/.*/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
    2341         for fname in `echo "$incoming"` ; do
    2342             fname=`LocateFile $fname`
    2343             for f in $fname ; do
    2344                 [ -e "$f" ] && echo $f
    2345             done
     2335        # We take the full path name of the dyn. lib. we want
     2336        incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*\(\/.*\)/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
     2337        for f in `echo "$incoming"` ; do
     2338            echo "$f `ReadAllLink $f`"
    23462339        done
    23472340        read incoming
     
    23792372    diskno=1
    23802373    while [ "$diskno" -le "$noof_disks" ] ; do
    2381     mkdir -p $minidir_root/$diskno
     2374        mkdir -p $minidir_root/$diskno
    23822375        cd $minidir_root/$diskno
    23832376        for fname in `find -type d -o -print` ; do
     
    24082401    cd $old_pwd
    24092402}
    2410 
    2411 
    2412 
    2413 EliminateRelatives() {
    2414 # eliminate /../../..... from path string
    2415     local orig i old_i newo
    2416     newo=$1
    2417     while [ "`echo "$newo" | grep "\.\."`" ] ; do
    2418         orig="`echo "$newo" | tr -s '/' '/'`"
    2419 #        echo "orig=$orig"
    2420         newo="/"
    2421         old_i=""
    2422         for i in `echo "$orig" | tr '/' ' '` ; do
    2423             if [ ! "$old_i" ] ; then
    2424                 old_i=$i
    2425                 continue
    2426             fi
    2427             if [ "$old_i" ] && [ "$i" = ".." ] ; then
    2428                 if [ "$old_i" = ".." ] ; then
    2429                     newo="$newo"$old_i/
    2430 #                    echo "two --- $old_i $i"
    2431                     old_i="$i"
    2432                     continue
    2433 #                else
    2434 #                    echo "swallowing ($old_i $i)"
    2435                 fi
    2436             elif [ "$old_i" != ".." ] ; then
    2437                 newo="$newo"$old_i/
    2438             fi
    2439             old_i=$i
    2440         done
    2441         newo="$newo"$i
    2442     done
    2443     echo "$newo"
    2444 }
    2445 
    2446 
    2447 WhatSoftlinkPointsTo() {
    2448     local orig new resolved
    2449         orig=$1
    2450         new=`ls -l $orig | tr -s ' ' '\t' | $AWK '{printf $NF;}'`
    2451         if [ "`echo "$new" | cut -d'/' -f1`" ] ; then
    2452             resolved=`dirname $orig`/$new
    2453         else
    2454             resolved=$new
    2455         fi
    2456     EliminateRelatives $resolved
    2457 }
    2458 
    2459 
    2460 
    24612403
    24622404
     
    24842426    return 0
    24852427}
    2486 
    2487 
    2488 
    2489 
    2490 ResolveSoftlink() {
    2491     local resolved new
    2492     resolved=$1
    2493     while [ -h "$resolved" ] ; do
    2494         resolved=`WhatSoftlinkPointsTo $resolved`
    2495     done
    2496     echo "$resolved"
    2497 }
    2498 
    2499 
    25002428
    25012429
     
    32103138done
    32113139
    3212 FILE_CACHE=$TMP_ROOT/mindi-file-loc-cache
    32133140KERN_DISK_MADE=""
    32143141
Note: See TracChangeset for help on using the changeset viewer.