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

Bug#724931: Please include the patch in git



Hi,

On 08.03.2014 02:13, Cyril Brulebois wrote:
Given the apt-cdrom regression we're hitting (#740673), I don't feel
like shipping this amount of additional modifications in jessie alpha 1
images; on the other hand, not uploading what's in apt-setup's master
currently would mean not using updated l10n material, which isn't too
nice. I'm tempted to branch "iso-loopback" from current master, so that
it's easily found afterwards, and to revert the ISO loopback bits for
now.

I generally agree that it would be good to have an alpha 1 installer to use for testing regressions of this patch, but on the other hand using loopmount to install Debian *works*. So you might want to reconsider applying this patch now, as it seems to be currently the only way to install Debian jessie directly. ;)
Yesterday I made a new installation using the patched:
Debian GNU/Linux testing "Jessie" - Official Snapshot amd64 CD Binary-1 20140203-06:21

I'm only half-joking, it really works, otherwise I would have reported a bug.

I fixed a few things in my previous patch (see attachments):
 * Fix typo in finish-install.d/10apt-cdrom-setup: cdrom/$j -> cdrom$j
 * Always test for other CDs, except if it is a netinst CD.
Otherwise one can't use CD-2 together with debian-testing-amd64-kde-CD-1.iso of type full_cd/single. (Maybe I didn't get how this is supposed to work?) * Mount further ISOs if at least four parts (seperated by -) of the name are the same. Example:
    a) debian-testing-amd64-CD-1.iso
    b) debian-testing-amd64-kde-CD-1.iso
    c) debian-testing-amd64-CD-2.iso
    d) debian-testing-amd64-CD-2-local-changes.iso
    e) debian-testing-i386-CD-2.iso
  a) and b) would load c) or d), but not e).
 * Fix crash, if the filesystem is not know (e.g. unpartitioned).

Pease add the attached patches on top of current git, even if you don't want to apply the patch now and instead move it to another branch.

Best regards,
Andreas
diff -ruN apt-setup.orig/finish-install.d/10apt-cdrom-setup apt-setup/finish-install.d/10apt-cdrom-setup
--- apt-setup.orig/finish-install.d/10apt-cdrom-setup	2014-02-13 12:42:00.738178000 +0100
+++ apt-setup/finish-install.d/10apt-cdrom-setup	2014-02-13 15:49:18.868155368 +0100
@@ -10,10 +10,10 @@
 if [ "$loopdev" ]; then
 	# Remove additional CD-Set mount points
 	j=1
-	while [ -d /target/media/cdrom/$j ]; do
-		logger -t finish-install "unmount /target/media/cdrom/$j"
-		umount /target/media/cdrom/$j 2>/dev/null || true
-		rmdir /target/media/cdrom/$j
+	while [ -d /target/media/cdrom$j ]; do
+		logger -t finish-install "unmount /target/media/cdrom$j"
+		umount /target/media/cdrom$j 2>/dev/null || true
+		rmdir /target/media/cdrom$j
 		j=$(($j + 1))
 	done
 
diff -ruN apt-setup.orig/generators/41cdset apt-setup/generators/41cdset
--- apt-setup.orig/generators/41cdset	2014-02-13 12:42:00.738178000 +0100
+++ apt-setup/generators/41cdset	2014-02-13 15:28:30.555167746 +0100
@@ -8,6 +8,20 @@
 	logger -t apt-setup "$@"
 }
 
+split_string() {
+	# Save the old internal field separator.
+	OIFS=$IFS
+	# Change the internal field separator.
+	IFS=$2
+	arr=$1
+	# Convert the separator to newline.
+	for x in $arr; do
+		echo "$x"
+	done
+	# Restore the old internal field separator.
+	IFS=$OIFS
+}
+
 # This code is copied from chroot-setup.sh, and is needed until after a d-i
 # release whose initrds contain a sufficiently new version of di-utils.
 if ! type chroot_cleanup_localmounts >/dev/null 2>&1; then
@@ -46,7 +60,7 @@
 # bluray CDs have cd_type 'bluray'
 cd_type=$(cat /cdrom/.disk/cd_type)
 log "The disk type is: $cd_type"
-if [ "$cd_type" != full_cd ] && [ "$cd_type" != dvd ]; then
+if [ "$cd_type" == "not_complete" ]; then
 	exit 0
 fi
 
@@ -123,23 +137,32 @@
 		if [ $run_count -eq 0 ]; then
 			log "Trying to find usable ISOs in the folder, where the boot ISO is..."
 			loopdir=$(db_getval cdrom-detect/cdrom_device)
-			ISOname=$(basename $loopdir)
-			loopdir=$(dirname $loopdir)
-			if [ "$cd_type" = "dvd" ]; then
-				# DVD
-				ISOstart=${ISOname%DVD-*}
-				ISOs=$(ls ${loopdir}/ | grep ${ISOstart}DVD-[^1].*[.]iso$)
-			elif [ "$cd_type" = "blueray" ]; then
-				# BD
-				ISOstart=${ISOname%BD-*}
-				ISOs=$(ls ${loopdir}/ | grep ${ISOstart}BD-[^1].*[.]iso$)
-			else
-				# probably CD
-				ISOstart=${ISOname%CD-*}
-				ISOs=$(ls ${loopdir}/ | grep ${ISOstart}CD-[^1].*[.]iso$)
-			fi
-			for iso in $ISOs; do
-				max_run=$(($max_run + 1))
+			ISOname=${loopdir##*/}
+			loopdir=${loopdir%/*}
+
+			ISOarray=$(split_string "$ISOname" "-")
+			allISOs=$(ls ${loopdir}/ | grep .iso)
+			ISO=""
+			for iso in $allISOs; do
+				arr=$(split_string "$iso" "-")
+				count=0
+				# Count common specifiers.
+				for elem in $arr; do
+					if [ "$elem" == "1.iso" ]; then
+						# Only look for supplementary ISOs, not ISOs like '*-CD-1.iso'.
+						count=-1
+						break
+					fi
+					for orig_elem in $ISOarray; do
+						if [ "$elem" == "$orig_elem" ]; then
+							count=$(($count + 1))
+						fi
+					done
+				done
+				if ([ $count -ge 4 ] && [ "$iso" != "$ISOname" ]); then
+					ISOs="$ISOs $iso"
+					max_run=$(($max_run + 1))
+				fi
 			done
 			log "Found $max_run ISO(s): $ISOs"
 		fi
diff -ruN cdrom-detect.orig/debian/cdrom-detect.postinst cdrom-detect/debian/cdrom-detect.postinst
--- cdrom-detect.orig/debian/cdrom-detect.postinst	2014-02-13 16:08:09.609078000 +0100
+++ cdrom-detect/debian/cdrom-detect.postinst	2014-02-13 16:46:44.927090946 +0100
@@ -166,18 +166,31 @@
 			log "Trying loopmount ($fs) on '$devices' ..."
 			for loopdev in $devices; do
 				# Determine the filesystem of the device
-				LOOPFS=$(get_fstype "$loopdev")
-				# Mount the device and try to mount the ISO specified by 'loopmount='
-				log "Try to mount device=$loopdev fstype=$LOOPFS"
-				if mount -o $OPTIONS -t $LOOPFS $loopdev /loop; then
-					log "Try to loop mount file=$loopfile fstype=$CDFS"
-					if [ -f $loopfile ] && try_mount $loopfile $CDFS $OPTIONS $loopdev; then
-						mounted=1
-						cd_mountable=false
-						break 2
+				if get_fstype "$loopdev"; then
+					LOOPFS=$(get_fstype "$loopdev")
+					# Mount the device and try to mount the ISO specified by 'loopmount='
+					log "Try to mount device=$loopdev fstype=$LOOPFS"
+					if mount -o $OPTIONS -t $LOOPFS $loopdev /loop; then
+						if [ -f $loopfile ]; then
+							log "Try to loop mount file=$loopfile fstype=$CDFS"
+							if [ -f $loopfile ] && try_mount $loopfile $CDFS $OPTIONS $loopdev; then
+								mounted=1
+								cd_mountable=false
+								break 2
+							else
+								log "The mount failed."
+								umount /loop
+							fi
+						else
+							log "File not found: $loopfile"
+							umount /loop
+						fi
 					else
-						umount /loop
+						log "The mount failed."
+						umount /loop || true
 					fi
+				else
+					log "The filesystem of device=$loopdev could not be determined."
 				fi
 			done
 		done
diff -ruN mountmedia.orig/mountmedia mountmedia/mountmedia
--- mountmedia.orig/mountmedia	2014-02-13 16:03:32.336846000 +0100
+++ mountmedia/mountmedia	2014-02-13 16:05:17.888934735 +0100
@@ -9,6 +9,10 @@
 
 MNT=/media
 
+log() {
+	logger -t mountmedia "$@"
+}
+
 devlist() {
 	if [ "$WANTFLOPPY" ]; then
 		list-devices floppy
@@ -36,11 +40,16 @@
 	# TO REMOVE, there is a bug somewhere in the kernel, the first
 	# mount command fail when changing floppy disk
 	# so we have to launch mount twice
-	fs_type=$(get_fstype $1)
-	mount -t $fs_type $1 $MNT || true
-	umount $MNT || true
-	mount -t $fs_type $1 $MNT
-	media_mounted && checkcontents $MNT
+	if get_fstype $1; then
+		fs_type=$(get_fstype $1)
+		mount -t $fs_type $1 $MNT || true
+		umount $MNT || true
+		mount -t $fs_type $1 $MNT
+		media_mounted && checkcontents $MNT
+	else
+		log "The filesystem of device=$1 could not be determined."
+		return 1
+	fi
 }
 
 checkcontents() {

Reply to: