From e7d99b5116495b5727c9271963d1901760867c58 Mon Sep 17 00:00:00 2001
From: Jesse Hathaway <jesse@mbuki-mvuki.org>
Date: Mon, 15 Oct 2007 18:04:48 -0400
Subject: lh_binary_syslinux: fix usb-hdd etch images

I did not realize that the syslinux boot methods,
iso, net, & hdd do not have feature parity for any
given version. As per old comments etch syslinux
v3.31 does not support sub directories on FAT images
---
 helpers/lh_binary_linux-image | 27 +++-----------------
 helpers/lh_binary_memtest     | 36 ++++-----------------------
 helpers/lh_binary_syslinux    | 58 ++++++++++++++++++++++++++++++-------------
 3 files changed, 50 insertions(+), 71 deletions(-)

diff --git a/helpers/lh_binary_linux-image b/helpers/lh_binary_linux-image
index 33c2fbb..6795ec4 100755
--- a/helpers/lh_binary_linux-image
+++ b/helpers/lh_binary_linux-image
@@ -47,32 +47,13 @@ Check_lockfile .lock
 # Creating lock file
 Create_lockfile .lock
 
-# Setting destination directory
-case "${LH_BINARY_IMAGES}" in
-	iso)
-		case "${LH_INITRAMFS}" in
-			casper)
-				DESTDIR="binary/casper"
-				;;
-
-			live-initramfs)
-				DESTDIR="binary/live"
-				;;
-		esac
-		;;
-
-	net)
-		DESTDIR="tftpboot"
+case "${LH_INITRAMFS}" in
+	casper)
+		DESTDIR="binary/casper"
 		;;
 
-	tar|usb-hdd)
+	live-initramfs)
 		DESTDIR="binary/live"
-
-		# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
-		if [ "${LH_DISTRIBUTION}" = "etch" ] && [ "${LH_BOOTLOADER}" = "syslinux" ]
-		then
-			DESTDIR="binary"
-		fi
 		;;
 esac
 
diff --git a/helpers/lh_binary_memtest b/helpers/lh_binary_memtest
index 946729b..557b945 100755
--- a/helpers/lh_binary_memtest
+++ b/helpers/lh_binary_memtest
@@ -88,39 +88,13 @@ Restore_cache cache/packages_binary
 Install_package
 
 # Setting destination directory
-case "${LH_BINARY_IMAGES}" in
-	iso)
-		case "${LH_INITRAMFS}" in
-			casper)
-				DESTDIR="binary/casper"
-				;;
-
-			live-initramfs)
-				DESTDIR="binary/live"
-				;;
-		esac
+case "${LH_INITRAMFS}" in
+	casper)
+		DESTDIR="binary/casper"
 		;;
 
-	net)
-		DESTDIR="tftpboot"
-		;;
-
-	tar|usb-hdd)
-		case "${LH_INITRAMFS}" in
-			casper)
-				DESTDIR="binary/casper"
-				;;
-
-			live-initramfs)
-				DESTDIR="binary/live"
-				;;
-		esac
-
-		# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
-		if [ "${LH_DISTRIBUTION}" = "etch" ] && [ "${LH_BOOTLOADER}" = "syslinux" ]
-		then
-			DESTDIR="binary"
-		fi
+	live-initramfs)
+		DESTDIR="binary/live"
 		;;
 esac
 
diff --git a/helpers/lh_binary_syslinux b/helpers/lh_binary_syslinux
index 8732c1c..e52c5d3 100755
--- a/helpers/lh_binary_syslinux
+++ b/helpers/lh_binary_syslinux
@@ -166,9 +166,11 @@ Copy_syslinux_templates ()
 
 		if [ "${LH_SYSLINUX_MENU}" = "disabled" ]
 		then
-			cp -r "${TEMPLATES}"/normal/* ${SCREEN_PATH}
+			cp "${TEMPLATES}"/normal/*.cfg ${SCREEN_PATH}
+			cp "${TEMPLATES}"/normal/data/* ${DATA_PATH}
 		else
-			cp -r "${TEMPLATES}"/menu/* ${SCREEN_PATH}
+			cp "${TEMPLATES}"/menu/*.cfg ${SCREEN_PATH}
+			cp "${TEMPLATES}"/menu/data/* ${DATA_PATH}
          # Grab menu binary from chroot
          MENUMODULE=$(grep 'menu.c32' ${TEMPLATES}/menu/header.cfg | sed 's,default\s*.*/\(.*menu.c32\)$,\1,g')
 			cp chroot/usr/lib/syslinux/"${MENUMODULE}" ${DATA_PATH}
@@ -257,27 +259,36 @@ Configure_syslinux_templates ()
              $template_file
    done
 
-   # Syslinux v3.31 in etch does not support include statement
+	# Syslinux v3.31 in etch does not support include statements
 	if [ "${LH_DISTRIBUTION}" = "etch" ]
 	then
-		while grep -q ^include ${SYSLINUX_PATH}/syslinux.cfg
+		while grep -q ^include ${SCREEN_PATH}/syslinux.cfg
 	   do
-			INCLUDES=$(grep ^include ${SYSLINUX_PATH}/syslinux.cfg |awk '{print $2}')
+			INCLUDES=$(grep ^include ${SCREEN_PATH}/syslinux.cfg |awk '{print $2}')
 			for FILE_PATH in ${INCLUDES}
 			do
 			   FILE_NAME=$(basename ${FILE_PATH})
 			   sed -i -e '\@include '${FILE_PATH}'@ {
-	         r '${SYSLINUX_PATH}/${FILE_NAME}'
-	         d  
-	         }' ${SYSLINUX_PATH}/syslinux.cfg
+				r '${SCREEN_PATH}/${FILE_NAME}'
+				d  
+				}' ${SCREEN_PATH}/syslinux.cfg
             # remove the files, which were included
-            if [ -e ${SYSLINUX_PATH}/${FILE_NAME} ]
+				if [ -e ${SCREEN_PATH}/${FILE_NAME} ]
             then
-               rm ${SYSLINUX_PATH}/${FILE_NAME}
+					rm ${SCREEN_PATH}/${FILE_NAME}
             fi
 			done
       done
-   fi
+		# Syslinux v3.31 in etch does not support sub directories, /path/kernel,
+		# when using FAT hard drive images, remove leading /'s
+		if [ "${LH_BINARY_IMAGES}" = "usb-hdd" ]
+		then
+			for FILE in ${SCREEN_PATH}/syslinux.cfg ${SCREEN_PATH}/boot.txt
+			do
+				sed -i -e 's@/@@' ${FILE}
+			done
+		fi
+	fi
 }
 
 # Setting up common variables
@@ -326,7 +337,20 @@ case "${LH_BINARY_IMAGES}" in
       LIVE_INSTALL_KERNEL_PATH="/install"
       LIVE_SCREEN_PATH="/syslinux"
       LIVE_DATA_PATH="${LIVE_SCREEN_PATH}/data"
-      MEDIA="hd-media"
+		# Syslinux v3.31 in etch does not support sub directories, /path/kernel,
+		# when using FAT hard drive images
+		if [ "${LH_DISTRIBUTION}" = "etch" ] && [ "${LH_BINARY_IMAGES}" = "usb-hdd" ]
+		then
+			SYSLINUX_PATH="binary"
+			KERNEL_PATH="binary"
+			SCREEN_PATH="binary"
+			DATA_PATH="binary"
+			LIVE_KERNEL_PATH=""
+			LIVE_INSTALL_KERNEL_PATH=""
+			LIVE_SCREEN_PATH=""
+			LIVE_DATA_PATH=""
+		fi
+		MEDIA="hd-media"
 		;;
 esac
 
@@ -408,12 +432,12 @@ LH_BOOTAPPEND_LIVE="$(echo ${LH_BOOTAPPEND_LIVE} | sed -e 's/  //')"
 # Parameters are listed at: linux/Documentation/kernel-parameters.txt
 FAILSAFE="noapic noapm nodma nomce nolapic nosmp vga=normal"
 
-# Assembling kernel configuration
-if [ ${LH_BINARY_IMAGES} = "net" ]
+# Moving kernels into place
+if [ "binary/${LH_INITRAMFS}" != "${KERNEL_PATH}" ]
 then
-   mv ${SYSLINUX_PATH}/vmlinuz* ${KERNEL_PATH}
-   mv ${SYSLINUX_PATH}/initrd* ${KERNEL_PATH}
-   mv ${SYSLINUX_PATH}/memtest ${KERNEL_PATH}
+	mv binary/${LH_INITRAMFS}/vmlinuz* ${KERNEL_PATH}
+	mv binary/${LH_INITRAMFS}/initrd* ${KERNEL_PATH}
+	mv binary/${LH_INITRAMFS}/memtest ${KERNEL_PATH}
 fi
 
 # Default entries
-- 
cgit v1.0