[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#731709: binary_syslinux-efi based on latest work on live-build master branch for grub-efi support



So this is the patch from Raphael Hertzog that you all know but adapted to be used from my last work.

Unfortunately it does not seem to boot in my virtual machine test.

Raphael can you take a look at it just in case it's a minor problem?

I'm also interested in being able to make cdroms with syslinux-efi.

The quick and dirty branch where I worked on both grub-efi and syslinux-efi is here:

https://github.com/adrian15/live-build/tree/efi_support_based_on_debian_cd

That branch is handy to understand the changes between Raphael's original patch and what I present here.

adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
commit 1397b6fc3dbf7d7f1e6a077a37b9f2e6ee7d7f39
Author: Adrian Gibanel Lopez <adrian.gibanel@btactic.com>
Date:   Mon Jan 18 03:37:01 2016 +0000

    Initial implementation of: binary_syslinux-efi
    based on latest work on live-build master branch
    for grub-efi support.
    
    In order to test this new script you need to specify at
    
    lb config:
    
    --bootloaders=syslinux,syslinux-efi
    
    .
    
    This work is based on this original patch:
    
    https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=103;bug=731709;att=1;filename=Add-support-for-EFI-boot-with-syslinux-efi.patch
    
    This is currently not working in my EFI test virtual machine.
    Let's hope the original author of the patch can take a look
    and, maybe fix a minor bug.

diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index 7e3c956..830965d 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -39,7 +39,7 @@
 .br
 	[\fB\-\-bootappend\-live\fR \fIPARAMETER\fR|\fI"PARAMETERS"\fR]
 .br
-	[\fB\-\-bootloader\fR grub|grub2|syslinux|grub-efi]
+	[\fB\-\-bootloader\fR grub|grub2|syslinux|grub-efi|syslinux-efi]
 .br
 	[\fB\-\-cache\fR true|false]
 .br
@@ -263,7 +263,7 @@ defines the filesystem to be used in the image type. This only has an effect if
 sets boot parameters specific to debian\-installer, if included.
 .IP "\fB\-\-bootappend\-live\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
 sets boot parameters specific to debian\-live. A complete list of boot parameters can be found in the \fIlive\-boot\fR(7) and \fIlive\-config\fR(7) manual pages.
-.IP "\fB\-\-bootloader\fR grub|grub2|syslinux|grub-efi" 4
+.IP "\fB\-\-bootloader\fR grub|grub2|syslinux|syslinux-efi" 4
 defines which bootloader is being used in the generated image. This has only an effect if the selected binary image type does allow to choose the bootloader. For example, if you build a iso, always syslinux (or more precise, isolinux) is being used. Also note that some combinations of binary images types and bootloaders may be possible but live\-build does not support them yet. \fBlb config\fR will fail to create such a not yet supported configuration and give a explanation about it. For hdd images on amd64 and i386, the default is syslinux.
 .IP "\fB\-\-cache\fR true|false" 4
 defines globally if any cache should be used at all. Different caches can be controlled through the their own options.
diff --git a/scripts/build/binary b/scripts/build/binary
index 7b0d743..7e30f27 100755
--- a/scripts/build/binary
+++ b/scripts/build/binary
@@ -70,6 +70,7 @@ lb binary_win32-loader ${@}
 lb binary_includes ${@}
 lb binary_hooks ${@}
 lb binary_grub-efi ${@}
+lb binary_syslinux-efi ${@}
 lb binary_checksums ${@}
 
 if [ "${LB_BUILD_WITH_CHROOT}" != "true" ]
diff --git a/scripts/build/binary_iso b/scripts/build/binary_iso
index 5d612b5..41331a1 100755
--- a/scripts/build/binary_iso
+++ b/scripts/build/binary_iso
@@ -157,6 +157,23 @@ then
 	fi
 fi
 
+if Is_Secondary_Bootloader "syslinux-efi"
+then
+	if [ -e binary/boot/efi.img ]
+	then
+		Echo "Using older EFI command line for xorriso $XORRISO_VER"
+		# Tell xorriso to create a secondary ElTorito boot record for the
+		# EFI bootloader
+		XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot --efi-boot boot/efi.img"
+		# Add the efi image as a FAT partition too, so our CD image will
+		# also boot on a USB key (like isohybrid, just implemented
+		# differently)
+		XORRISO_OPTIONS="${XORRISO_OPTIONS} -append_partition 2 0x01 binary/boot/efi.img"
+	else
+		Echo "No EFI boot code to include in the ISO"
+	fi
+fi
+
 #if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
 #then
 #	XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
diff --git a/scripts/build/binary_syslinux-efi b/scripts/build/binary_syslinux-efi
new file mode 100644
index 0000000..d70e0fd
--- /dev/null
+++ b/scripts/build/binary_syslinux-efi
@@ -0,0 +1,284 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2014 Raphaël Hertzog <buxy@kali.org>
+##
+## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'prepares and installs Syslinux based EFI support into binary')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+if Is_Secondary_Bootloader "syslinux-efi"
+then
+	:
+else
+	exit 0
+fi
+
+Echo_message "Begin preparing Syslinux based EFI support..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/binary_syslinux-efi
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Check architecture
+Check_architectures amd64 i386
+Check_crossarchitectures
+
+case "${LB_ARCHITECTURES}" in
+	amd64)
+		_EFI_TYPE=efi64
+		;;
+	i386)
+		_EFI_TYPE=efi32
+		;;
+	*)
+		echo "ERROR: can't provide EFI boot support to architecture ${LB_ARCHITECTURES}" >&2
+		exit 1
+		;;
+esac
+
+# Assembling image specifics
+case "${LIVE_IMAGE_TYPE}" in
+	iso*)
+		_BOOTLOADER="isolinux"
+
+		case "${LB_MODE}" in
+			progress-linux)
+				_CONFDIR="binary/boot"
+				;;
+
+			*)
+				_CONFDIR="binary/isolinux"
+				;;
+		esac
+		;;
+
+	netboot)
+		_BOOTLOADER="pxelinux"
+		_CONFDIR="tftpboot"
+		;;
+
+	hdd*|*)
+		case ${LB_BINARY_FILESYSTEM} in
+			fat*|ntfs)
+				_BOOTLOADER=syslinux
+
+				case "${LB_MODE}" in
+					progress-linux)
+						_CONFDIR="binary/boot"
+						;;
+
+					*)
+						_CONFDIR="binary/syslinux"
+						;;
+				esac
+				;;
+
+			ext[234]|btrfs)
+				_BOOTLOADER=extlinux
+				_CONFDIR="binary/boot/extlinux"
+				;;
+
+			*)
+				Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
+				exit 1
+				;;
+		esac
+		;;
+esac
+
+# Checking depends
+case "${LB_BUILD_WITH_CHROOT}" in
+	true)
+		_CHROOT_DIR=""
+		_SYSLINUX_EFI_DIR="chroot/usr/lib/SYSLINUX.EFI/$_EFI_TYPE"
+		_SYSLINUX_COMMON_DIR="chroot/usr/lib/syslinux/modules/$_EFI_TYPE"
+
+		Check_package chroot /usr/bin/syslinux syslinux
+		Check_package chroot /usr/lib/syslinux syslinux-common
+		Check_package chroot /usr/lib/SYSLINUX.EFI syslinux-efi
+		Check_package chroot /usr/bin/mcopy mtools
+		Check_package chroot /sbin/mkfs.msdos dosfstools
+		;;
+
+	false)
+		_CHROOT_DIR="chroot"
+		_SYSLINUX_EFI_DIR="/usr/lib/syslinux/$_EFI_TYPE"
+		_SYSLINUX_COMMON_DIR="/usr/lib/syslinux/modules/$_EFI_TYPE"
+
+		if [ ! -e /usr/bin/syslinux ]
+		then
+			# syslinux
+			Echo_error "/usr/bin/syslinux - no such file."
+			exit 1
+		fi
+
+		if [ ! -e /usr/lib/syslinux ]
+		then
+			# syslinux-common
+			Echo_error "/usr/lib/syslinux - no such directory"
+			exit 1
+		fi
+
+		if [ ! -e /usr/lib/SYSLINUX.EFI ]
+		then
+			# syslinux-efi
+			Echo_error "/usr/lib/SYSLINUX.EFI - no such directory"
+			exit 1
+		fi
+
+		if [ ! -e /usr/bin/mcopy ]
+		then
+			# mtools
+			Echo_error "/usr/bin/mcopy - no such file."
+			exit 1
+		fi
+
+		if [ ! -e /sbin/mkfs.msdos ]
+		then
+			# dosfstools
+			Echo_error "/sbin/mkfs.msdos - no such file."
+			exit 1
+		fi
+		;;
+esac
+
+# Restoring cache
+Restore_cache cache/packages.binary
+
+# Installing depends
+Install_package
+
+# Abort if we don't have the required EFI files
+if [ ! -e $_SYSLINUX_EFI_DIR/syslinux.efi ]; then
+	Echo_warning "$_SYSLINUX_EFI_DIR/syslinux.efi missing, no EFI support included."
+	case "${LB_BUILD_WITH_CHROOT}" in
+		true)
+			# Saving cache
+			Save_cache cache/packages.binary
+
+			# Removing depends
+			Remove_package
+			;;
+	esac
+	exit 0
+fi
+
+# Cleanup files that we generate
+rm -rf chroot/efi-temp chroot/efi.img binary/boot/efi.img
+
+# Copy syslinux and its config files in the temporary EFI image
+mkdir -p chroot/efi-temp/live
+mkdir -p chroot/efi-temp/EFI/BOOT
+for _F in $_CONFDIR/*.cfg $_CONFDIR/*.png $_SYSLINUX_COMMON_DIR/*.*32 $_SYSLINUX_COMMON_DIR/*.*64; do
+	if [ -e $_F ]; then
+		cp $_F chroot/efi-temp/EFI/BOOT/
+	else
+		Echo_warning "No file matching $_F, EFI support might be broken."
+	fi
+done
+cp $_SYSLINUX_EFI_DIR/syslinux.efi chroot/efi-temp/EFI/BOOT/BOOTX64.efi
+cp $_SYSLINUX_EFI_DIR/syslinux.efi chroot/efi-temp/EFI/BOOT/syslinux.efi
+
+# Copy the various kernel images
+cp binary/live/vmlinuz* binary/live/initrd* chroot/efi-temp/live/
+if [ -d binary/install ]; then
+	cp -r binary/install chroot/efi-temp/
+fi
+
+# Edit the menu to differentiate the EFI version
+if [ -e chroot/efi-temp/EFI/BOOT/menu.cfg ]; then
+	sed -i -e "s/^menu title/menu title EFI/" chroot/efi-temp/EFI/BOOT/menu.cfg
+else
+        Echo_warning "No menu.cfg file that can be edited to indicate that we boot on EFI!"
+fi
+
+# Ensure we have a syslinux.cfg
+if [ ! -e chroot/efi-temp/EFI/BOOT/syslinux.cfg ]; then
+	for _F in isolinux.cfg pxelinux.cfg/default extlinux.conf; do
+		if [ -f chroot/efi-temp/EFI/BOOT/$_F ]; then
+			cp chroot/efi-temp/EFI/BOOT/$_F chroot/efi-temp/EFI/BOOT/syslinux.cfg
+			break
+		fi
+	done
+fi
+
+# Define the EFI filesystem size
+_TOTALSIZE=$(du -sk chroot/efi-temp/ | awk '{print $1}')
+# Add 5% safety margin
+_TOTALSIZE=$(( $_TOTALSIZE * 21 / 20 ))
+# Required size rounded to upper 32kb
+_BLOCKS=$(( ($_TOTALSIZE + 31) / 32 * 32 ))
+Echo "EFI boot image needs $_TOTALSIZE Kb, thus allocating $_BLOCKS blocks."
+
+# Script to generate the EFI boot image
+cat >binary.sh <<END
+#!/bin/sh
+
+set -e
+
+mkfs.msdos -C $_CHROOT_DIR/efi.img $_BLOCKS
+mcopy -s -v -i $_CHROOT_DIR/efi.img $_CHROOT_DIR/efi-temp/* ::
+END
+
+# Copying files
+case "${LB_BUILD_WITH_CHROOT}" in
+	true)
+		mv binary.sh chroot/
+		Chroot chroot "sh binary.sh"
+		rm -f chroot/binary.sh
+
+		# Saving cache
+		Save_cache cache/packages.binary
+
+		# Removing depends
+		Remove_package
+		;;
+
+	false)
+		sh binary.sh
+		rm -f binary.sh
+		;;
+esac
+
+mkdir -p binary/boot
+mv chroot/efi.img binary/boot/
+rm -rf chroot/efi-temp
+
+case "${LB_BUILD_WITH_CHROOT}" in
+        true)
+                # Saving cache
+                Save_cache cache/packages.binary
+
+                # Removing depends
+                Remove_package
+                ;;
+esac
+
+# Creating stage file
+Create_stagefile .build/binary_syslinux-efi

Reply to: