You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2 KiB

  1. #!/bin/sh
  2. set -e
  3. . /usr/share/debconf/confmodule
  4. file="$1"
  5. if [ ! -e /cdrom/.disk/cd_type ] || [ -d /hd-media ] || \
  6. [ ! -e /var/lib/install-cd.id ]; then
  7. exit 0
  8. fi
  9. # multi-arch CDs have cd_type 'non_complete'
  10. # KDE/Xfce CDs and multi-arch DVDs have '/single' postfix in cd_type
  11. cd_type=$(cat /cdrom/.disk/cd_type)
  12. if [ "$cd_type" != full_cd ] && [ "$cd_type" != dvd ]; then
  13. exit 0
  14. fi
  15. get_label() {
  16. $logoutput --pass-stdout $chroot $ROOT \
  17. apt-cdrom ident | grep "^Stored label:" | \
  18. sed "s/^[^:]*: //"
  19. }
  20. logoutput=""
  21. if [ "$CATCHLOG" ]; then
  22. logoutput="log-output -t apt-setup"
  23. fi
  24. chroot=
  25. if [ "$ROOT" ]; then
  26. chroot=chroot
  27. # We can only change CDs if current CD is unmounted
  28. $logoutput umount /cdrom || true
  29. fi
  30. tmp=$($chroot $ROOT tempfile)
  31. # Only needed with Etch version of apt-cdrom
  32. $logoutput umount /target/cdrom/ || true
  33. cd_label=$(tail -n1 /var/lib/install-cd.id)
  34. db_subst apt-setup/cdrom/set-first LABEL "$cd_label"
  35. db_input high apt-setup/cdrom/set-first || true
  36. if ! db_go; then
  37. if [ "$ROOT" ]; then
  38. load-install-cd "$ROOT"
  39. fi
  40. exit 10
  41. fi
  42. db_get apt-setup/cdrom/set-first
  43. while [ "$RET" = true ]; do
  44. cd_label=$(get_label)
  45. # Hmm. The greps could fail if a label contains regexp control chars...
  46. if [ "$cd_label" ] && \
  47. (grep "^deb cdrom:\[$cd_label\]" $file || \
  48. grep "^deb cdrom:\[$cd_label\]" $ROOT/etc/apt/sources.list.new); then
  49. template=apt-setup/cdrom/set-double
  50. db_subst $template LABEL "$cd_label"
  51. else
  52. # apt-cdrom can be interactive, avoid that
  53. if $logoutput $chroot $ROOT apt-cdrom add \
  54. -o Dir::Etc::SourceList=$tmp \
  55. </dev/null; then
  56. cat $ROOT$tmp >> $file
  57. # Label is assigned by apt-cdrom add, so get again
  58. cd_label=$(get_label)
  59. template=apt-setup/cdrom/set-next
  60. db_subst $template LABEL "$cd_label"
  61. else
  62. template=apt-setup/cdrom/set-failed
  63. fi
  64. rm -f $ROOT$tmp $ROOT$tmp~
  65. fi
  66. # Only needed with Etch version of apt-cdrom
  67. $logoutput umount /target/cdrom/ || true
  68. db_input critical $template || true
  69. if ! db_go; then
  70. if [ "$ROOT" ]; then
  71. load-install-cd "$ROOT"
  72. fi
  73. exit 10
  74. fi
  75. db_get $template
  76. done
  77. # Make sure the installation CD is loaded again
  78. if [ "$ROOT" ]; then
  79. load-install-cd "$ROOT"
  80. fi