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

Bug#573173: support multiple kernel versions with same flavour



Package: live-build
Version: 1:20151215
Followup-For: Bug #573173

Hello,

sending patch against version of live-build currently in debian:
20151215

The patch was rejected in the past mainly due to pending rewrite of
live-build in python which is no longer planned AFAIK.

This patch makes the menu more verbose showing the kernel version and
also makes it possible to build image with multiple kernels of the same
flavour.

Kernels are sorted lowest first (from stable to experimental).

-- Package-specific info:

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (910, 'testing'), (900, 'stable'), (610, 'oldstable'), (410, 'unstable'), (400, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf

Kernel: Linux 4.6.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: systemd (via /run/systemd/system)

Versions of packages live-build depends on:
ii  debootstrap  1.0.81

Versions of packages live-build recommends:
ii  apt-utils                       1.3~pre2
ii  cpio                            2.11+dfsg-5
ii  live-boot-doc                   1:20160511
ii  live-config-doc                 5.20160608
pn  live-manual-html | live-manual  <none>
ii  wget                            1.18-2

Versions of packages live-build suggests:
ii  debian-keyring  2016.07.02
ii  gpgv            1.4.20-6

-- no debconf information
Build menu for multiple kernels of the same flavour.

This allows to include stable and sid kernel in single image to support wider
range of hardware.

Kernel version is included in menu label. This allows differentiating multiple
kernels of same flavour and gives useful information for single kernel images
as well.


Index: live-build-20151215mk1/scripts/build/binary_syslinux
===================================================================
--- live-build-20151215mk1.orig/scripts/build/binary_syslinux	2016-08-16 11:20:07.691549799 +0200
+++ live-build-20151215mk1/scripts/build/binary_syslinux	2016-08-16 11:20:07.687549755 +0200
@@ -197,50 +197,43 @@
 if [ -e "${_TARGET}/live.cfg.in" ]
 then
 	# This is all rather suboptimal.. needs prettifying at some point
-	_FLAVOURS="$(echo ${LB_LINUX_FLAVOURS} | wc -w)"
+	_FLAVOURS="$(echo ${LB_LINUX_FLAVOURS} | tr " " "\n" | sed -e '/^$/d')"
+	if echo ${_FLAVOURS} | grep -q +$
+	then
+		_FLAVOURS_GIT=""
+	else
+		_FLAVOURS_GIT="$(echo ${LB_LINUX_FLAVOURS} | tr " " "\n" | sed -e '/^$/d' -e 's/$/+/')"
+	fi
+
+	_NUMBER="0"
+
+	for _FLAVOUR in ${_FLAVOURS} ${_FLAVOURS_GIT}
+	do
+		for _KERNEL in $(ls binary/live/vmlinuz-*-${_FLAVOUR})
+		do
+			_NUMBER="$((${_NUMBER} + 1))"
+			_KVER=$(basename "${_KERNEL}" -"${_FLAVOUR}" | sed -e 's/vmlinuz-//')
+			_INITRD="$(echo "${_KERNEL}" | sed -e 's|/vmlinuz-|/initrd.img-|')"
+			mv "${_KERNEL}" binary/${_INITRAMFS}/vmlinuz${_NUMBER}
+			mv "${_INITRD}" binary/${_INITRAMFS}/initrd${_NUMBER}.img
+
+			if [ "${_NUMBER}" -gt 1 ]
+			then
+				grep -v 'menu default' "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
+			else
+				cat "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
+			fi
+
+			sed -i -e "s|@FLAVOUR@|${_FLAVOUR} ${_KVER}|g" \
+			    -e "s|@LINUX@|${_INITRAMFS}/vmlinuz${_NUMBER}|g" \
+			    -e "s|@INITRD@|${_INITRAMFS}/initrd${_NUMBER}.img|g" \
+			    -e "s|@APPEND_LIVE@|${LB_BOOTAPPEND_LIVE}|g" \
+			    -e "s|@APPEND_FAILSAFE@|${LB_BOOTAPPEND_FAILSAFE}.img|g" \
+			    "${_TARGET}/live.cfg"
+		done
+	done
 
-	case "${_FLAVOURS}" in
-		1)
-			# If multiple initrd images are being generated (by DKMS packages, etc),
-			# we likely only want the latest version.
-			mv $(ls -r1 --sort=version binary/${_INITRAMFS}/vmlinuz-* | head -n 1) binary/${_INITRAMFS}/vmlinuz
-			mv $(ls -r1 --sort=version binary/${_INITRAMFS}/initrd.img-* | head -n 1) binary/${_INITRAMFS}/initrd.img
-
-			sed -e "s|@FLAVOUR@|${LB_LINUX_FLAVOURS}|g" \
-			    -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz|g" \
-			    -e "s|@INITRD@|/${_INITRAMFS}/initrd.img|g" \
-			"${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
-
-			rm -f "${_TARGET}/live.cfg.in"
-			;;
-
-		*)
-			_NUMBER="0"
-
-			for _FLAVOUR in ${LB_LINUX_FLAVOURS}
-			do
-				_NUMBER="$((${_NUMBER} + 1))"
-
-				mv binary/${_INITRAMFS}/vmlinuz-*-${_FLAVOUR} binary/${_INITRAMFS}/vmlinuz${_NUMBER}
-				mv binary/${_INITRAMFS}/initrd.img-*-${_FLAVOUR} binary/${_INITRAMFS}/initrd${_NUMBER}.img
-
-				if [ "${_NUMBER}" -gt 1 ]
-				then
-					echo "" >> "${_TARGET}/live.cfg"
-					grep -v 'menu default' "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
-				else
-					cat "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
-				fi
-
-				sed -i -e "s|@FLAVOUR@|${_FLAVOUR}|g" \
-				       -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz${_NUMBER}|g" \
-				       -e "s|@INITRD@|/${_INITRAMFS}/initrd${_NUMBER}.img|g" \
-				"${_TARGET}/live.cfg"
-			done
-
-			rm -f "${_TARGET}/live.cfg.in"
-			;;
-	esac
+	rm -f "${_TARGET}/live.cfg.in"
 fi
 
 if [ -e chroot/etc/os-release ]

Reply to: