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

[PATCH] Fix numbering of live kernels + initrd files when using syslinux



Hello,

 Please accept this patch that fixes the numbering of live kernels + initrd files when using syslinux.

 1. The first syslinux entry created is for the default linux flavour (ie. the first flavour listed in LB_LINUX_FLAVOURS). This entry uses the label 'live' whereas the other flavours use a label of 'live ${FLAVOUR}'. We do not number the kernel and initrd files for the 'live' entry.
 2. For the other kernel flavors, we use the position of the flavour in LB_LINUX_FLAVOURS for numbering. The previous method was completely bogus and would never work.
 3. This patch also make some very small cosmetic changes to that section of the code.

 Once landed, lb_binary_disk will no longer choke on Ubuntu mode and AFAIK this is the last issue preventing a completely successful build of Ubuntu.

Cheers,

--
Cody A.W. Somerville
Release Engineer
Foundations Team
Custom Engineering Solutions Group
Canonical OEM Services
Phone: +1 781 850 2087
Cell: +1 613 401 5141
Fax: +1 613 687 7368
Email: cody.somerville@canonical.com
=== modified file 'scripts/build/lb_binary_syslinux'
--- scripts/build/lb_binary_syslinux	2010-09-26 13:03:18 +0000
+++ scripts/build/lb_binary_syslinux	2010-12-15 21:17:45 +0000
@@ -95,31 +95,32 @@
 
 	case "${LB_BINARY_IMAGES}" in
 		iso*|usb*)
-			NUMBER="$(ls -1 ${KERNEL_PATH} | grep 'vmlinuz-' | wc -l)"
-
-			# Do not add numbering to filenames if first kernel/initrd
-			if [ "${NUMBER}" = "2" ]
+			if [ "${LABEL}" = "live" ]
 			then
-				NUMBER=""
+				# Do not number the default kernel / initrd files.
+				_NUMBER=""
+			else
+				# Use order of flavours in LB_LINUX_FLAVOURS for numbering.
+				_NUMBER="$(echo ${LB_LINUX_FLAVOURS} | awk -v FLAVOUR="${FLAVOUR}" 'BEGIN{RS=" "} {if($1 == FLAVOUR) print NR}')"
 			fi
 
-			# Note: ISOLINUX will not find the kernel if the name ends in ".img".
 			if [ -e ${KERNEL_PATH}/${KERNEL} ]
 			then
-				mv ${KERNEL_PATH}/${KERNEL} ${KERNEL_PATH}/vmlinuz${NUMBER}
+				# Note: ISOLINUX will not find the kernel if the name ends in ".img".
+				mv ${KERNEL_PATH}/${KERNEL} ${KERNEL_PATH}/vmlinuz${_NUMBER}
 			fi
 
 			if [ -e ${KERNEL_PATH}/${INITRD} ]
 			then
-				mv ${KERNEL_PATH}/${INITRD} ${KERNEL_PATH}/initrd${NUMBER}.img
+				mv ${KERNEL_PATH}/${INITRD} ${KERNEL_PATH}/initrd${_NUMBER}.img
 			fi
 
-			KERNEL=vmlinuz${NUMBER}
-			INITRD=initrd${NUMBER}.img
+			KERNEL=vmlinuz${_NUMBER}
+			INITRD=initrd${_NUMBER}.img
 		;;
 	esac
 
-	# Regular kernel
+	## Regular kernel boot
 	LINUX_LIVE="${LINUX_LIVE}\nlabel ${LABEL}\n"
 
 	# Write the menu label if the syslinux menu is being use
@@ -131,7 +132,7 @@
 	LINUX_LIVE="${LINUX_LIVE}\tkernel ${LIVE_KERNEL_PATH}/${KERNEL}\n"
 	LINUX_LIVE="${LINUX_LIVE}\tappend initrd=${LIVE_KERNEL_PATH}/${INITRD} boot=${INITFS} config ${LB_BOOTAPPEND_LIVE} ${APPEND} ${QAPPEND}\n"
 
-	# Failsafe kernel
+	## Failsafe kernel boot
 	LINUX_LIVE="${LINUX_LIVE}\nlabel ${LABEL}failsafe\n"
 
 	# Write the menu label if the syslinux menu is being use


Reply to: