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

bin/live-update-initramfs: dirname / basename fixes



	Please consider the (untested) patch MIME'd.

Fixed two filename handling issues in bin/live-update-initramfs.

bin/live-update-initramfs: Fixed: use absolute filenames while
counting initramfs images (were: relative to CWD); derive their
version numbers properly (were: containing the leading ‘/boot/’
directory.)

-- 
FSF associate member #7257	np. forrest.it
diff --git a/bin/live-update-initramfs b/bin/live-update-initramfs
index 1d6fbf6..731bfea 100755
--- a/bin/live-update-initramfs
+++ b/bin/live-update-initramfs
@@ -56,13 +56,13 @@ case "${_READ_WRITE}" in
 		/usr/sbin/update-initramfs.orig.initramfs-tools "${@}"
 
 		# FIXME: needs to exclude initrd backup files
-		if [ "$(ls initrd.img-* | wc -l)" -gt 1 ]
+		if [ "$(set -- /boot/initrd.img-* ; echo $#)" -gt 1 ]
 		then
 			_NUMBER="1"
 
 			for _INITRD in /boot/initrd.img-*
 			do
-				_VERSION="$(echo ${_INITRD} | sed -e 's|initrd.img-||')"
+				_VERSION=${_INITRD#*/initrd.img-}
 
 				cp /boot/vmlinuz-${_VERSION} /lib/live/image/live/vmlinuz${_NUMBER}.new
 				cp /boot/initrd.img-${_VERSION} /lib/live/image/live/initrd${_NUMBER}.img.new

Reply to: