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

Bug#882769: Cannot upgrade from Stretch: cp: target '/lib/live/mount/medium/live/vmlinuz.new' is not a directory



On Mon, 04 Dec 2017, Thomas Goirand wrote:
> Could you please review the patch and let me know if you think it's ok,
> apply to the git, and allow me to upload?

I think it's wrong because it handles vmlinuz/initrd separately. I pushed
what I think is a proper fix into git. Can you test the git version and
confirm that it works for you?

(I attach the patch applied on top of the last NMU)

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Support Debian LTS: https://www.freexian.com/services/debian-lts.html
Learn to master Debian: https://debian-handbook.info/get/
diff --git a/bin/live-update-initramfs b/bin/live-update-initramfs
index 3cdbed3..38d5f27 100755
--- a/bin/live-update-initramfs
+++ b/bin/live-update-initramfs
@@ -55,30 +55,36 @@ case "${_READ_WRITE}" in
 		# Updating initramfs
 		/usr/sbin/update-initramfs.orig.initramfs-tools "${@}"
 
-		# FIXME: needs to exclude initrd backup files
-		if [ "$(ls /boot/initrd.img-* | wc -l)" -gt 1 ]
+		if [ "$(ls /boot/vmlinuz-* | wc -l)" -gt 1 ]
 		then
 			_NUMBER="1"
 
-			for _INITRD in /boot/initrd.img-*
+			for _VMLINUZ in /boot/vmlinuz-*
 			do
-				_VERSION="$(basename ${_INITRD} | sed -e 's|initrd.img-||')"
+				_VERSION="$(basename ${_VMLINUZ} | sed -e 's|vmlinuz-||')"
 
 				cp /boot/vmlinuz-${_VERSION} /lib/live/mount/medium/live/vmlinuz${_NUMBER}.new
-				cp /boot/initrd.img-${_VERSION} /lib/live/mount/medium/live/initrd${_NUMBER}.img.new
-
-				mv /lib/live/mount/medium/live/vmlinuz${_NUMBER}.new /lib/live/mount/medium/live/vmlinuz${_NUMBER}
-				mv /lib/live/mount/medium/live/initrd${_NUMBER}.img.new /lib/live/mount/medium/live/initrd${_NUMBER}.img
+				if [ -e /boot/initrd.img-${_VERSION} ]; then
+					cp /boot/initrd.img-${_VERSION} /lib/live/mount/medium/live/initrd${_NUMBER}.img.new
+				fi
 
 				_NUMBER="$((${_NUMBER} + 1))"
 			done
 		else
-			cp /boot/vmlinuz-* /lib/live/mount/medium/live/vmlinuz.new
-			cp /boot/initrd.img-* /lib/live/mount/medium/live/initrd.img.new
+			_VMLINUZ=$(echo /boot/vmlinuz-*)
+			_VERSION="$(basename ${_VMLINUZ} | sed -e 's|vmlinuz-||')"
+			cp $_VMLINUZ /lib/live/mount/medium/live/vmlinuz.new
+			if [ -e /boot/initrd.img-${_VERSION} ]; then
+				cp /boot/initrd.img-${_VERSION} /lib/live/mount/medium/live/initrd.img.new
+			fi
 
-			mv /lib/live/mount/medium/live/vmlinuz.new /lib/live/mount/medium/live/vmlinuz
-			mv /lib/live/mount/medium/live/initrd.img.new /lib/live/mount/medium/live/initrd.img
 		fi
+		for f in /lib/live/mount/medium/live/vmlinuz*.new \
+		         /lib/live/mount/medium/live/initrd*.new; do
+			if [ -e $f ]; then
+				mv $f ${f%.new}
+			fi
+		done
 		;;
 
 	false)
diff --git a/debian/changelog b/debian/changelog
index 69a1b46..39dbf1d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+live-tools (1:20171205) UNRELEASED; urgency=medium
+
+  * Improve update-initramfs wrapper to better handle unmatched
+    kernels and initrd images. Closes: #882769
+
+ -- Raphaël Hertzog <hertzog@debian.org>  Tue, 05 Dec 2017 09:31:05 +0100
+
 live-tools (1:20151214+nmu1) unstable; urgency=medium
 
   * Non-maintainer upload.

Reply to: