----- Forwarded message from Osamu Aoki <osamu@debian.org> -----
From: Osamu Aoki <osamu@debian.org>
Date: Sat, 28 Aug 2004 18:28:44 +0200
To: Joey Hess <joeyh@debian.org>
Subject: Re: Bug#265612: cdrom-detect: patch as requested
User-Agent: Mutt/1.5.6+20040803i
Hi,
Sorry for slow response. I wanted to check few more things. So far it
looks good to me.
On Fri, Aug 27, 2004 at 12:09:39PM -0400, Joey Hess wrote:
> Can you send me a unified diff with your latest patch? There have been
> so many patches and code fragments posted that it's a lot of work to
> sort through them all and try to pick one when I cannot reproduce the
> bug.
Just for cdrom-detect, I got source package and made diff -u and
attached here. It is rather big since total reshuffle of looping.
Originally posted here:
http://lists.debian.org/debian-boot/2004/08/msg01653.html
The postinst script it self is attached in this mail.
* This has been tested by me and vincent for 2.4 kernel and works on
both normal and funny systems using ISO image. (Previously posted)
* I also replaced code in initrd for 2.6 and works fine here on a
normal and funny systems. (Below)
The basic concept behind my code shuffle was explained at:
http://lists.debian.org/debian-boot/2004/08/msg01661.html
Here is key part of code test result with 2.6 kernel. (With locally
modified RC1 image)
Aug 28 15:09:29 syslogd started: BusyBox v1.00-pre10 (Debian 20040623-1)
Aug 28 15:09:29 kernel: klogd started: BusyBox v1.00-pre10 (Debian 20040623-1)
Aug 28 15:09:29 kernel: Linux version 2.6.7-1-386 (dilinger@toaster.hq.voxel.net) (gcc version 3.3.4 (Debian 1:3.3.4-2)) #1 Thu Jul 8 05:08:04 EDT 2004
...
Aug 28 13:58:31 hw-detect: Detected hotplug support, installing hotplug.
Aug 28 13:58:31 hw-detect: Missing modules 'agpgart (Intel Corporation 82845 845 (Brookdale) Chipset AGP Bridge), i810-tco (Intel Corporation 82801CAM ISA Bridge (LPC)), e100 (Intel Corporation 82801CAM (ICH3) PRO/100 VE (LOM) Ethernet Controller), ide-mod (Linux IDE driver), ide-probe-mod (Linux IDE probe driver), ide-detect (Linux IDE detection), ide-floppy (Linux IDE floppy), eth1394 (FireWire
ethernet)
Aug 28 13:58:45 cdrom-detect: Searching for Debian installation media...
Aug 28 13:58:45 cdrom-detect: Loop 1 out of 2
Aug 28 13:58:45 cdrom-detect: Try to detect a cdrom automatically by devfs.
Aug 28 13:58:48 cdrom-detect: Cdrom-mount succeeded: device=/dev/cdroms/cdrom0
Aug 28 13:58:48 cdrom-detect: Searching for Debian installation media...
Aug 28 13:58:48 cdrom-detect: Sanity check of CD before aproving mounted CD
Aug 28 13:58:48 cdrom-detect: Detected CD 'Debian GNU/Linux testing "Sarge" - Official NetInst Snapshot i386 Binary-1 (20040806)'
Aug 28 13:58:48 cdrom-detect: Detected CD with 'testing' distribution
Aug 28 13:58:48 cdrom-detect: Exit main loop after approving mounted CD.
Aug 28 13:58:54 main-menu[501]: DEBUG: resolver (libc6): package doesn't exist (ignored)
...
Since I run out of CD-R and my buggy Dell can not boot from CD-RW (it
has to be CD-R), I booted with previously posted image with expert26 and
replaced /var/lib/dpkg/info/cdrom-detect.postinst with one from USB
memory key device. It booted no problem. (It takes very long time to
fail first mount efforts. Screen is blue but it works after a while
since this new script also do a remount action.)
So now I can say I tested 4 combinations and this script works:
Good CDROM PC ---\-/-- Kernel 2.4
X
Funny CDROM PC ---/-\-- Kernel 2.6
But I have to admit this is only i386 and I am not an expert shell coder
as you have already noticed. So very careful code review will be most
appreciated.
Regards,
Osamu
PS: If you preffer to see least change to cdrom-detect.postinst itself,
alternative approach (small patch) to fix bug is posted at:
http://lists.debian.org/debian-boot/2004/08/msg01712.html
(Never tested but much simpler if you hate my big change here.)
diff -Nru cdrom-detect-1.00-org/debian/cdrom-detect.postinst cdrom-detect-1.00/debian/cdrom-detect.postinst
--- cdrom-detect-1.00-org/debian/cdrom-detect.postinst 2004-06-30 19:48:46.000000000 +0200
+++ cdrom-detect-1.00/debian/cdrom-detect.postinst 2004-08-20 08:19:22.000000000 +0200
@@ -9,90 +9,124 @@
}
fail () {
- log "CDROM-detect failed."
+ log "$@"
db_input critical cdrom-detect/failure || [ $? -eq 30 ]
db_go
+ # redundant but to be sure
+ umount /cdrom 2>/dev/null || true
exit 1
}
-# Is a cdrom already mounted? If so, assume it's the right one..
-mount | grep -q ^/dev/cdroms/ && exit 0
-if [ -e /cdrom/.disk/info ] ; then
- CDNAME=`cat /cdrom/.disk/info`
- log "Detected CD '$CDNAME'"
- exit 0
-fi
-
hw-detect cdrom-detect/detect_progress_title || true
-log "Searching for Debian installation media..."
-
-mkdir /cdrom 2>/dev/null || true
-
+maxmount=2 # max counts of the mounting tries
+imount=0 # mount counter
+mounted=0 # 0=initial, 1=detection in progress, 2=mounted
while true
do
- mounted=0
-
- if [ -d /dev/cdroms ]; then
- devices="`echo /dev/cdroms/*`"
- else
- devices=""
- fi
- for device in $devices
- do
- if mount -t iso9660 -o ro,exec $device /cdrom; then
- log "CDROM-mount succeeded: device=$device"
- mounted=1
- db_set cdrom-detect/cdrom_device $device
- break
- else
- log "CDROM-mount failed (error=$?): device=$device"
- log "Unmounting CD just to be sure."
- umount /cdrom 2>/dev/null || true
- log "Trying it again."
- if mount -t iso9660 -o ro,exec $device /cdrom
- then
- log "CDROM-mount succeeded: device=$device"
- mounted=1
- db_set cdrom-detect/cdrom_device $device
- break
- else
- log "CDROM-mount failed again (error=$?): device=$device"
- log "Unmounting CD just to be sure and giving it up."
- umount /cdrom 2>/dev/null || true
- fi
- fi
- done
-
- if [ "$mounted" = "1" ]; then
- break
- fi
-
- # If a device was detected but the mount failed, ask for the CD.
- if [ -n "$devices" ]; then
+ log "Searching for Debian installation media..."
+ if [ ! -e /cdrom ] ; then
+ mkdir /cdrom 2>/dev/null || true
+ elif [ "$mounted" = "1" ]; then
+ log "Cdrom device was detected but the mount failed."
db_input critical cdrom-detect/retry || [ $? -eq 30 ]
db_go
db_get cdrom-detect/retry
if [ "$RET" = "true" ]; then
+ mounted=0
continue
else
- fail
+ fail "Retry of cdrom detect refused."
+ fi
+ elif [ -e /cdrom/.disk/info ] ; then
+ log "Sanity check of CD before aproving mounted CD"
+ CDNAME=`cat /cdrom/.disk/info`
+ log "Detected CD '$CDNAME'"
+ # Set the suite used by base-installer and base-config to
+ # the suite that is on the CD from Release file.
+ for distlink in stable testing unstable ; do
+ relfile=/cdrom/dists/$distlink/Release
+ if [ -e $relfile ] ; then
+ suite=$(sed -n 's/^Suite: *//p' $relfile)
+ log "Detected CD with '$suite' distribution"
+ db_set mirror/suite $suite
+ break
+ fi
+ done
+ # For DMA related mount errors. (RR extension)
+ if [ "X" = "X${suite}" ]; then
+ log "Could not determine the package 'suite'. Is the cdrom OK?"
+ umount /cdrom 2>/dev/null || true
+ mounted=1
+ continue
+ elif [ ! -e "/cdrom/dists/$suite/Release" ]; then
+ log "No such file '/cdrom/dists/$suite/Release'. Is the cdrom OK?"
+ umount /cdrom 2>/dev/null || true
+ mounted=1
+ continue
fi
+ log "Exit main loop after approving mounted CD."
+ break
+
+ elif mount | grep -q 'on /cdrom ' ; then
+ log "The available CD is not a Debian CD!"
+ umount /cdrom 2>/dev/null || true
+ db_input critical cdrom-detect/wrong-cd || [ $? -eq 30 ]
+ db_go
+ imount=$((${imount}-1))
+ mounted=0
+ continue
+ fi
+
+ # Start detecting and mounting cdrom
+ if [ "$imount" -ge "$maxmount" ] ; then
+ fail "Tried to mount media $imount times and failed."
+ fi
+ imount=$((${imount}+1))
+ log "Loop $imount out of $maxmount"
+ mounted=1
+
+ log "Try to detect a cdrom automatically by devfs."
+ # This cdrom detection can be disabled by CDROM_DEVICES=none
+ if [ -n "$CDROM_DEVICES" ]; then
+ devices="$CDROM_DEVICES"
+ elif [ -d /dev/cdroms ]; then
+ devices=$(echo /dev/cdroms/*|grep -Fv '*' || true)
+ else
+ devices=""
+ fi
+ if [ -n "$devices" ] && [ "$devices" != "none" ]; then
+ for device in $devices
+ do
+ if mount -t iso9660 -o ro,exec $device /cdrom; then
+ log "Cdrom-mount succeeded: device=$device"
+ mounted=2
+ db_set cdrom-detect/cdrom_device $device
+ break # for device loop
+ else
+ log "Cdrom-mount failed (error=$?): device=$device"
+ umount /cdrom 2>/dev/null || true
+ mounted=0
+ fi
+ done
+ continue
fi
- # If no device was detected, perhaps a driver floppy is needed.
+ log "Try to mount a driver floppy since no auto-cdrom device found."
if [ -e /usr/lib/debian-installer/retriever/floppy-retriever ]; then
- db_input critical cdrom-detect/load_floppy
+ db_input critical cdrom-detect/load_floppy
db_go
db_get cdrom-detect/load_floppy
if [ "$RET" = true ]; then
- anna floppy-retriever
- hw-detect cdrom-detect/detect_progress_title || true
- continue
+ anna floppy-retriever
+ hw-detect cdrom-detect/detect_progress_title || true
+ imount=$((${imount}-1))
+ mounted=2
+ continue
fi
fi
- # Otherwise manual configuration may be needed
+ log "Try to mount a cdrom on old non-devfs hardwares manually."
db_input critical cdrom-detect/manual_config || [ $? -eq 30 ]
db_go
db_get cdrom-detect/manual_config
@@ -121,46 +155,21 @@
modprobe $module
fi
if mount -t iso9660 -o ro,exec $device /cdrom; then
- log "CDROM-mount succeeded: device=$device"
- mounted=1
- break
- else
- log "CDROM-mount failed (error=$?): device=$device"
- log "Unmounting CD just to be sure and giving it up."
- umount /cdrom 2>/dev/null || true
+ log "Cdrom-mount succeeded: device=$device"
+ db_set cdrom-detect/cdrom_device $device
+ mounted=2
+ db_set cdrom-detect/cdrom_device $device
+ else
+ log "Cdrom-mount failed (error=$?): device=$device"
+ umount /cdrom 2>/dev/null || true
+ imount=$((${imount}-1))
+ mounted=0
fi
- else
- fail
+ continue
fi
+ fail "No media detected: auto-cdrom, floppy, manual-cdrom."
done
-if [ -e /cdrom/.disk/info ] ; then
- CDNAME=`cat /cdrom/.disk/info`
- log "Detected CD '$CDNAME'"
-else
- log "The available CD is not a Debian CD!"
- umount /cdrom
- db_input critical cdrom-detect/wrong-cd || [ $? -eq 30 ]
- db_go
- exit 1
-fi
-
-# Set the suite used by base-installer and base-config to
-# the suite 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.
-for distlink in stable testing unstable ; do
- relfile=/cdrom/dists/$distlink/Release
- if [ -e $relfile ] ; then
- suite=$(sed -n 's/^Suite: *//p' $relfile)
- log "Detected CD with '$suite' distribution"
- db_set mirror/suite $suite
-
- break
- fi
-done
# Ask for eject to be installed into /target/, to be able to use it in
# the prebaseconfig script.
----- End forwarded message -----
--
see shy jo
Attachment:
signature.asc
Description: Digital signature