From a40fb341ea42559224113f583303313e4463f7b6 Mon Sep 17 00:00:00 2001
From: Jesse Hathaway <jesse@mbuki-mvuki.org>
Date: Sat, 13 Oct 2007 16:47:39 -0400
Subject: readd support for booting etch via syslinux

---
 helpers/lh_binary_syslinux | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/helpers/lh_binary_syslinux b/helpers/lh_binary_syslinux
index ff79f08..8732c1c 100755
--- a/helpers/lh_binary_syslinux
+++ b/helpers/lh_binary_syslinux
@@ -239,7 +239,7 @@ Copy_syslinux_templates ()
 
 Configure_syslinux_templates ()
 {
-   templates=$(find ${SYSLINUX_PATH} -type f -name '*.cfg' -o -name '*.txt' -o -name 'default')
+   templates=$(find ${SYSLINUX_PATH} -type f -name '*.cfg' -o -name '*.txt')
    for template_file in ${templates}; do
 		sed -i -e "s@{\$LINUX_LIVE}@${LINUX_LIVE}@" \
              -e "s@{\$LINUX_INSTALL}@${LINUX_INSTALL}@" \
@@ -256,6 +256,28 @@ Configure_syslinux_templates ()
 		       -e 's/\ $//g' \
              $template_file
    done
+
+   # Syslinux v3.31 in etch does not support include statement
+	if [ "${LH_DISTRIBUTION}" = "etch" ]
+	then
+		while grep -q ^include ${SYSLINUX_PATH}/syslinux.cfg
+	   do
+			INCLUDES=$(grep ^include ${SYSLINUX_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
+            # remove the files, which were included
+            if [ -e ${SYSLINUX_PATH}/${FILE_NAME} ]
+            then
+               rm ${SYSLINUX_PATH}/${FILE_NAME}
+            fi
+			done
+      done
+   fi
 }
 
 # Setting up common variables
@@ -437,6 +459,9 @@ fi
 # Copy templates to base syslinux directory
 Copy_syslinux_templates
 
+# Fill in templates with created values
+Configure_syslinux_templates
+
 # Configure syslinux setup per boot method
 case "${LH_BINARY_IMAGES}" in
 	iso)
@@ -497,9 +522,6 @@ case "${LH_BINARY_IMAGES}" in
 		;;
 esac
 
-# Fill in templates with created values
-Configure_syslinux_templates
-
 # Saving cache
 Save_cache cache/packages_binary
 
-- 
cgit v1.0