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

Bug#724931: Please include the patch in git



Hi,

I don't know why, but I didn't receive your email. I just read it on bugs.debian.org.

Using the patched ISOs I noticed an error in the patch: In 41cdset $filename was incorrectly used instead of $ISOname. Therefore too many ISOs were considered as part of the set. The corrected patch is attached. I also removed the unused $ISOend variable.

Furthermore I noticed that there are more official ISOs than I had in mind, when I wrote the cdset-patch: If the first ISO is called debian-7.2.0-amd64-CD-1.iso, 41cdset looks for other ISOs with names debian-7.2.0-amd64-CD-*[^1].*[.]iso and thus finds e.g. debian-7.2.0-amd64-CD-2.iso. But there exists also the debian-update-7.2.0-amd64-CD-1.iso, which would not be found. And if you started with a debian-7.2.0-kfreebsd-amd64-CD-1.iso, 41cdset would not find debian-7.2.0-amd64-CD-2.iso.
Possible ways to treat this problem:
* One could just adapt the script for these cases, but I think that the detailed structure of the ISO names should not be hardcoded. * Alternatively one could just check every *.iso, but this has the disadvantage, that if you have many other ISOs in the same folder, you would have to click through many messages in the installer, stating that this or that ISO is no Debian ISO. * I think the best way would be to mention in the documentation what ISOs 41cdset looks for. Any ISO could easily be renamed to match the assumptions.

I have also tried to apply the patch to the kfreebsd ISO to check, whether it works there as well, but I have been unable to extract the initrd. It seems not to be packed as gzipped cpio archive.

I haven't heard from Ian since his last mail on 13th October and I have no clue what he has in mind as a more general solution. Perhaps he has been busy otherwise.

In general I think, that it would be good to include the patch now and add any additional improvements later.

Best regards,
Andreas
diff -rupN apt-cdrom-setup.orig/usr/bin/load-install-cd apt-cdrom-setup/usr/bin/load-install-cd
--- apt-cdrom-setup.orig/usr/bin/load-install-cd	2011-03-23 03:00:10.000000000 +0100
+++ apt-cdrom-setup/usr/bin/load-install-cd	2013-10-11 21:36:49.735038936 +0200
@@ -10,6 +10,13 @@ ROOT="$1"
 
 logoutput="log-output -t load-install-cd"
 
+# Why isn't this function, or something like it,
+# in /usr/share/debconf/confmodule ?
+db_getval()
+{
+	db_get "$1" && echo "$RET" || true
+}
+
 check_id() {
 	cd_ids=$(LC_ALL=C $logoutput --pass-stdout chroot $ROOT \
 		 apt-cdrom ident | grep "^Identifying" | cut -d" " -f2)
@@ -29,18 +36,9 @@ while ! check_id; do
 	db_go || exit 10
 done
 
-fs=iso9660
-if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
-	fs="$RET"
-fi
-OS=$(udpkg --print-os)
-case "$OS" in
-	hurd)
-		OPTIONS=ro
-		;;
-	*)
-		OPTIONS=ro,exec
-		;;
-esac
+fs=$(db_getval cdrom-detect/cdrom_fs)
+[ "$fs" ] || fs=iso9660
+OPTIONS=$(db_getval cdrom-detect/cdrom_options)
+[ "$OPTIONS" ] || OPTIONS=ro,exec
 db_get cdrom-detect/cdrom_device
 $logoutput mount -t "$fs" -o $OPTIONS $RET /cdrom
diff -rupN apt-cdrom-setup.orig/usr/lib/apt-setup/generators/40cdrom apt-cdrom-setup/usr/lib/apt-setup/generators/40cdrom
--- apt-cdrom-setup.orig/usr/lib/apt-setup/generators/40cdrom	2013-05-12 12:49:10.000000000 +0200
+++ apt-cdrom-setup/usr/lib/apt-setup/generators/40cdrom	2013-10-11 00:19:52.494473022 +0200
@@ -10,7 +10,9 @@ if ! type chroot_cleanup_localmounts >/d
 	# Variant of chroot_cleanup that only cleans up chroot_setup's mounts.
 	chroot_cleanup_localmounts () {
 		rm -f /target/usr/sbin/policy-rc.d
-		mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
+		if [ -f /target/sbin/start-stop-daemon.REAL ]; then
+			mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
+		fi
 		if [ -x /target/sbin/initctl.REAL ]; then
 			mv /target/sbin/initctl.REAL /target/sbin/initctl
 		fi
@@ -40,32 +42,23 @@ if [ ! -s /cdrom/.disk/info ]; then
 	exit 0
 fi
 
-cd_mountable=1
-db_get cdrom-detect/hybrid || true
-if [ "$RET" = true ] || [ -d /hd-media ]; then
-	cd_mountable=""
-else
-	db_get cdrom-detect/usb-hdd || true
-	if [ "$RET" = true ]; then
-		cd_mountable=""
-	fi
-fi
+# Why isn't this function, or something like it,
+# in /usr/share/debconf/confmodule ?
+db_getval()
+{
+	db_get "$1" && echo "$RET" || true
+}
+
+# See whether the device is mountable
+cd_mountable=true
+cd_mountable=$(db_getval cdrom-detect/cdrom_mountable)
 
 remount_cd() {
-	if [ "$ROOT" ] && [ "$cd_mountable" ]; then
-		fs=iso9660
-		if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
-			fs="$RET"
-		fi
-		OS=$(udpkg --print-os)
-		case "$OS" in
-			hurd)
-				OPTIONS=ro
-				;;
-			*)
-				OPTIONS=ro,exec
-				;;
-		esac
+	if [ "$ROOT" ] && [ $cd_mountable = true ]; then
+		fs=$(db_getval cdrom-detect/cdrom_fs)
+		[ "$fs" ] || fs=iso9660
+		OPTIONS=$(db_getval cdrom-detect/cdrom_options)
+		[ "$OPTIONS" ] || OPTIONS=ro,exec
 		db_get cdrom-detect/cdrom_device
 		$logoutput mount -t "$fs" -o $OPTIONS $RET /cdrom || true
 	fi
@@ -106,7 +99,7 @@ if [ "$ROOT" ]; then
 	chroot=chroot
 
 	# Allow apt-cdrom to manage mounting/unmounting CDs in /target
-	if [ "$cd_mountable" ]; then
+	if [ $cd_mountable = true ]; then
 		rm -f $ROOT/etc/apt/apt.conf.d/00NoMountCDROM
 
 		$logoutput umount /target/media/cdrom* || true
@@ -121,13 +114,17 @@ fi
 
 tmp=$($chroot $ROOT tempfile)
 
+# See whether /cdrom is a loopmounted ISO
+loopdev=$(db_getval cdrom-detect/cdrom_loopdev)
+
 # apt-cdrom can be interactive, avoid that
 if $logoutput $chroot $ROOT apt-cdrom add \
    -o Dir::Etc::SourceList=$tmp \
    </dev/null; then
 	cat $ROOT$tmp >> $file
 
-	if [ "$ROOT" ] && [ "$cd_mountable" ]; then
+	# Save the name of the CD to let the CD-set detection (among others) know, what the original CD was.
+	if [ "$ROOT" ] && ([ $cd_mountable = true ] || [ "$loopdev" ]); then
 		save_label
 	fi
 else
diff -rupN apt-cdrom-setup.orig/usr/lib/apt-setup/generators/41cdset apt-cdrom-setup/usr/lib/apt-setup/generators/41cdset
--- apt-cdrom-setup.orig/usr/lib/apt-setup/generators/41cdset	2011-01-19 05:26:34.000000000 +0100
+++ apt-cdrom-setup/usr/lib/apt-setup/generators/41cdset	2013-11-01 10:20:10.239239966 +0100
@@ -4,17 +4,22 @@ set -e
 . /usr/share/debconf/confmodule
 . /lib/chroot-setup.sh
 
+log() {
+	logger -t apt-setup "$@"
+}
+
 # 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
 	# Variant of chroot_cleanup that only cleans up chroot_setup's mounts.
 	chroot_cleanup_localmounts () {
 		rm -f /target/usr/sbin/policy-rc.d
-		mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
+		if [ -f /target/sbin/start-stop-daemon.REAL ]; then
+			mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
+		fi
 		if [ -x /target/sbin/initctl.REAL ]; then
 			mv /target/sbin/initctl.REAL /target/sbin/initctl
 		fi
-
 		# Undo the mounts done by the packages during installation.
 		# Reverse sorting to umount the deepest mount points first.
 		# Items with count of 1 are new.
@@ -40,10 +45,13 @@ fi
 # KDE/Xfce CDs and multi-arch DVDs have '/single' postfix in cd_type
 # 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
 	exit 0
 fi
 
+log "Starting disk set detection"
+
 get_label() {
 	LC_ALL=C $logoutput --pass-stdout $chroot $ROOT \
 		apt-cdrom ident | grep "^Stored label:" | head -n1 | \
@@ -55,6 +63,17 @@ if [ "$CATCHLOG" ]; then
 	logoutput="log-output -t apt-setup"
 fi
 
+
+# Why isn't this function, or something like it,
+# in /usr/share/debconf/confmodule ?
+db_getval()
+{
+	db_get "$1" && echo "$RET" || true
+}
+
+# See whether /cdrom is a loopmounted ISO
+loopdev=$(db_getval cdrom-detect/cdrom_loopdev)
+
 chroot=
 if [ "$ROOT" ]; then
 	chroot=chroot
@@ -75,6 +94,19 @@ fi
 tmp=$($chroot $ROOT tempfile)
 
 cd_label=$(tail -n1 /var/lib/install-cd.id)
+
+if [ "$loopdev" ]; then
+	run_count=0
+	max_run=0
+	# Load the mount parameters for the CD
+	CDFS=$(db_getval cdrom-detect/cdrom_fs)
+	[ "$CDFS" ] || CDFS=iso9660
+	OPTIONS=$(db_getval cdrom-detect/cdrom_options)
+	[ "$OPTIONS" ] || OPTIONS=ro,exec
+fi
+
+log "First installation disk: $cd_label"
+
 db_subst apt-setup/cdrom/set-first LABEL "$cd_label"
 db_input high apt-setup/cdrom/set-first || true
 if ! db_go; then
@@ -86,7 +118,90 @@ fi
 db_get apt-setup/cdrom/set-first
 
 while [ "$RET" = true ]; do
-	cd_label=$(get_label)
+	cd_label=""
+	if [ "$loopdev" ]; then
+		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))
+			done
+			log "Found $max_run ISO(s): $ISOs"
+		fi
+
+		try_iso=0
+		while [ $try_iso -eq 0 ]; do
+			if [ $run_count -lt $max_run ]; then
+				i=0
+				ISO=""
+				# select current ISO file
+				for isofile in $ISOs; do
+					if [ $i -eq $run_count ]; then
+						ISO=$isofile
+						break
+					fi
+					i=$(($i + 1))
+				done
+				j=1
+				# create mount point for the ISO
+				mount_point=/media/cdrom$j
+				while [ -d $ROOT$mount_point ]; do
+					j=$(($j + 1))
+					mount_point=/media/cdrom$j
+				done
+				mkdir $ROOT$mount_point
+
+				log "Try to loop mount file=$loopdir/$ISO, fstype=$CDFS to $ROOT$mount_point"
+				if mount -t $CDFS -o loop,$OPTIONS $loopdir/$ISO $ROOT$mount_point; then
+					log "CD-ROM mount succeeded: file=$loopdir/$ISO fstype=$CDFS"
+					if [ -e $ROOT$mount_point/.disk/info ]; then
+						CDNAME=$(cat $ROOT$mount_point/.disk/info | tr '"' '_')
+						log "Detected disk '$CDNAME'"
+						# Load the codename (e.g. jessie) from the database
+						db_get cdrom/codename
+						codename=$RET
+						RET=""
+						log "Detected codename: $codename"
+						try_iso=1
+					else
+						log "The disk in $loopdir/$ISO is not a Debian disk!"
+						umount $ROOT$mount_point 2>/dev/null || true
+						rmdir $ROOT$mount_point
+					fi
+				else
+					log "Mount failed: file=$loopdir/$ISO fstype=$CDFS"
+					umount $ROOT$mount_point 2>/dev/null || true
+					rmdir $ROOT$mount_point
+				fi
+			else
+				log "No more ISOs found"
+				break
+			fi
+			run_count=$(($run_count + 1))
+		done
+	fi
+
+	if [ "$loopdev" ] && [ $try_iso -eq 1 ]; then
+		cd_label=$CDNAME
+	else
+		cd_label=$(get_label)
+	fi
+
 	# Hmm. The greps could fail if a label contains regexp control chars...
 	if [ "$cd_label" ] && \
 	   (grep "^deb cdrom:\[$cd_label\]" $file || \
@@ -94,20 +209,36 @@ while [ "$RET" = true ]; do
 		template=apt-setup/cdrom/set-double
 		db_subst $template LABEL "$cd_label"
 	else
-		# apt-cdrom can be interactive, avoid that
-		if $logoutput $chroot $ROOT apt-cdrom add \
-		   -o Dir::Etc::SourceList=$tmp \
-		   </dev/null; then
-			cat $ROOT$tmp >> $file
+		if [ "$loopdev" ] && [ $try_iso -eq 1 ]; then
+			# Add an entry for the mount point of the ISO
+			printf "\ndeb [ trusted=yes ] file:$mount_point $codename main" >> $file
+			log "added log entry: 'deb [ trusted=yes ] file:$mount_point $codename main'"
+
+			# Make apt aware of the file
+			$logoutput $chroot $ROOT apt-cdrom -d $mount_point  add \
+			   -o Dir::Etc::SourceList=$tmp \
+			   </dev/null;
+
+			rm -f $ROOT$tmp $ROOT$tmp~
 
-			# Label is assigned by apt-cdrom add, so get again
-			cd_label=$(get_label)
 			template=apt-setup/cdrom/set-next
 			db_subst $template LABEL "$cd_label"
 		else
-			template=apt-setup/cdrom/set-failed
+			# apt-cdrom can be interactive, avoid that
+			if $logoutput $chroot $ROOT apt-cdrom add \
+			   -o Dir::Etc::SourceList=$tmp \
+			   </dev/null; then
+				cat $ROOT$tmp >> $file
+
+				# Label is assigned by apt-cdrom add, so get again
+				cd_label=$(get_label)
+				template=apt-setup/cdrom/set-next
+				db_subst $template LABEL "$cd_label"
+			else
+				template=apt-setup/cdrom/set-failed
+			fi
+			rm -f $ROOT$tmp $ROOT$tmp~
 		fi
-		rm -f $ROOT$tmp $ROOT$tmp~
 	fi
 
 	db_input critical $template || true
diff -rupN apt-cdrom-setup.orig/usr/lib/finish-install.d/10apt-cdrom-setup apt-cdrom-setup/usr/lib/finish-install.d/10apt-cdrom-setup
--- apt-cdrom-setup.orig/usr/lib/finish-install.d/10apt-cdrom-setup	2011-01-19 05:26:34.000000000 +0100
+++ apt-cdrom-setup/usr/lib/finish-install.d/10apt-cdrom-setup	2013-10-09 15:58:45.408856113 +0200
@@ -1,6 +1,29 @@
 #! /bin/sh
 set -e
 
+. /usr/share/debconf/confmodule
+
+# See whether /cdrom is a loopmounted ISO
+db_get cdrom-detect/cdrom_loopdev || true
+loopdev="$RET"
+
+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
+		j=$(($j + 1))
+	done
+
+	if grep -q "^deb[^:]* file:" /target/etc/apt/sources.list; then
+		logger -t finish-install "Removing additional ISOs from sources.list"
+		sed -i "/^deb[^:]* file:/d" /target/etc/apt/sources.list
+	fi
+	log-output -t finish-install chroot /target apt-get update
+fi
+
 # Disable netinst CD image in sources.list if any other sources are present
 if [ -e /cdrom/.disk/base_installable ] && \
    [ -e /cdrom/.disk/cd_type ] && \

Reply to: