Changeset 2488


Ignore:
Timestamp:
Nov 18, 2009, 9:41:00 PM (10 years ago)
Author:
bruno
Message:

r3621@localhost: bruno | 2009-11-18 10:53:33 +0100

  • PrepareBootDiskImage? replaces previously duplicated functions for lilo/isolinux handling and completely re-written
  • remove useless rootfs files
  • Use MINDI_CACHE instead of /tmp globally
Location:
branches/2.2.10
Files:
6 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mindi/deplist.d/minimal.conf

    r2475 r2488  
    6363/bin/sleep
    6464/bin/uname
     65/etc/services
     66/etc/protocols
     67/etc/shells
     68/etc/termcap
     69/etc/bashrc
    6570
    6671# Compression
  • branches/2.2.10/mindi/mindi

    r2481 r2488  
    347347        LogFile "Debian-style config detected."
    348348        mkdir -p $bigdir/tmp
    349         echo "/etc/console/boottime.kmap.gz" > $bigdir/tmp/KEYMAP-LIVES-HERE
     349        echo "/etc/console/boottime.kmap.gz" > $MINDI_CACHE/KEYMAP-LIVES-HERE
    350350        KBDEPTH=0
    351351        mkdir -p $bigdir/etc/console
     
    356356        LogFile "Ubuntu-style config detected."
    357357        mkdir -p $bigdir/tmp
    358         echo "/etc/console-setup/boottime.kmap.gz" > $bigdir/tmp/KEYMAP-LIVES-HERE
     358        echo "/etc/console-setup/boottime.kmap.gz" > $MINDI_CACHE/KEYMAP-LIVES-HERE
    359359        KBDEPTH=0
    360360        mkdir -p $bigdir/etc/console-setup
     
    410410    fi
    411411    mkdir -p $bigdir/tmp
    412     echo "$mappath" > $bigdir/tmp/KEYMAP-LIVES-HERE
     412    echo "$mappath" > $MINDI_CACHE/KEYMAP-LIVES-HERE
    413413    KBDEPTH=0
    414414    AddKeyboardMappingFile $mappath
     
    922922    AddFileToCfgIfExists $MINDI_TMP/BOOTLOADER.DEVICE bootloader.device $outfile
    923923    AddFileToCfgIfExists $MINDI_TMP/BOOTLOADER.NAME   bootloader.name   $outfile
    924     AddFileToCfgIfExists $MINDI_TMP/KEYMAP-LIVES-HERE keymap-lives-here $outfile
    925924    AddFileToCfgIfExists $MINDI_TMP/TAPEDEV-HAS-DATA-DISKS tapedev-has-data-disks $outfile
    926925}
     
    14121411    fi
    14131412    echo -en "."
     1413    # Some distro do auto mount at that point (Ubuntu)
    14141414    LogFile "Unmounting $USBPART just in case"
    14151415    umount $USBPART 2>> $LOGFILE 1>> $LOGFILE
     
    16281628
    16291629
    1630 PrepareBootDiskImage_LILO() {
    1631     local imagesdir dev imagefile mountpoint fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
     1630
     1631PrepareBootDiskImage() {
     1632    local imagesdir dev imagefile mountpoint fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage liloconf mountefi
    16321633    imagesdir=$MINDI_CACHE
    16331634    kernelpath=$1
    1634 
     1635    do_boot_root_thingy=""
    16351636    retval=0
     1637
    16361638    [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    16371639    echo -en "Making "$BOOT_SIZE"KB boot disk..."
    16381640    TurnTgzIntoRdz $MINDI_DATA/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?"
    16391641    echo -en "..."
    1640     imagefile=$imagesdir/mindi-bootroot.$BOOT_SIZE.img
    1641     mountpoint=$MINDI_TMP/mountpoint.$$
    1642     mkdir -p $mountpoint
    1643     dd if=/dev/zero of=$imagefile bs=1k count=$BOOT_SIZE &> /dev/null || Die "Cannot dd blank file"
    1644     mkdosfs $imagefile >> $LOGFILE 2>> $LOGFILE
    1645     mount -t vfat -o loop $imagefile $mountpoint || LogAll "Cannot mount (PBDI)"
    1646     # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
    1647     mkdir -p $mountpoint/etc
    1648     liloconf=$mountpoint/elilo.conf
    1649 
    1650     MakeBootConfFile elilo > $liloconf
    1651 
    1652     # Copy it so that CD-ROM menu entry is satisfied
    1653     mountefi=0
    1654     df -T | grep /boot/efi | grep -q vfat
    1655     if [ $? -ne 0 ]; then
    1656         mount /boot/efi
    1657         if [ $? -ne 0 ]; then
    1658             echo "You have to mount your EFI partition when using mindi"
    1659             MindiExit -1
    1660         fi
    1661         mountefi=1
    1662     fi
    1663     el=`find /boot/efi -name elilo.efi`
    1664     cp $el $mountpoint
    1665     cp $liloconf $mountpoint
    1666     if [ $mountefi -eq 1 ]; then
    1667         umount /boot/efi 2>&1 > /dev/null
    1668     fi
    1669 
    1670     LogFile "Copying $MINDI_TMP/initrd.img to $mountpoint..."
    1671     cp -f $MINDI_TMP/initrd.img $mountpoint 2>> $LOGFILE
    1672     if [ "$?" -ne "0" ] ; then
    1673         LogAll "Failed to copy $MINDI_TMP/initrd.img to $mountpoint"
    1674         cat $MINDI_TMP/mtpt.$$ >> $LOGFILE
    1675         LogAll "Please unload some of your modules and try again."
    1676         rm -f $MINDI_TMP/mtpt.$$
    1677         LogAll "Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)"
    1678         retval=$(($retval+1))
    1679     fi
    1680     MakeMessageFile > $mountpoint/message.txt
    1681 
    1682     # copy the kernel across
    1683     [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found
    1684     dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
    1685     free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
    1686     cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2>> $LOGFILE
    1687     if [ "$?" -ne "0" ] ; then
    1688         LogFile "Files at mountpoint ($mountpoint) :-"
    1689         du -sk $mountpoint/* >> $LOGFILE
    1690         LogFile "--- end of list of files ---"
    1691         echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
    1692 Sorry, your kernel is too big for your image.\n" >> $LOGFILE
    1693         [ "$mountpoint" != "" ] && rm -f $mountpoint/vmlinuz
    1694         cd $old_pwd
    1695         umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    1696         rmdir $mountpoint || LogAll "Cannot rmdir (PBDI)"
    1697         [ "$imagefile" != "" ] && rm -f $imagefile
    1698         return 0
    1699     fi
    1700     max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
    1701     LogFile "Free space left on image = $free_space KB"
    1702     LogFile "Max kernel size on $BOOT_SIZE KB image (est'd) = $max_kernel_size K"
    1703     # make it bootable
    1704     [ "$mountpoint" != "" ] && rm -f $mountpoint/zero
    1705     [ -e "$MINDI_DATA/memdisk" ] && cp -f $MINDI_DATA/memdisk $mountpoint 2>> $LOGFILE
    1706     if [ "$KERN_DISK_MADE" ] ; then
    1707         LogFile "Not running LILO. It's not that kind of disk."
    1708     fi
    1709 
    1710     cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE
    1711     umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    1712     echo -en "..."
    1713     rmdir $mountpoint || LogAll "Cannot rmdir (PBDI)"
    1714     if [ "$retval" -eq "0" ] ; then
    1715         echo -en "...$DONE\n"
    1716         if [ "$KERN_DISK_MADE" ] ; then
    1717             LogAll "$BOOT_SIZE KB boot disks were created OK\n"
    1718         fi
    1719     else
    1720         echo -en "...failed\n"
    1721         LogAll $BOOT_SIZE"KB boot disk was NOT created\n"
    1722         [ "$imagefile" != "" ] && rm -f $imagefile
    1723     fi
    1724     [ "$retval" -ne "0" ] && LogAll "PrepareBootDiskImage() is returning nonzero"
    1725     return $retval
    1726 }
    1727 
    1728 
    1729 PrepareBootDiskImage_ISOLINUX() {
    1730     local imagesdir dev imagefile mountpoint fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
    1731     imagesdir=$MINDI_CACHE
    1732     kernelpath=$1
    1733     do_boot_root_thingy=""
    1734     local retval old_pwd
    1735     retval=0
    1736 
    1737     [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    1738     echo -en "Making "$BOOT_SIZE"KB boot disk..."
    1739     TurnTgzIntoRdz $MINDI_DATA/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?"
    1740     echo -en "..."
    1741     imagefile=$MINDI_TMP/mindi-bootroot.$BOOT_SIZE.img
     1642    imagefile=$MINDI_CACHE/mindi-bootroot.$BOOT_SIZE.img
    17421643    mountpoint=$MINDI_TMP/mountpoint.$$
    17431644    mkdir -p $mountpoint
    17441645    dd if=/dev/zero of=$imagefile bs=1k count=$BOOT_SIZE &> /dev/null || Die "Cannot dd blank file"
    17451646    LogFile "Creating vfat filesystem on $imagefile"
    1746     mkfs.vfat $imagefile >> $LOGFILE 2>> $LOGFILE
    1747     # syslinux should be run on a  local file (doen't work through NFS Cf: #297)
    1748     syslinux $imagefile >> $LOGFILE 2>> $LOGFILE
    1749 
    1750     # Only move it now to its final destination abd use it now
    1751     mv $imagefile $imagesdir
    1752     imagefile=$imagesdir/mindi-bootroot.$BOOT_SIZE.img
     1647    mkdosfs $imagefile >> $LOGFILE 2>> $LOGFILE
     1648    if [ "$ARCH" != "ia64" ] ; then
     1649        # syslinux should be run on a local file (doen't work through NFS Cf: #297)
     1650        # Ensure that $MINDI_CACHE is not on NFS (it shouldn't)
     1651        syslinux $imagefile >> $LOGFILE 2>> $LOGFILE
     1652    fi
    17531653
    17541654    mount -t vfat -o loop $imagefile $mountpoint || LogAll "Cannot mount (PBDI)"
    17551655
    17561656    # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
     1657    mkdir -p $mountpoint/etc
     1658    liloconf=$mountpoint/elilo.conf
     1659
    17571660    MakeMessageFile > $mountpoint/message.txt
    1758     MakeBootConfFile isolinux > $mountpoint/syslinux.cfg
     1661
     1662    if [ "$ARCH" != "ia64" ] ; then
     1663        MakeBootConfFile isolinux > $mountpoint/syslinux.cfg
     1664    else
     1665        MakeBootConfFile elilo > $liloconf
     1666        # Copy it so that CD-ROM menu entry is satisfied
     1667        mountefi=0
     1668        df -T | grep /boot/efi | grep -q vfat
     1669        if [ $? -ne 0 ]; then
     1670            mount /boot/efi
     1671            if [ $? -ne 0 ]; then
     1672                echo "You have to mount your EFI partition when using mindi"
     1673                MindiExit -1
     1674            fi
     1675            mountefi=1
     1676        fi
     1677        el=`find /boot/efi -name elilo.efi`
     1678        cp $el $mountpoint
     1679        cp $liloconf $mountpoint
     1680        if [ $mountefi -eq 1 ]; then
     1681            umount /boot/efi 2>&1 > /dev/null
     1682        fi
     1683    fi
     1684
    17591685    LogFile "Copying $MINDI_TMP/initrd.img to $mountpoint/initrd.img..."
    17601686    cp -f $MINDI_TMP/initrd.img $mountpoint/initrd.img 2>> $LOGFILE
     
    17841710        rmdir $mountpoint || LogAll "Cannot rmdir (PBDI)"
    17851711
    1786         [ "$imagefile" != "" ] && rm -f $imagefile
     1712        rm -f $imagefile
    17871713        return 0
    17881714    fi
     
    17931719    # make it bootable
    17941720    [ "$mountpoint" != "" ] && rm -f $mountpoint/zero
    1795     mkdir -p $mountpoint/etc
    17961721    [ -e "$MINDI_DATA/memdisk" ] && cp -f $MINDI_DATA/memdisk $mountpoint 2>> $LOGFILE
     1722
     1723    if [ "$ARCH" = "ia64" ] ; then
     1724        cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE
     1725    fi
    17971726    umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    17981727    echo -en "..."
     
    18011730    if [ "$retval" -eq "0" ] ; then
    18021731        echo -en "...$DONE\n"
    1803         if [ "$KERN_DISK_MADE" ] ; then
    1804             [ "$imagefile" != "" ] && rm -f $imagefile
    1805             LogAll "$BOOT_SIZE KB boot disks were created OK\n"
    1806         fi
     1732        LogAll "$BOOT_SIZE KB boot disk was created OK\n"
    18071733    else
    18081734        echo -en "...failed\n"
    1809         LogAll $BOOT_SIZE"KB boot disk was NOT created\n"
    1810         [ "$imagefile" != "" ] && rm -f $imagefile
     1735        LogAll "$BOOT_SIZE KB boot disk was NOT created\n"
     1736        rm -f $imagefile
    18111737    fi
    18121738    [ "$retval" -ne "0" ] && LogAll "PrepareBootDiskImage() is returning nonzero"
     
    19181844    fi
    19191845
    1920     LogFile -en "$FILES_IN_FILELIST" > $bigdir/FILES-IN-FILELIST
    19211846    if [ _"$MONDO_SHARE" != _"" ]; then
    19221847        for q in filelist.full.gz biggielist.txt ; do
     
    22502175    mindi-get-perl-modules `cat $MINDI_CONF/perl-scripts` >> $MINDI_TMP/cp.lis
    22512176
    2252     for w in cdrom groovy-stuff ; do
    2253         echo mnt/$w >> $MINDI_TMP/mkdir.lis
    2254     done
     2177    echo mnt/cdrom >> $MINDI_TMP/mkdir.lis
    22552178
    22562179    ls /dev/fd0*[1,2][4,7,8]* >> $MINDI_TMP/cp.lis 2> /dev/null
     
    23352258
    23362259    # Then copy files needed
    2337     LANGUAGE=C tar cf - `cat $MINDI_TMP/cp.lis` | (cd $mountpoint ; tar xf - ) 2>&1 | grep -Ev "tar: Removing.*/\'" >> $LOGFILE
     2260    LANGUAGE=C tar cf - `cat $MINDI_TMP/cp.lis` 2> /dev/null | (cd $mountpoint ; tar xf - ) 2>&1 | grep -Ev "tar: Removing.*/\'" >> $LOGFILE
    23382261
    23392262    # Then handle links
     
    23532276
    23542277    # Finally integrate what we provide statically as part of mindi
    2355     (cd $tgz_dir_fname ; LANGUAGE=C tar cf - . ) | (cd $mountpoint ; tar xf - )  2>&1 | grep -Ev "tar: Removing.*/\'" >> $LOGFILE
     2278    (cd $tgz_dir_fname ; LANGUAGE=C tar cf - . ) | (cd $mountpoint ; tar xf - ) 2>&1 | grep -Ev "tar: Removing.*/\'" >> $LOGFILE
    23562279
    23572280    # Extracting devices
    2358     bash
    23592281    (cd $mountpoint/dev ; tar -zxf dev-entries.tgz) || Die "Cannot untar dev-entries.tgz"
    23602282    rm -f $mountpoint/dev/dev-entries.tgz
     
    24022324        Die "Filesystem $gvFileSystem not supported for initrd image. Terminating."
    24032325    fi
     2326    ls -al $MINDI_TMP/initrd.img > /tmp/initrd.log
    24042327
    24052328    if [ "$res" -eq "0" ] ; then
     
    27562679LogAll "Latest Mindi is available from http://www.mondorescue.org"
    27572680LogAll "------------------------------------------------------------------------------"
    2758 
    2759 KERN_DISK_MADE=""
    2760 
    27612681LogFile "DIFFERENTIAL = $DIFFERENTIAL"
    27622682LogFile "INTERNAL TAPE BLOCK SIZE = $INTERNAL_TAPE_BLOCK_SIZE"
     
    27922712
    27932713LogFile "Ramdisk will be $ramdisk_size KB"
    2794 if [ "$ARCH" = "ia64" ] ; then
    2795     PrepareBootDiskImage_LILO $kernelpath || Die "Failed to create ia64 image disk image."
    2796 else
    2797     PrepareBootDiskImage_ISOLINUX $kernelpath || Die "Failed to create $ramdisk_size MB disk image."
    2798 fi
     2714PrepareBootDiskImage $kernelpath || Die "Failed to create $ramdisk_size MB disk image."
    27992715
    28002716[ -e "$MINDI_DATA/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\
  • branches/2.2.10/mindi/rootfs/sbin/find-and-mount-cdrom

    r2462 r2488  
    7070    [ "$SECOND_TRY" ] && add="At 2nd attempt, " || add=""
    7171    LogIt $add"CD-ROM found and mounted at $device" 3
    72     echo "$device" > /tmp/CDROM-LIVES-HERE
     72    echo "$device" > $MINDI_CACHE/CDROM-LIVES-HERE
    7373    LogIt "find-and-mount-cdrom --- leaving (0)"
    7474    exit 0
  • branches/2.2.10/mindi/rootfs/sbin/ide-opt

    r1983 r2488  
    88    echo -e -n "Optimizing IDE drive access..."
    99
    10     cdrom_lives_here=`cat /tmp/CDROM-LIVES-HERE`
     10    cdrom_lives_here=`cat $MINDI_CACHE/CDROM-LIVES-HERE`
    1111    if [ "$?" -ne "0" ] ; then
    1212    echo "I don't know where the CDROM lives. Optimization cancelled."
  • branches/2.2.10/mindi/rootfs/sbin/init

    r2487 r2488  
    8484
    8585LaunchTerminals() {
    86     openvt 2 /bin/sh
    87     openvt 3 /bin/sh
    88     openvt 4 /bin/sh
    89     openvt 5 /bin/sh
    90     openvt 6 /bin/sh
    91     openvt 7 /bin/sh /sbin/wait-for-petris
    92     openvt 8 /usr/bin/tail -f $LOGFILE
     86    openvt -l /bin/sh
     87    openvt -l /bin/sh
     88    openvt -l /bin/sh
     89    openvt -l /bin/sh
     90    openvt -l /bin/sh
     91    openvt -l /bin/sh /sbin/wait-for-petris
     92    openvt -l /usr/bin/tail -f $LOGFILE
    9393    # May avoid shell error messages
    94     chmod 666 /dev/tty* /dev/console
     94    # chmod 666 /dev/tty* /dev/console
    9595    # By default first serial line is configured as tty
    9696    # Required to have a correct serial console support (MP on ia64 or VSP with iLO2 e.g.)
  • branches/2.2.10/mindi/rootfs/sbin/install-additional-tools

    r2445 r2488  
    1515# ------------ main -----------
    1616
    17 # if the file '/tmp/CDROM-LIVES-HERE' exists then we should use the CD
     17# if the file '$MINDI_CACHE/CDROM-LIVES-HERE' exists then we should use the CD
    1818
    1919LogIt "Starting install-additional-tools"
     
    4040
    4141    mountpoint=/dev/null
    42     [ -e "/tmp/CDROM-LIVES-HERE" ] && mountpoint=/mnt/cdrom/images
     42    [ -e "$MINDI_CACHE/CDROM-LIVES-HERE" ] && mountpoint=/mnt/cdrom/images
    4343    tarball=$mountpoint/all.tar.gz
    44     if [ -e "/tmp/CDROM-LIVES-HERE" ] ; then
     44    if [ -e "$MINDI_CACHE/CDROM-LIVES-HERE" ] ; then
    4545        [ -e "$tarball" ] || LogIt "Can't find CD's $tarball" 1
    4646    fi
     
    5858    cd $old_pwd
    5959    echo -e -n "\r"
    60     [ ! -e "/tmp/CDROM-LIVES-HERE" ] && umount $mountpoint
     60    [ ! -e "$MINDI_CACHE/CDROM-LIVES-HERE" ] && umount $mountpoint
    6161    sleep 1
    6262fi
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2462 r2488  
    653653
    654654    mr_free(bkpinfo->media_device);
    655     if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    656         bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
     655    if (bkpinfo->disaster_recovery && does_file_exist(MINDI_CACHE"/CDROM-LIVES-HERE")) {
     656        bkpinfo->media_device = last_line_of_file(MINDI_CACHE"/CDROM-LIVES-HERE");
    657657    } else {
    658658        bkpinfo->media_device = find_cdrom_device(FALSE);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2462 r2488  
    604604    } else {
    605605        mr_free(bkpinfo->media_device);
    606         if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    607             bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
     606        if (bkpinfo->disaster_recovery && does_file_exist(MINDI_CACHE"/CDROM-LIVES-HERE")) {
     607            bkpinfo->media_device = last_line_of_file(MINDI_CACHE"/CDROM-LIVES-HERE");
    608608        } else {
    609609            bkpinfo->media_device = find_cdrom_device(TRUE);
Note: See TracChangeset for help on using the changeset viewer.