Changeset 863 in MondoRescue for trunk/mindi/mindi
- Timestamp:
- Oct 2, 2006, 12:26:44 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mindi/mindi
r839 r863 129 129 IDE_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" 130 130 PCMCIA_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 "131 USB_MODS="usb-storage usb-ohci usb-uhci usbcore usb_storage hid uhci_hcd ehci_hcd uhci-hcd ehci-hcd usbkbd usbhid" 132 132 CDROM_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" 133 133 NET_MODS="sunrpc nfs nfs_acl lockd loop mii 3c59x e100 bcm5700 bnx2 e1000 eepro100 ne2k-pci tg3 pcnet32 8139cp 8139too 8390 vmxnet" … … 571 571 list_of_optimized_libraries=`grep "lib/i[5-7]86/" $filelist` 572 572 if [ "$list_of_optimized_libraries" = "" ] ; then 573 return 0573 return 0 574 574 fi 575 575 echo -en "Dropping i686-optimized libraries if appropriate" 576 576 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 586 582 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 596 593 done 597 594 sort $filelist | $AWK '{ print $1; }' | uniq > $filelist.tmp … … 796 793 noof_lines=$2 797 794 while [ "$incoming" != "" ] ; do 798 if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then799 # echo "Skipping '$incoming'"800 incoming=`ReadLine`801 continue802 fi803 if [ "$incoming" = "LVMFILES:" ] ; then804 break805 fi806 # echo "Processing '$incoming'."807 # sleep 1795 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 808 805 filelist=`GenerateListForFile "$incoming"` 809 806 r=$? 810 807 [ "$r" -ne "0" ] && LogIt "$incoming not found\n" 811 808 res=$(($res+$r)) 812 # echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE809 # echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE 813 810 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 875 812 done 876 813 progress=$(($progress+1)) … … 887 824 incoming=`ReadLine` 888 825 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 889 886 fi 890 887 echo -en "$DONE\nMaking complete dependency list" … … 1156 1153 elif [ -h "$fname" ] && [ -x "$fname" ] ; then 1157 1154 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." >> $LOGFILE1159 # echo "$fname"1160 1155 else 1161 1156 ldd $fname 2> /dev/null | ProcessLDD $fname … … 1164 1159 } 1165 1160 1166 1161 # Give all symlinks recursively of a full path name 1162 ReadAllLink() { 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 } 1167 1182 1168 1183 LocateFile() { 1169 1184 local i path fname_to_find location output resolved tmp stub cache_id loclist 1170 1185 fname_to_find="$1" 1171 if [ "$FILE_CACHE" ] ; then1172 touch $FILE_CACHE1173 output=""; cache_id=`echo $fname_to_find | md5sum`1174 output=`sed -n -e "s/^$cache_id //p" $FILE_CACHE`1175 if [ ! "$output" = "" ] ; then1176 echo "$output"1177 return 01178 fi1179 fi1180 1186 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 1190 1193 fi 1191 1194 output="" 1192 1195 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 1216 1204 done 1217 1205 if [ "$output" = "" ] ; then 1218 # echo "$fname_to_find not found" >> /dev/stderr 1219 return 1 1206 return 1 1220 1207 fi 1221 1208 echo "$output" 1222 [ "$FILE_CACHE" ] && echo -ne "$cache_id $output\n" >> $FILE_CACHE1223 1209 return 0 1224 1210 } … … 1399 1385 [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue 1400 1386 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` 1402 1388 [ "`echo "$current_partition" | grep -F "/dev/mapper"`" != "" ] && current_partition="$c_p" 1403 1389 [ "`echo "$useless_dev" | grep -F "$current_partition"`" ] && continue … … 1407 1393 [ "$c_p" = "none" ] && continue 1408 1394 redhat_label="" 1409 absolute_partition=` ResolveSoftlink$c_p`1395 absolute_partition=`readlink -f $c_p` 1410 1396 partition_mountpt=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $2}' | head -n1` 1411 1397 … … 1422 1408 redhat_label=`echo "$current_partition" | /bin/cut -d'=' -f2` 1423 1409 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 1424 1415 1425 # 1sttry : blkid, the good way for all LABEL except swap1426 if [ -x "/sbin/blkid" ]; then1416 # 2nd try : blkid, the good way for all LABEL except swap 1417 if [ "x$actual_dev" = "x" -a -x "/sbin/blkid" ]; then 1427 1418 actual_dev=`/sbin/blkid | /bin/grep "$redhat_label" | grep LABEL= | /bin/cut -d':' -f1` 1428 1419 # For LVM FS it will give a /dev/dm-# which should then be converted … … 1441 1432 fi 1442 1433 1443 # 2nd try, which works on a standard partition (ext2/3), but not on swap1434 # 3rd try, which works on a standard partition (ext2/3), but not on swap 1444 1435 # For LVM gives a /dev/mapper entry 1445 1436 if [ "x$actual_dev" = "x" ]; then … … 1447 1438 fi 1448 1439 1449 # 3rdtry, with vol_id1440 # 4th try, with vol_id 1450 1441 # SWAP only 1451 1442 if [ "x$actual_dev" = "x" -a -x "/sbin/vol_id" ]; then … … 1460 1451 fi 1461 1452 1462 # 4th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice or SW-mydevice. e.g. : LABEL=SWAP-hda51453 # 5th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice or SW-mydevice. e.g. : LABEL=SWAP-hda5 1463 1454 # LABEL=SW-cciss/c0d0p3 (RDP) 1455 # or could be a string that isn't a complete device name (eg. LABEL =SWAP-cciss/c0d0p) 1464 1456 # SWAP only 1465 1457 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 1471 1466 fi 1472 1467 … … 1475 1470 current_partition=$actual_dev 1476 1471 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 installblkid|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" 1478 1473 fi 1479 1474 else … … 2284 2279 # [ "$?" -ne "0" ] && echo "Failed to save $i's MBR to bigdir" >> $LOGFILE 2285 2280 j=$i 2286 [ -h "$j" ] && j=` ResolveSoftlink$j`2281 [ -h "$j" ] && j=`readlink -f $j` 2287 2282 LogIt "Creating /dev/boot_device ($j)\n" 2288 2283 mkdir -p $bigdir/dev … … 2338 2333 read incoming 2339 2334 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`" 2346 2339 done 2347 2340 read incoming … … 2379 2372 diskno=1 2380 2373 while [ "$diskno" -le "$noof_disks" ] ; do 2381 mkdir -p $minidir_root/$diskno2374 mkdir -p $minidir_root/$diskno 2382 2375 cd $minidir_root/$diskno 2383 2376 for fname in `find -type d -o -print` ; do … … 2408 2401 cd $old_pwd 2409 2402 } 2410 2411 2412 2413 EliminateRelatives() {2414 # eliminate /../../..... from path string2415 local orig i old_i newo2416 newo=$12417 while [ "`echo "$newo" | grep "\.\."`" ] ; do2418 orig="`echo "$newo" | tr -s '/' '/'`"2419 # echo "orig=$orig"2420 newo="/"2421 old_i=""2422 for i in `echo "$orig" | tr '/' ' '` ; do2423 if [ ! "$old_i" ] ; then2424 old_i=$i2425 continue2426 fi2427 if [ "$old_i" ] && [ "$i" = ".." ] ; then2428 if [ "$old_i" = ".." ] ; then2429 newo="$newo"$old_i/2430 # echo "two --- $old_i $i"2431 old_i="$i"2432 continue2433 # else2434 # echo "swallowing ($old_i $i)"2435 fi2436 elif [ "$old_i" != ".." ] ; then2437 newo="$newo"$old_i/2438 fi2439 old_i=$i2440 done2441 newo="$newo"$i2442 done2443 echo "$newo"2444 }2445 2446 2447 WhatSoftlinkPointsTo() {2448 local orig new resolved2449 orig=$12450 new=`ls -l $orig | tr -s ' ' '\t' | $AWK '{printf $NF;}'`2451 if [ "`echo "$new" | cut -d'/' -f1`" ] ; then2452 resolved=`dirname $orig`/$new2453 else2454 resolved=$new2455 fi2456 EliminateRelatives $resolved2457 }2458 2459 2460 2461 2403 2462 2404 … … 2484 2426 return 0 2485 2427 } 2486 2487 2488 2489 2490 ResolveSoftlink() {2491 local resolved new2492 resolved=$12493 while [ -h "$resolved" ] ; do2494 resolved=`WhatSoftlinkPointsTo $resolved`2495 done2496 echo "$resolved"2497 }2498 2499 2500 2428 2501 2429 … … 3210 3138 done 3211 3139 3212 FILE_CACHE=$TMP_ROOT/mindi-file-loc-cache3213 3140 KERN_DISK_MADE="" 3214 3141
Note:
See TracChangeset
for help on using the changeset viewer.