Changeset 1902


Ignore:
Timestamp:
Apr 9, 2008, 12:05:24 AM (11 years ago)
Author:
bruno
Message:

mindi simplification, by not managing multiple data disks anymore

Location:
branches/2.2.6
Files:
1 deleted
4 edited

Legend:

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

    r1840 r1902  
    2727fstab raidtab modules.conf conf.modules mondorestore modules.conf.local
    2828/etc/mdadm/mdadm.conf /etc/mdadm.conf
     29/sbin/ldconfig
    2930afio star ntfsclone parted ms-sys file getfattr setfattr getfacl setfacl
    3031buffer
     
    5657
    5758# For Debug  mode
    58 # gdb
     59# gdb valgrind /usr/lib/valgrind
    5960
    6061#----------------- For all you LVM users out there, much love -----------------
  • branches/2.2.6/mindi/mindi

    r1901 r1902  
    141141AddFileToCfgIfExists() {
    142142    [ -e "$1" ] && echo -en "$2 `cat $1`\n" >> $3
    143 }
    144 
    145 
    146 AddFileToDir() {
    147     local filename minidir_root noof_disks diskno res filesize would_occupy zipsize complevel cutoff compressed_fname siz
    148     filename=$1
    149     minidir_root=$2
    150     noof_disks=$3
    151 
    152     diskno=$noof_disks
    153     mkdir -p $minidir_root/$diskno
    154     [ "$LAST_COMPRESSED_SIZE" = "" ] && LAST_COMPRESSED_SIZE=0
    155     if [ ! -e "$filename" ] ; then
    156         if [ -h "$filename" ] ; then
    157             cp --parents -pRdf $filename $minidir_root/$diskno 2>> $LOGFILE
    158             return $noof_disks
    159         else
    160             Die "AddFileToDir asked me to add $filename, which does not exist. Oops! Did you run out of disk space or is your Linux distro severely broken?"
    161         fi
    162     fi
    163 
    164     # move to the disk that has room on it (or end up using the last, if all full)
    165     while [ "$diskno" -lt $MAX_DISKS ] ; do
    166         mkdir -p $minidir_root/$diskno
    167         filesize=`du -sk $filename | cut -f1`
    168         cp --parents -Rdf $filename $minidir_root/$diskno 2>> $LOGFILE
    169         if [ "$filesize" -le "4" ] ; then
    170             siz=$filesize
    171         elif [ ! -f "$filename" ] ; then
    172             siz=0
    173         else
    174             siz=`grep -m 1 "$filename.gz$" $minidir_root/compressed/compressed.txt | cut -f1`
    175             [ "$siz" = "" ] && Die "FIXME - can't find $filename's size."
    176             siz=$(($siz-2));# to allow for sectors & the fact that they round up
    177         fi
    178         [ ! "$siz" ] && siz=4
    179         [ "$siz" -lt "0" ] && siz=0
    180         LAST_COMPRESSED_SIZE=$(($LAST_COMPRESSED_SIZE+$siz))
    181         [ "$LAST_COMPRESSED_SIZE" -le "$MAX_COMPRESSED_SIZE" ] &&return $diskno
    182         echo "disk=$diskno siz=$LAST_COMPRESSED_SIZE" >> $LOGFILE
    183         LAST_COMPRESSED_SIZE=0
    184         rm -f $minidir_root/$diskno/$filename
    185         diskno=$(($diskno+1))
    186     done
    187     return 0 ; # failed
    188143}
    189144
     
    377332    done
    378333    echo $r
    379 }
    380 
    381 
    382 CreateDataDiskImagesFromTarballs() {
    383     local tardir outdir diskno noof_disks kp
    384     tardir=$1
    385     outdir=$2
    386     noof_disks=$3
    387 
    388     mkdir -p $outdir
    389     diskno=1
    390     echo -en "Creating data disk "
    391     while [ "$diskno" -le "$noof_disks" ] ; do
    392         echo -en "#$diskno..."
    393         cp -f $tardir/$diskno.tar.gz $outdir 2>> $LOGFILE || LogIt "[line 424] Cannot copy $tardir/$diskno.tar.gz to $outdir"
    394         CreateOneDataDiskImage $tardir/$diskno.tar.gz $outdir/mindi-data-$diskno.img $diskno $noof_disks
    395         diskno=$(($diskno+1))
    396     done
    397     mv -f $tardir/all.tar.gz $outdir
    398     du -sk $outdir/*gz >> $LOGFILE
    399     echo -e "$DONE"
    400 }
    401 
    402 
    403 
    404 CreateOneDataDiskImage() {
    405     local tarball imagefile dev diskno noof_disks mountpoint
    406     tarball=$1
    407     imagefile=$2
    408     diskno=$3
    409     noof_disks=$4
    410 
    411     mountpoint=$MINDI_TMP/mountpoint.$$
    412     mkdir -p $mountpoint
    413     dd if=/dev/zero of=$imagefile bs=1k count=1440 &> /dev/null || LogIt "Cannot dd (CODI)"
    414     echo "Creating ext2 filesystem on $imagefile" >> $LOGFILE
    415     mke2fs -N 12 -F $imagefile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $imagefile"
    416     mount -t ext2 -o loop $imagefile $mountpoint || Die "Can't loopmount $imagefile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."
    417     mv $tarball $mountpoint/
    418     if [ "$?" -ne "0" ] ; then
    419         umount $mountpoint
    420         rmdir $mountpoint
    421         Die "Tarball $tarball is too big for disk! (CODI)\nAdjust mindi_max_compressed_size in your $MINDI_CONFIG"
    422     fi
    423     [ "$diskno" -eq "$noof_disks" ] && echo "This is the last disk ($diskno=$noof_disks)" >> $mountpoint/LAST-DISK
    424     umount $mountpoint || LogIt "Cannot umount (CODI)"
    425     rmdir $mountpoint || LogIt "Cannot rmdir (CODI)"
    426334}
    427335
     
    16041512
    16051513
    1606 MoveHyperlinkSensibly() {
    1607     local filename minidir_root resides_on_diskno noof_disks old_diskno d old_pwd
    1608     filename=$1
    1609     minidir_root=$2
    1610     resides_on_diskno=$3
    1611     noof_disks=$4
    1612 
    1613     [ -h "$minidir_root/$resides_on_diskno/$filename" ] || Die "$filename isn't a softlink (or doesn't exist): how can I move it sensibly?"
    1614 
    1615     old_diskno=$resides_on_diskno
    1616     d=1
    1617     while [ "$d" -le "$noof_disks" ] ; do
    1618         if [ "$d" -ne "$old_diskno" ] ; then
    1619             old_pwd=`pwd`
    1620             cd $minidir_root/$old_diskno
    1621             cp --parents -Rdf $filename $minidir_root/$d/ 2>> $LOGFILE || Die "Can't move $filename (sensibly) from $old_diskno to $d"
    1622             rm -f $filename
    1623             cd $old_pwd
    1624         fi
    1625 # when the softlink is resolvable, our work here is done
    1626         [ -e "$minidir_root/$d/$filename" ] && return 0
    1627         old_diskno=$d
    1628         d=$(($d+1))
    1629     done
    1630     return 1
    1631 }
    1632 
    1633 
    16341514OfferToMakeBootableISO() {
    16351515    local i old_pwd
     
    18251705    fi
    18261706    echo -en "."
    1827 }
    1828 
    1829 
    1830 PluralOrNot() {
    1831     [ "$1" -gt "1" ] && echo -en "s"
    18321707}
    18331708
     
    21682043
    21692044PrepareDataDiskImages() {
    2170     local needlist bigdir minidir_root tardir diskdir imagesdir res i j k old_pwd lines lfiles
     2045    local needlist bigdir diskdir imagesdir res i j k old_pwd lines lfiles
    21712046
    21722047    imagesdir=$1
    2173     rm -f $imagesdir/mindi-*.img $imagesdir/[0-9]*.tar.gz $imagesdir/mindi.iso
     2048    rm -f $imagesdir/mindi.iso
    21742049    needlist=$MINDI_TMP/what-we-need.txt
    21752050    bigdir=$MINDI_TMP/bigdir
    2176     minidir_root=$MINDI_TMP/minidir
    2177     mkdir -p $minidir_root
    21782051    mkdir -p $bigdir/usr/bin
    2179     tardir=$MINDI_TMP/tardir
    21802052
    21812053    lfiles="$DEPLIST_FILE"
     
    22132085    fi
    22142086    if [ "$res" -ne "0" ] ; then
    2215         Die "You have $res file`PluralOrNot $res` present in dependency list\nbut absent from filesystem."
     2087        Die "You have $res files present in dependency list\nbut absent from filesystem."
    22162088    fi
    22172089    FindAndAddUserKeyboardMappingFile
     
    22632135    echo -e "$DONE"
    22642136    TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
    2265     SplitDirectoryIntoMinidirs $bigdir $minidir_root
    2266     noof_disks=$?
    2267     [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"
    22682137    MakeMountlist $MINDI_TMP/mountlist.txt
    2269     mkdir -p $minidir_root/$noof_disks/tmp
    2270     cp -f $MINDI_TMP/mountlist.txt $minidir_root/$noof_disks/tmp/mountlist.txt 2> /dev/null || Die "Cannot copy mountlist.txt from $MINDI_TMP to data disk"
     2138    mkdir -p $bigdir/tmp
     2139    cp -f $MINDI_TMP/mountlist.txt $bigdir/tmp/mountlist.txt 2> /dev/null || Die "Cannot copy mountlist.txt from $MINDI_TMP to data disk"
    22712140    if [ _"$MONDO_SHARE" != _"" ]; then
    2272         cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MINDI_TMP/. 2>> $LOGFILE
    2273     fi
    2274     [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm || LVM="false"
    2275     cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
    2276     ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
    2277     CreateDataDiskImagesFromTarballs $tardir $imagesdir $noof_disks
     2141        cp -f $bigdir/tmp/mountlist.txt $MINDI_TMP/. 2>> $LOGFILE
     2142    fi
     2143    [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $bigdir/tmp/i-want-my-lvm || LVM="false"
     2144    cat $bigdir/tmp/mountlist.txt >> $LOGFILE
     2145    echo -en "$FILES_IN_FILELIST" > $bigdir/FILES-IN-FILELIST 2> /dev/null
     2146    echo -en "$LAST_FILELIST_NUMBER" > $bigdir/LAST-FILELIST-NUMBER 2> /dev/null
     2147    if [ _"$MONDO_SHARE" != _"" ]; then
     2148        for q in filelist.full.gz biggielist.txt ; do
     2149            [ ! -e "$MINDI_TMP/$q" ] && Die "Cannot find $MINDI_TMP/$q"
     2150            cp -pRdf $MINDI_TMP/$q $bigdir/tmp 2>> $LOGFILE
     2151        done
     2152    fi
     2153
     2154    echo -en "Tarring and zipping the data content..."
     2155    size_of_all_tools=`du -sk $bigdir | cut -f1`
     2156    (cd $bigdir ; tar -b 4096 -cf - . 2> /dev/null | gzip -9 > $imagesdir/all.tar.gz)
     2157    du -sk $imagesdir/*gz >> $LOGFILE
     2158    echo -e "$DONE"
     2159
    22782160    FRIENDLY_OUTSTRING="Boot and data disk images were created."
    2279     # One 1.72MB boot disk, one 2.88MB boot disk and $noof_disks data disk images
    2280     rmdir $tardir $bigdir
     2161    rm -rf $bigdir
    22812162    rm -f $needlist
    2282     return $noof_disks
    22832163}
    22842164
     
    23322212
    23332213
    2334 RejigHyperlinks() {
    2335     local minidir_root noof_disks fname path diskno old_pwd awk_loc gawk_loc dir i
    2336     minidir_root=$1
    2337     noof_disks=$2
    2338 
    2339     old_pwd=`pwd`
    2340     diskno=1
    2341     while [ "$diskno" -le "$noof_disks" ] ; do
    2342         mkdir -p $minidir_root/$diskno
    2343         cd $minidir_root/$diskno
    2344         for fname in `find -type d -o -print` ; do
    2345             [ -h "$minidir_root/$diskno/$fname" ] && MoveHyperlinkSensibly $fname $minidir_root $diskno $noof_disks
    2346         done
    2347         diskno=$(($diskno+1))
    2348     done
    2349 
    2350     cd $old_pwd
    2351     return
    2352 }
    2353 
    2354 
    23552214ReplaceIndividualLine() {
    23562215    local orig_file new_file lino newstring lines_total lines_remaining
     
    24392298
    24402299
    2441 SplitDirectoryIntoMinidirs() {
    2442     local bigdir minidir_root i noof_disks old_pwd res
    2443 
    2444     bigdir=$1
    2445     minidir_root=$2
    2446     [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
    2447 
    2448     TryToFitDataIntoSeveralDirs $bigdir $minidir_root
    2449     noof_disks=$?
    2450     if [ "$noof_disks" -eq "0" ] ; then
    2451         echo "Failed to fit data into several dirs."
    2452         return 0
    2453     fi
    2454     RejigHyperlinks $minidir_root $noof_disks
    2455     [ "$bigdir" != "" ] && rm -Rf $bigdir/*
    2456     return $noof_disks
    2457 }
    2458 
    24592300
    24602301StripExecutable()
     
    24712312    fi
    24722313    rm -f $tmpfile
    2473 }
    2474 
    2475 
    2476 TemporarilyCompressAllFiles() {
    2477     local i orig_fname out_fname out_list
    2478 
    2479     i=0
    2480     out_list=$2/compressed/compressed.txt
    2481     mkdir -p $2/compressed
    2482     > $out_list
    2483     for orig_fname in $1 ; do
    2484         out_fname=$2/compressed/$orig_fname.gz
    2485         mkdir -p $out_fname 2> /dev/null
    2486         rmdir $out_fname 2> /dev/null
    2487         gzip -c6 $orig_fname > $out_fname 2> /dev/null
    2488         i=$(((($i+1))%15))
    2489         [ "$i" -eq "0" ] && echo -en "."
    2490         du -sk $out_fname >> $out_list
    2491     done
    24922314}
    24932315
     
    25872409    fi
    25882410    echo "$output" | tr -s ' ' '\n' | sort -u | tr '\n' ' '
    2589 }
    2590 
    2591 
    2592 TryToFitDataIntoSeveralDirs() {
    2593     local bigdir minidir_root noof_disks diskno list_of_files filename old_pwd progress
    2594     local i retval noof_disks total_files list_of_devs
    2595 
    2596     bigdir=$1
    2597     minidir_root=$2
    2598     BIG_CLUNKY_SIZE_COUNTER=0
    2599     retval=0
    2600     noof_disks=1
    2601 
    2602     echo -en "\r                                                                            \rDividing data into several groups..."
    2603     old_pwd=`pwd`
    2604     cd $bigdir
    2605     list_of_files=`GetFileSizeList . | sort -nr | cut -f2 | grep -Fv "/dev/"`
    2606     progress=0
    2607     total_files=`CountItemsIn "$list_of_files"`
    2608     if [ "`echo "$filename" | grep -x "/dev/.*"`" ] ; then
    2609         filesize=1
    2610     fi
    2611     mkdir -p $minidir_root/$noof_disks
    2612     if [ -e "dev" ] ; then
    2613         echo "Copying dev/* to $minidir_root/$noof_disks" >> $LOGFILE
    2614         cp --parents -pRdf dev $minidir_root/$noof_disks 2>> $LOGFILE
    2615     fi
    2616     TemporarilyCompressAllFiles "$list_of_files" $minidir_root
    2617     for filename in $list_of_files ; do
    2618         AddFileToDir $filename $minidir_root $noof_disks
    2619         i=$?
    2620         if [ "$i" -gt "$noof_disks" ] ; then
    2621             noof_disks=$i
    2622             echo -en "\r\t\t\t\t\t\t($noof_disks disks)"
    2623         fi
    2624         if [ "$i" -eq "0" ] ; then
    2625             LogIt "Cannot add file $filename to minidir $minidir_root"
    2626             retval=$(($retval+1))
    2627         fi
    2628         progress=$(($progress+1))
    2629         echo -en "\r\t\t\t\t\t\t\t\t$(($progress*100/$total_files))% complete\r"
    2630     done
    2631     cd $old_pwd
    2632     echo -en "\rThe files have been subdivided into $noof_disks directories.                                                            \r"
    2633     [ "$minidir_root" != "" ] && rm -Rf $minidir_root/compressed
    2634     if [ "$retval" -gt "0" ] ; then
    2635         return 0
    2636     else
    2637         return $noof_disks
    2638     fi
    26392411}
    26402412
     
    29052677}
    29062678
    2907 
    2908 ZipMinidirsIntoTarballs() {
    2909     local minidir_root tardir noof_disks diskno old_pwd i
    2910     minidir_root=$1
    2911     tardir=$2
    2912     noof_disks=$3
    2913 
    2914     echo -en "Tarring and zipping the group`PluralOrNot $noof_disks`..."
    2915     mkdir -p $tardir
    2916     mkdir -p $minidir_root/all
    2917     old_pwd=`pwd`
    2918     diskno=1
    2919     while [ "$diskno" -le "$noof_disks" ] ; do
    2920         cd $minidir_root/$diskno || LogIt "WARNING - cannot cd to $minidir_root/$diskno"
    2921         tar -cf - . 2>> $LOGFILE | gzip -9 > $tardir/$diskno.tar.gz || Die "Can't tar/gzip disk#$diskno; please tell Dev Team -exactly- what the errors where."
    2922         diskno=$(($diskno+1))
    2923         echo -n "..."
    2924         cp -pRdf * $minidir_root/all 2>> $LOGFILE
    2925     done
    2926     mkdir -p $minidir_root/all/tmp
    2927     cd $minidir_root/all
    2928     size_of_all_tools=`du -sk . | cut -f1`
    2929     if [ _"$MONDO_SHARE" != _"" ]; then
    2930         for q in filelist.full.gz biggielist.txt ; do
    2931             [ ! -e "$MINDI_TMP/$q" ] && Die "Cannot find $MINDI_TMP/$q"
    2932             cp -pRdf $MINDI_TMP/$q tmp/ 2>> $LOGFILE
    2933         done
    2934         mkdir -p $minidir_root/all/tmp
    2935         echo -en "$FILES_IN_FILELIST" > $minidir_root/all/tmp/FILES-IN-FILELIST 2> /dev/null
    2936         echo -en "$LAST_FILELIST_NUMBER" > $minidir_root/all/tmp/LAST-FILELIST-NUMBER 2> /dev/null
    2937     fi
    2938     tar -b 4096 -cf - * 2> /dev/null | gzip -9 > $tardir/all.tar.gz
    2939     dd if=/dev/zero bs=1k count=64 >> $imagesdir/all.tar.gz 2> /dev/null
    2940     [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"
    2941     cd $old_pwd
    2942     [ "$minidir_root" != "" ] && rm -Rf $minidir_root
    2943     echo -e "$DONE"
    2944 }
    29452679
    29462680
     
    34043138
    34053139PrepareDataDiskImages $MINDI_CACHE
    3406 noof_disks=$?
    34073140ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))
    34083141rds=$(($ramdisk_size-$((ramdisk_size%4096))))
  • branches/2.2.6/mindi/rootfs/sbin/install-additional-tools

    r1841 r1902  
    2020mountdir=$GROOVY
    2121# Should be the same as in mindi => conf param
    22 MAX_DISKS=99
    2322mkdir -p $mountdir
    24 diskno=1
    2523res=0
    2624if [ -e "/tmp/TAPEDEV-HAS-DATA-DISKS" ] ; then
    2725    LogIt "I am assuming the data disks' contents are already in $mountdir."
    2826else
    29     while [ "$diskno" -lt "$MAX_DISKS" ] ; do
    30         LogIt "PLEASE WAIT. Untarring disk #$diskno" 2
    31         untar $diskno $mountdir
    32         res=$(($res+$?))
    33         [ -e "/LAST-DISK" ] && diskno=999
    34         diskno=$(($diskno+1))
    35         [ -e "/tmp/CDROM-LIVES-HERE" ] && [ ! -f "/mnt/cdrom/images/$diskno.tar.gz" ] && break
    36     done
     27    LogIt "PLEASE WAIT. Untarring data content" 2
     28
     29    mountpoint=/dev/null
     30    [ -e "/tmp/CDROM-LIVES-HERE" ] && mountpoint=/mnt/cdrom/images
     31    tarball=$mountpoint/all.tar.gz
     32    if [ -e "/tmp/CDROM-LIVES-HERE" ] ; then
     33        [ -e "$tarball" ] || LogIt "Can't find CD's $tarball" 1
     34    fi
     35
     36    old_pwd=`pwd`
     37    cd $mountdir
     38    counter=0
     39    for fname in `tar -zxvf $tarball` ; do
     40     counter=$(($counter+1))
     41        [ "$(($counter % 4))" -eq "0" ] && echo -en "\r\t\t\t\t\t\t\t\\"
     42        [ "$(($counter % 4))" -eq "1" ] && echo -en "\r\t\t\t\t\t\t\t|"
     43        [ "$(($counter % 4))" -eq "2" ] && echo -en "\r\t\t\t\t\t\t\t/"
     44        [ "$(($counter % 4))" -eq "3" ] && echo -en "\r\t\t\t\t\t\t\t-"
     45    done
     46    cd $old_pwd
     47    echo -e -n "\r"
     48    [ ! -e "/tmp/CDROM-LIVES-HERE" ] && umount $mountpoint
     49    sleep 1
    3750fi
    38 rm -f /LAST-DISK
    3951
    4052LogIt "Recombining large files..." 1
  • branches/2.2.6/mondo/src/mondorestore/mondo-restore.c

    r1885 r1902  
    29612961    make_hole_for_dir(MONDO_CACHE);
    29622962
    2963 /* Backup original mountlist.txt */
     2963    /* Backup original mountlist.txt */
    29642964    sprintf(tmp, "%s.orig", g_mountlist_fname);
    29652965    if (!does_file_exist(g_mountlist_fname)) {
     
    29732973    }
    29742974
    2975 /* Init directories */
     2975    /* Init directories */
    29762976    make_hole_for_dir("/var/log");
    29772977    make_hole_for_dir("/tmp/tmpfs");    /* just in case... */
     
    29842984    run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE);
    29852985
    2986 /* Init GUI */
     2986    /* Init GUI */
    29872987    malloc_libmondo_global_strings();
    29882988    setup_newt_stuff();         /* call newtInit and setup screen log */
     
    29962996    iamhere("what time is it");
    29972997
    2998 /* Process command-line parameters */
     2998    /* Process command-line parameters */
    29992999    if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) {
    30003000#ifdef __FreeBSD__
Note: See TracChangeset for help on using the changeset viewer.