On Friday 26 October 2007, Frans Pop wrote: > A simple check to add would be if the CD has actually been changed (that > the ID is not the same as the last one scanned), or even that a CD has > not yet been scanned. I'll probably add that.
The patch below (which is on top of the earlier patch) adds a check that the CD/DVD hasn't been scanned already. I also now display the labels of CDs after they've been added, which I feel is a lot more user-friendly. In line with that I've also rewritten the templates. I've considered Christian's comments, but not implemented all. Especially the first comment would require also changing existing strings and I don't think it's a good idea to mix that with this new work. I also noticed that the error checking when adding CDs was incorrect in 50cdrom. I've already committed a change for that in SVN and 41cdrom now also uses the correct check.
commit b400f1ff5dd9a732a746fd319b21170c0e02096f Author: Frans Pop <[EMAIL PROTECTED]> Date: Fri Oct 26 21:07:13 2007 +0200 apt-cdrom-setup: rework multi-CD support - check that we don't add the same CD twice - rewrite templates and display labels of added/wanted CDs - also reload installation CD when exiting early from 41cdset - apt-cdrom add will itself report failure if a CD cannot be added diff --git a/packages/apt-setup/debian/apt-cdrom-setup.templates b/packages/apt-setup/debian/apt-cdrom-setup.templates index 95cab60..be8bdc6 100644 --- a/packages/apt-setup/debian/apt-cdrom-setup.templates +++ b/packages/apt-setup/debian/apt-cdrom-setup.templates @@ -11,33 +11,57 @@ _Description: apt configuration problem Template: apt-setup/cdrom/set-first Type: boolean Default: false -_Description: Scan additional CDs or DVDs? - If you have additional CDs or DVDs available from the same set as the - installation CD, you can now scan these. This will allow packages to be - installed from those CD/DVDs during the next step of the installation. +#flag:translate!:3 +Description: Scan another CD or DVD? + Your installation CD or DVD has been scanned; its label is: . - Please insert the new CD or DVD before you make your selection. + ${LABEL} + . + You can now scan additional CDs or DVDs for use by the package manager + (apt). Normally these should be from the same set as the installation + CD/DVD. + . + If you wish to scan another CD or DVD, please insert it now. Template: apt-setup/cdrom/set-next Type: boolean Default: false -_Description: Scan another CD or DVD? - Please insert the new CD or DVD before you make your selection. +#flag:translate!:3 +Description: Scan another CD or DVD? + The CD or DVD with the following label has been scanned: + . + ${LABEL} + . + If you wish to scan another CD or DVD, please insert it now. + +Template: apt-setup/cdrom/set-double +Type: boolean +Default: true +#flag:translate!:3 +Description: Scan another CD or DVD? + The CD or DVD with the following label has already been scanned: + . + ${LABEL} + . + Please replace it now if you wish to scan another CD or DVD. Template: apt-setup/cdrom/set-failed Type: boolean -Default: false -_Description: Scan another CD or DVD? +Default: true +Description: Scan another CD or DVD? An attempt to configure apt to install additional packages from the CD failed. . - Do you wish to try again? + Please check that the CD/DVD has been inserted correctly. Template: apt-setup/cdrom/load-cd1 Type: text -_Description: Insert the original installation CD/DVD. - Please reinsert the first CD or DVD of your set in the drive before - you continue. +#flag:translate!:3 +Description: Please insert the installation CD/DVD. + The installation system now needs the original installation CD, which has + the following label: + . + ${LABEL} Template: finish-install/progress/apt-cdrom-setup Type: text diff --git a/packages/apt-setup/generators/41cdset b/packages/apt-setup/generators/41cdset index f353bcb..00d7338 100755 --- a/packages/apt-setup/generators/41cdset +++ b/packages/apt-setup/generators/41cdset @@ -15,6 +15,15 @@ if [ "$cd_type" != full_cd ] && [ "$cd_type" != dvd ]; then exit 0 fi +get_label() { + # Remove trailing space from the label (#448187) + $logoutput --pass-stdout $chroot $ROOT \ + apt-cdrom ident | grep "^Stored label:" | \ + sed "s/^[^:]*: //;s/[[:space:]]*$//" + # apt-cdrom ident leaves CD mounted + $logoutput $chroot $ROOT umount /cdrom || true +} + logoutput="" if [ "$CATCHLOG" ]; then logoutput="log-output -t apt-setup" @@ -39,28 +48,56 @@ fi tmp=$($chroot $ROOT tempfile) +cd_label=$(get_label) +if [ "$ROOT" ]; then + echo "$cd_label" >>/var/lib/install-cd.id +fi +db_subst apt-setup/cdrom/set-first LABEL "$cd_label" db_input high apt-setup/cdrom/set-first || true -db_go || exit 10 +if ! db_go; then + if [ "$ROOT" ]; then + load-install-cd "$ROOT" + fi + exit 10 +fi db_get apt-setup/cdrom/set-first + while [ "$RET" = true ]; do # The first mount of an image can fail (at least in VirtualBox) $logoutput $chroot $ROOT mount /cdrom && \ $logoutput $chroot $ROOT umount /cdrom || true - # apt-cdrom can be interactive, avoid that - $logoutput $chroot $ROOT apt-cdrom add \ - -o Dir::Etc::SourceList=$tmp \ - </dev/null - cat $ROOT$tmp >> $file - rm -f $ROOT$tmp $ROOT$tmp~ - - if apt-setup-verify $file; then - template=apt-setup/cdrom/set-next + cd_label=$(get_label) + # Hmm. The greps could fail if a label contains regexp control chars... + if [ "$cd_label" ] && \ + (grep "^deb cdrom:\[$cd_label\]" $file || \ + grep "^deb cdrom:\[$cd_label\]" $ROOT/etc/apt/sources.list.new); then + template=apt-setup/cdrom/set-double + 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 + db_input critical $template || true - db_go || exit 10 + if ! db_go; then + if [ "$ROOT" ]; then + load-install-cd "$ROOT" + fi + exit 10 + fi db_get $template done diff --git a/packages/apt-setup/load-install-cd b/packages/apt-setup/load-install-cd index 7c013b5..d0ac98f 100755 --- a/packages/apt-setup/load-install-cd +++ b/packages/apt-setup/load-install-cd @@ -21,12 +21,14 @@ check_id() { # apt-cdrom ident leaves CD mounted $logoutput chroot $ROOT umount /cdrom || true - if [ "$cd_id" = "$(cat /var/lib/install-cd.id)" ]; then + if [ "$cd_id" = "$(head -n1 /var/lib/install-cd.id)" ]; then return 0 fi return 1 } +cd_label=$(tail -n1 /var/lib/install-cd.id) +db_subst apt-setup/cdrom/load-cd1 LABEL "$cd_label" while ! check_id; do db_input high apt-setup/cdrom/load-cd1 || true db_go || exit 10
signature.asc
Description: This is a digitally signed message part.