Changeset 3476


Ignore:
Timestamp:
Oct 14, 2015, 4:56:07 PM (2 years ago)
Author:
bruno
Message:

Mindi now uses syslinux for UEFI as well as for BIOS mode for x86_64

  • Adds a function FindLdlinuxe64Binary to find ldlinux.e64
  • Adds a function FindSyslinux64EFI to find syslinux.efi
  • FindLdlinux32Binary only called in BIOS mode
  • Remove duplication of copy of files under Mondo Temp dir
  • Creates a similar content for UEFI machines as for BIOS based on syslinux.efi and syslinux.cfg
  • Re create ISO image with different params for UEFI in case of failure as options do not work for all genisoimage versions
  • Adds a function MakeISOErrors to manage these errors
  • Centralize the call to MakeBootConfFile?

Note that adaptation needs also to be done for mondoarchive wrt genisoimage params to solve #782

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi/mindi

    r3474 r3476  
    525525    [ ! -e "$MBOOTC32" ] && Die "Please install mboot.c32 first. If your syslinux RPM doesn't include mboot.c32, you may download an isolinux RPM from Mondo's website - go to http://www.mondorescue.org/downloads.shtml"
    526526    LogFile "INFO: Found mboot.c32 at $MBOOTC32"
     527}
     528
     529FindLdlinuxe64Binary() {
     530    LDLINUXE64=/usr/share/syslinux/efi64/ldlinux.e64
     531    [ ! -e "$LDLINUXE64" ] && LDLINUXE64=/usr/lib64/syslinux/efi64/ldlinux.e64
     532    [ ! -e "$LDLINUXE64" ] && LDLINUXE64=/usr/share/lib/syslinux/efi64/ldlinux.e64
     533    [ ! -e "$LDLINUXE64" ] && LDLINUXE64=/usr/share/lib64/syslinux/efi64/ldlinux.e64
     534    [ ! -e "$LDLINUXE64" ] && LDLINUXE64=/usr/lib/syslinux/modules/efi64/ldlinux.e64
     535    [ ! -e "$LDLINUXE64" ] && LDLINUXE64=/usr/lib64/syslinux/modules/efi64/ldlinux.e64
     536    [ ! -e "$LDLINUXE64" ] && LDLINUXE64=`find / -name ldlinux.e64 | grep -x "/.*/ldlinux.e64"`
     537    [ ! -e "$LDLINUXE64" ] && Die "Please install ldlinux.e64 first. If your syslinux RPM doesn't include ldlinux.e64, you may download an isolinux RPM from Mondo's website - go to http://www.mondorescue.org/downloads.shtml"
     538    LogFile "INFO: Found ldlinux.e64 at $LDLINUXE64"
     539}
     540
     541FindSyslinux64EFI() {
     542    SYSLINUX64EFI=/usr/share/syslinux/efi64/syslinux.efi
     543    [ ! -e "$SYSLINUX64EFI" ] && SYSLINUX64EFI=/usr/lib/syslinux/efi64/syslinux.efi
     544    [ ! -e "$SYSLINUX64EFI" ] && SYSLINUX64EFI=/usr/lib64/syslinux/efi64/syslinux.efi
     545    [ ! -e "$SYSLINUX64EFI" ] && SYSLINUX64EFI=/usr/share/syslinux/syslinux.efi
     546    [ ! -e "$SYSLINUX64EFI" ] && SYSLINUX64EFI=/usr/share/lib64/syslinux/efi64/syslinux.efi
     547    [ ! -e "$SYSLINUX64EFI" ] && SYSLINUX64EFI=/usr/lib/SYSLINUX/efi64/syslinux.efi
     548    [ ! -e "$SYSLINUX64EFI" ] && SYSLINUX64EFI=`find / -name syslinux.efi | grep -x "/.*64/syslinux.efi"`
     549    [ ! -e "$SYSLINUX64EFI" ] && Die "Please install syslinux first. If your syslinux RPM doesn't include syslinux, you may download an syslinux RPM from Mondo's website - go to http://www.mondorescue.org/downloads.shtml"
     550    LogFile "INFO: Found syslinux.efi at $SYSLINUX64EFI"
    527551}
    528552
     
    14641488        fi
    14651489    done
     1490
    14661491    MakeMessageFile $MINDI_TMP/iso | cut -c1-80 > $MINDI_TMP/iso/message.txt
     1492
    14671493    if [ $KERNEL_IS_XEN = "yes" ]; then
    14681494        FindMboot32Binary
     
    14701496        cp $MBOOTC32 $MINDI_TMP/iso/mboot.c32  2>> $LOGFILE || Die "Cannot copy mboot.c32 ($MBOOTC32) to mindi tmp ($MINDI_TMP/iso/mboot.c32). Did you run out of disk space?"
    14711497    fi
    1472     # Useful for syslinux 5.x
    1473     FindLdlinux32Binary
    1474     if [ -e $LDLINUXC32 ]; then
    1475         cp $LDLINUXC32 $MINDI_TMP/iso/ldlinux.c32  2>> $LOGFILE || Die "Cannot copy ldlinux.c32 ($LDLINUXC32) to mindi tmp ($MINDI_TMP/iso/ldlinux.c32). Did you run out of disk space?"
    1476     fi
     1498
    14771499    cp $kernelpath $MINDI_TMP/iso/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/iso/vmlinuz). Did you run out of disk space?"
    14781500    cp $MINDI_TMP/initrd.img $MINDI_TMP/iso/initrd.img 2>> $LOGFILE || Die "Cannot copy initrd.img ($MINDI_TMP/initrd.img) to $MINDI_TMP/iso/initrd.img. Did you run out of disk space?"
    1479 
    1480     if [ _"$MONDO_SHARE" != _"" ]; then
    1481         if [ $KERNEL_IS_XEN = "yes" ]; then
    1482             cp $xenkernelpath $MONDO_ROOT/xen.gz 2>> $LOGFILE || Die "Cannot copy xen.gz ($xenkernelpath) to mindi tmp ($MONDO_ROOT/xen.gz). Did you run out of disk space?"
    1483             cp $MBOOTC32 $MONDO_ROOT/mboot.c32  2>> $LOGFILE || Die "Cannot copy mboot.c32 ($MBOOTC32) to mindi tmp ($MONDO_ROOT/mboot.c32). Did you run out of disk space?"
    1484         fi
    1485         if [ -e $LDLINUXC32 ]; then
    1486             cp $LDLINUXC32 $MONDO_ROOT/ldlinux.c32  2>> $LOGFILE || Die "Cannot copy ldlinux.c32 ($LDLINUXC32) to $MONDO_ROOT/ldlinux.c32. Did you run out of disk space?"
    1487         fi
    1488         cp $kernelpath $MONDO_ROOT/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MONDO_ROOT/vmlinuz). Did you run out of disk space?"
    1489         cp $MINDI_TMP/initrd.img $MONDO_ROOT/initrd.img 2>> $LOGFILE || Die "Cannot copy initrd.img ($MINDI_TMP/initrd.img) to $MONDO_ROOT/initrd.img. Did you run out of disk space?"
    1490     fi
    1491     MakeBootConfFile isolinux > $MINDI_TMP/iso/isolinux.cfg
    14921501    if [ "$ARCH" != "ia64" ] ; then
    14931502        cp $ISOLINUX $MINDI_TMP/iso/isolinux.bin 2>> $LOGFILE || Die "Cannot copy isolinux.bin ($ISOLINUX) to $MINDI_TMP/iso - did you run out of disk space?"
     
    14961505    # copy boot stuff now generated in PrepareDataDiskImage
    14971506    if [ "$BOOT_TYPE" = "UEFI" ]; then
     1507        FindLdlinuxe64Binary
     1508        if [ -e $LDLINUXE64 ]; then
     1509            cp $LDLINUXE64 $MINDI_TMP/iso/ 2>> $LOGFILE || Die "Cannot copy $LDLINUXE64 to mindi tmp ($MINDI_TMP/iso/). Did you run out of disk space?"
     1510        fi
    14981511        (cd $MINDI_TMP/iso ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI)
    14991512        tbc="EFI"
    15001513    else
     1514        # Useful for syslinux 5.x
     1515        FindLdlinux32Binary
     1516        if [ -e $LDLINUXC32 ]; then
     1517            cp $LDLINUXC32 $MINDI_TMP/iso/ 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to mindi tmp ($MINDI_TMP/iso/). Did you run out of disk space?"
     1518        fi
    15011519        (cd $MINDI_TMP/iso ; tar xfz $MINDI_CACHE/all.tar.gz ./boot)
    15021520        tbc="boot"
    15031521    fi
    15041522
     1523    if [ _"$MONDO_SHARE" != _"" ]; then
     1524        if [ $KERNEL_IS_XEN = "yes" ]; then
     1525            cp $xenkernelpath $MONDO_ROOT/xen.gz 2>> $LOGFILE || Die "Cannot copy $xenkernelpath to mondo tmp ($MONDO_ROOT/xen.gz). Did you run out of disk space?"
     1526            cp $MBOOTC32 $MONDO_ROOT/ 2>> $LOGFILE || Die "Cannot copy $MBOOTC32 to mondo tmp ($MONDO_ROOT/). Did you run out of disk space?"
     1527        fi
     1528        if [ -e $LDLINUXC32 ]; then
     1529            cp $LDLINUXC32 $MONDO_ROOT/ 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $MONDO_ROOT/. Did you run out of disk space?"
     1530        fi
     1531        if [ -e $LDLINUXE64 ]; then
     1532            cp $LDLINUXE64 $MONDO_ROOT/ 2>> $LOGFILE || Die "Cannot copy $LDLINUXE64 to $MONDO_ROOT/. Did you run out of disk space?"
     1533        fi
     1534        cp $kernelpath $MONDO_ROOT/vmlinuz 2>> $LOGFILE || Die "Cannot copy $kernelpath to mondo root ($MONDO_ROOT/vmlinuz). Did you run out of disk space?"
     1535        cp $MINDI_TMP/initrd.img $MONDO_ROOT/ 2>> $LOGFILE || Die "Cannot copy $MINDI_TMP/initrd.img to $MONDO_ROOT/. Did you run out of disk space?"
     1536    fi
     1537
     1538   
    15051539    old_pwd=`pwd`
    15061540    cd "$MINDI_TMP/iso"
    15071541    if [ "$ARCH" != "ia64" ] ; then
    15081542        if [ _"$MONDO_SHARE" != _"" ]; then
    1509             cp -rf $MINDI_TMP/iso/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt,boot*.txt,pxe.txt,$tbc} $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy core files to ramdisk for boot disk (under $MONDO_ROOT). Did you run out of disk space?"
    1510             if [ -e $MINDI_TMP/iso/ldlinux.c32 ]; then
    1511                 cp $MINDI_TMP/iso/ldlinux.c32 $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy ldlinux.c32 (from $MINDI_TMP/iso/$LDLINUXC32) to $MONDO_ROOT. Did you run out of disk space?"
     1543            cp -rf $MINDI_TMP/iso/{initrd.img,vmlinuz,isolinux.bin,message.txt,boot*.txt,pxe.txt,$tbc} $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy core files to ramdisk for boot disk (under $MONDO_ROOT). Did you run out of disk space?"
     1544            cfgf=`find $MINDI_TMP/iso -name 'isolinux.cfg' | head -1`
     1545            if [ -e $cfgf ]; then
     1546                cp $cfgf $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy $cfgf to $MONDO_ROOT. Did you run out of disk space?"
    15121547            fi
    15131548            if [ $KERNEL_IS_XEN = "yes" ]; then
    1514                 cp -f $MINDI_TMP/iso/{mboot.c32,xen.gz} $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy Xen core files to ramdisk for boot disk (under $MONDO_ROOT). Did you run out of disk space?"
     1549                cp -f $MINDI_TMP/iso/xen.gz $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy Xen kernel to $MONDO_ROOT. Did you run out of disk space?"
    15151550            fi
    15161551            cp -f $MONDO_SHARE/autorun $MINDI_TMP/iso 2>> $LOGFILE
    15171552        fi
    1518         CMD="$ISO_CMD -U $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ."
     1553        CMD="$ISO_CMD -U $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
     1554        if [ "$BOOT_TYPE" = "UEFI" ]; then
     1555            # These options do not work for all genisoimage versions :-(
     1556            CMD="$CMD -eltorito-alt-boot -efi-boot images/mindi-bootroot.img -no-emul-boot"
     1557        fi
    15191558    else
    1520         CMD="$ISO_CMD $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b images/mindi-bootroot.img -c images/boot.cat -no-emul-boot ."
     1559        CMD="$ISO_CMD $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b images/mindi-bootroot.img -c images/boot.cat -no-emul-boot"
    15211560    fi
    15221561    LogFile "Invoking $CMD"
    1523     $CMD > /dev/null 2> $MINDI_TMP/mkisofs.log
     1562    $CMD . > /dev/null 2> $MINDI_TMP/mkisofs.log
    15241563    if [ "$?" -ne "0" ] ; then
    1525         LogFile "----------- $ISO_CMD's errors --------------"
    1526         LogAll "$ISO_CMD returned the following errors:"
    1527         cat $MINDI_TMP/mkisofs.log | tee -a $LOGFILE
    1528         LogAll "ERROR: Failed to create ISO image."
     1564        if [ "$BOOT_TYPE" = "UEFI" ]; then
     1565            CMD=`echo $CMD | perl -p -e 's|-efi-boot |-eltorito-platform 0xEF -eltorito-boot |'`
     1566            $CMD . > /dev/null 2> $MINDI_TMP/mkisofs.log
     1567            if [ "$?" -eq "0" ] ; then
     1568                LogAll "INFO: Created bootable ISO image at $MINDI_CACHE/mindi.iso"
     1569            else
     1570                MakeISOErrors
     1571            fi
     1572        else
     1573            MakeISOErrors
     1574        fi
    15291575    else
    15301576        LogAll "INFO: Created bootable ISO image at $MINDI_CACHE/mindi.iso"
     
    15321578    rm -f $MINDI_TMP/mkisofs.log
    15331579    cd "$old_pwd"
     1580}
     1581
     1582MakeISOErrors() {
     1583
     1584LogFile "----------- $ISO_CMD's errors --------------"
     1585LogAll "$CMD returned the following errors:"
     1586cat $MINDI_TMP/mkisofs.log | tee -a $LOGFILE
     1587LogAll "ERROR: Failed to create ISO image."
    15341588}
    15351589
     
    18681922PrepareBootDiskImage() {
    18691923    # LILO originally
    1870     local dev imagefile fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf bootimage
     1924    local dev imagefile fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootconf bootimage
    18711925    kernelpath=$1
    18721926    retval=0
     
    20992153    fi
    21002154
    2101     # copy (e)lilo/syslinux/grub/whatever stuff into it as well
     2155    # copy (e)lilo/isolinux/grub/whatever stuff into it as well
    21022156    # to get it on the media (in addition to the boot part
    21032157    # and also to support UEFI boot mechanism
    21042158    bootdir=$bigdir/boot
     2159    bootconf="$bootdir/syslinux.cfg"
     2160    boottype=isolinux
    21052161    mkdir -p $bootdir
    21062162    if [ "$BOOT_TYPE" != "BIOS" ]; then
     
    21132169        if [ "$BOOT_TYPE" = "UEFI" ]; then
    21142170            # UEFI
    2115             lilodir=$bigdir/EFI/BOOT
    2116             mkdir -p $lilodir
    2117             liloconf="$lilodir/grub.conf"
    2118             # grub.efi for rhel6 and grubx64.efi for rhel7
    2119             lilobin="grub*.efi"
     2171            efidir=$bigdir/EFI/BOOT
     2172            FindSyslinux64EFI
     2173            bootbin=$SYSLINUX64EFI
     2174            bootconf="$efidir/syslinux.cfg"
    21202175           
    2121             MakeBootConfFile grub > $liloconf
    21222176        else
    21232177            # EFI
    2124             lilodir=$bootdir
    2125             mkdir -p $lilodir
    2126             liloconf="$lilodir/elilo.conf"
    2127             lilobin="elilo.efi"
    2128 
    2129             MakeBootConfFile elilo > $liloconf
     2178            efidir=$bootdir
     2179            bootbin=`find /boot/efi -iname "elilo.efi" | head -1`
     2180            boottype=elilo
     2181            bootconf="$efidir/elilo.conf"
     2182
    21302183        fi
    21312184
     
    21412194            mountefi=1
    21422195        fi
    2143         el=`find /boot/efi -iname "$lilobin"`
    2144         cp $el $lilodir
     2196        mkdir -p $efidir
     2197        cp $bootbin $efidir
    21452198        if [ $mountefi -eq 1 ]; then
    21462199            umount /boot/efi 2>&1 > /dev/null
    21472200        fi
    2148     else
    2149         MakeBootConfFile isolinux > $bootdir/syslinux.cfg
    2150     fi
     2201    fi
     2202    MakeBootConfFile $boottype > $bootconf
    21512203
    21522204    echo -en "Tarring and zipping the data content..."
Note: See TracChangeset for help on using the changeset viewer.