Bug#265636: Idea for Dell CDROM detect issue
I found bug.
If no IDE existed, it used to assign:
devices='/dev/cdroms/*'
That is bad. That section (needs to be)
# Auto detect CDROM by devfs
if [ -d /dev/cdroms ]; then
devices=$(echo /dev/cdroms/*|grep -v '*' || true)
else
devices=""
fi
Also
if [ -n "$devices" ]; then
needs to be moved up before
for device in $devices
Some more code cleanings ...
By the way, it does not detect firewire CD now.
Osamu
#! /bin/sh
set -e
. /usr/share/debconf/confmodule
#set -x
log() {
logger -t cdrom-detect "$@"
}
fail () {
log "$@"
db_input critical cdrom-detect/failure || [ $? -eq 30 ]
db_go
# redundant but to be sure
umount /cdrom 2>/dev/null || true
exit 1
}
hw-detect cdrom-detect/detect_progress_title || true
log "Searching for Debian installation media..."
maxmount=2 # max count of the mount try
imount=0 # mount counter
mounted=0 # 0=initial, 1=detection in progress, 2=mounted
while true
do
if [ "$imount" -gt "$maxmount" ] ; then
fail "Tried to mount CD $maxmount times and failed."
fi
log "main loop: $imount out of $maxmount"
# Is a cdrom (image) already mounted at /cdrom? Sanity check!
if [ ! -e /cdrom ] ; then
# First run of cdrom-detect
mkdir /cdrom 2>/dev/null || true
elif [ "$mounted" = "1" ]; then
# If a device was detected but the mount failed, ask for the CD.
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
imount=$((${imount}-1))
mounted=0
continue
else
fail "a device was detected but the mount failed."
fi
elif [ -e /cdrom/.disk/info ] ; then
# 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. 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 # for distlink loop
fi
done
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 "successful mount, exit main loop."
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
# mount CD
imount=$((${imount}+1))
mounted=1
# Auto detect CDROM by devfs
if [ -d /dev/cdroms ]; then
devices=$(echo /dev/cdroms/*|grep -v '*' || true)
else
devices=""
fi
if [ -n "$devices" ]; 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"
log "Unmounting CD just to be sure."
umount /cdrom 2>/dev/null || true
fi
done
continue
fi
# Mount floppy if CD auto detect fails
# If no device was detected, perhaps a driver floppy is needed.
if [ -e /usr/lib/debian-installer/retriever/floppy-retriever ]; then
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
mounted=2
continue
fi
fi
# Otherwise manual configuration may be needed
db_input critical cdrom-detect/manual_config || [ $? -eq 30 ]
db_go
db_get cdrom-detect/manual_config
modules=none
for i in `ls -1 /lib/modules/*/kernel/drivers/cdrom/ | sed 's/\.ko$//' | sed 's/\.o$//'`
do
modules="$modules, $i"
done
if [ "$RET" = "true" ]; then
db_subst cdrom-detect/cdrom_module choices "$modules"
db_input critical cdrom-detect/cdrom_module || [ $? -eq 30 ]
db_go
db_get cdrom-detect/cdrom_module
module="$RET"
db_input critical cdrom-detect/cdrom_device || [ $? -eq 30 ]
db_go
db_get cdrom-detect/cdrom_device
device="$RET"
if [ "$module" != "none" ]; then
modprobe $module
fi
if mount -t iso9660 -o ro,exec $device /cdrom; then
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"
log "Unmounting CD just to be sure and giving it up."
umount /cdrom 2>/dev/null || true
fi
continue
else
fail "Manual CD mount refused."
fi
mounted=0
done
# Ask for eject to be installed into /target/, to be able to use it in
# the prebaseconfig script.
apt-install eject || true
# Hey, we're done
db_subst cdrom-detect/success cdname "$CDNAME"
db_input low cdrom-detect/success || [ $? -eq 30 ]
db_go
exit 0
Reply to: