1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
#! /bin/sh
set -e
. /usr/share/debconf/confmodule
#set -x
log() {
logger -t cdrom-detect "$@"
}
fail () {
log "CDROM-detect failed."
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
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
db_input critical cdrom-detect/retry || [ $? -eq 30 ]
db_go
db_get cdrom-detect/retry
if [ "$RET" = "true" ]; then
continue
else
fail
fi
fi
# 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
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"
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
fi
else
fail
fi
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
# Get all the pool directories into the dentry cache, to cut down on seek
# times.
poolcount="$(set -- /cdrom/pool/*/*; echo $#)"
db_progress START 0 "$poolcount" cdrom-detect/scanning_progress_title
for pooldir in /cdrom/pool/*/*; do
if [ -d "$pooldir" ]; then
db_subst cdrom-detect/scanning_progress_step DIR "$pooldir"
db_progress INFO cdrom-detect/scanning_progress_step
find "$pooldir/" >/dev/null 2>&1
fi
db_progress STEP 1
done
db_progress STOP
# 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.
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
|