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

Bug#564441: iso-scan: proposed patch to select an ISO among multiple ones



Package: iso-scan
Version: 1.28
Severity: wishlist
Tags: patch


	Hello,

  I asked back in october 2009 if it was possible to select the ISO
image we want to use when there are multiple ISO files available on the
installer media (see
http://lists.debian.org/debian-boot/2009/10/msg00064.html).

  After a while, I tried to build a patch to iso-scan package to do it
(see attached file). I'm not familiar with debconf nor installer, so
I'm not sure I've done the right way.

  I see 2 solutions for my problem :
- either I parse all ISO files from all disks/partitions, and ask for
choice if any : I thought it could be quite long to parse all
partitions, and this way all installer' users have to wait for this.
- either after each ISO file found, we ask if it's the right one. I
followed this last track, and put the question with a 'medium'
debconf level, so in 'normal' installations, the question shouldn't
either appear and block the user (it would also be annoying to add a
step to all people for a need of few ones).

I've patched the iso-scan source and tried to test the result, without
success, because I didn't know how to rebuild a whole installer image.

Here is what I've done, if you see some advices to let me achieve the
tests, tell me ; if someone could also test the patch, it would be
nice !

- on a USB drive with already a debian installer system and 2 debian
iso (Lenny and testing), I've put my modified iso-scan.postinst and
iso-scan.templates files. I've then started on it with qemu :

$ qemu -hda /dev/sdb -vnc :0

and added 'install debconf/priority=medium' to the kernel cmd line.

$ after selecting language, country and locale, I selected the menu
entry to get a shell, and inside, I mound the usb disk partition and
copy from it iso-scan.postinst in /var/lib/dpkg/info/ (replacing
original one) and I load iso-scan.templates :

$ mkdir /media/usbdisk
$ mount /dev/hda2 /media/usbdisk -t ext2
$ cp /media/usbdisk/iso-scan.postinst /var/lib/dpkg/info/
$ debconf-loadtemplate iso-scan /media/usbdisk/iso-scan.templates
$ exit

And then I go back to the menu and select item to search for an
installation ISO

but the item fails, and looking in /var/log/syslog, I get that
iso-scan's new debconf template is not found :-(
(debconf returns : RET='10 iso-scan/ask_right_iso does'nt exist')

I also tried to restart debconf process by killing it, with more
success.


  Thanks for your attention,
	Fred.


-- System Information:
Debian Release: 5.0.3
  APT prefers stable
  APT policy: (990, 'stable'), (800, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32 (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -Naur iso-scan-1.28ref/debian/changelog iso-scan-1.28+testiso1/debian/changelog
--- iso-scan-1.28ref/debian/changelog	2009-06-11 22:01:33.000000000 +0200
+++ iso-scan-1.28+testiso1/debian/changelog	2010-01-07 10:05:05.000000000 +0100
@@ -1,3 +1,10 @@
+iso-scan (1.28+testiso1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Test to ask if found ISO is the right one.
+
+ -- Frédéric Boiteux <fboiteux@free.fr>  Thu, 07 Jan 2010 10:03:55 +0100
+
 iso-scan (1.28) unstable; urgency=low
 
   [ Colin Watson ]
diff -Naur iso-scan-1.28ref/debian/iso-scan.postinst iso-scan-1.28+testiso1/debian/iso-scan.postinst
--- iso-scan-1.28ref/debian/iso-scan.postinst	2009-01-10 01:25:38.000000000 +0100
+++ iso-scan-1.28+testiso1/debian/iso-scan.postinst	2010-01-07 11:16:07.000000000 +0100
@@ -17,12 +17,12 @@
 	db_progress INFO iso-scan/progress_mount
 	mount -t auto -o ro $dev_to_mount /hd-media 2>/dev/null
 }
-		
+
 is_debian_iso () {
 	test -e /cdrom/.disk/info
 }
 
-register_cd () {
+analyze_cd () {
 	# Make sure that the iso is usable for the architecture. If so,
 	# set the suite and codename to the suite/codename that is on the CD.
 	# This assumes that there will be no more than one distribution on
@@ -38,12 +38,8 @@
 			suite=$(sed -n 's/^Suite: *//p' $relfile)
 			codename=$(sed -n 's/^Codename: *//p' $relfile)
 			log "Detected ISO with '$suite' ($codename) distribution"
-			db_set cdrom/suite $suite
-			db_set cdrom/codename $codename
-			db_subst iso-scan/success SUITE $suite
 
 			description=`sed -n 's/^Description: *//p' $relfile`
-			db_subst iso-scan/success DESCRIPTION $description
 
 			return 0
 		fi
@@ -52,6 +48,46 @@
 	return 1
 }
 
+register_cd () {
+	# Make sure that the iso is usable for the architecture. If so,
+	# set the suite and codename to the suite/codename that is on the CD.
+	# This assumes that there will be no more than one distribution on
+	# the CD, and that one of the testing, stable, or unstable links will
+	# point to it. Since the CDs currently have many links, parse the
+	# Release file to get the actual suite name to use.
+	# Prefer the suite in default-release.
+  if analyze_cd; then
+    # Ask user if the found ISO is the expected one ; if not, the scan will
+    # continue, to find another ISO image elsewhere.
+
+    #
+    # Ask about if the found ISO is the correct target ?
+		log "Ask if ISO $iso_to_try is the good one"
+	  db_subst iso-scan/ask_right_iso FILENAME    $iso_to_try
+	  db_subst iso-scan/ask_right_iso SUITE       $suite
+	  db_subst iso-scan/ask_right_iso CODENAME    $codename
+	  db_subst iso-scan/ask_right_iso DESCRIPTION $description
+	  db_input medium iso-scan/ask_right_iso || true
+	  db_go || true
+
+	  db_get iso-scan/ask_right_iso
+	  if [ "$RET" != true ]; then
+		  log "Not the right ISO (RET='$RET')"
+      return 1
+    fi
+
+		db_set cdrom/suite $suite
+		db_set cdrom/codename $codename
+		db_subst iso-scan/success SUITE $suite
+
+		db_subst iso-scan/success DESCRIPTION $description
+
+		return 0
+	fi
+
+	return 1
+}
+
 # Try to mount a file as an iso, and see if it's a Debian cd.
 try_iso () {
 	iso_to_try=$1
diff -Naur iso-scan-1.28ref/debian/iso-scan.templates iso-scan-1.28+testiso1/debian/iso-scan.templates
--- iso-scan-1.28ref/debian/iso-scan.templates	2009-02-25 08:32:12.000000000 +0100
+++ iso-scan-1.28+testiso1/debian/iso-scan.templates	2010-01-07 09:57:52.000000000 +0100
@@ -35,6 +35,17 @@
 # :sl3:
 _Description: Scanning ${DRIVE} (in ${DIRECTORY})...
 
+Template: iso-scan/ask_right_iso
+Type: boolean
+Default: true
+# :sl3:
+_Description: Is ISO file ${FILENAME} the right image for installation?
+ The ISO file ${FILENAME} on ${DEVICE} (${SUITE}, code ${CODENAME},
+ self-described as '${DESCRIPTION}') will be used as the
+ installation ISO image.
+ If you have multiple ISO files on the same installer drive,
+ you may select here which one you want to use now.
+
 Template: iso-scan/ask_second_pass
 Type: boolean
 Default: false

Reply to: