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.

89 lines
1.6 KiB

  1. #!/bin/sh
  2. set -e
  3. . /usr/share/debconf/confmodule
  4. file="$1"
  5. if [ ! -e /cdrom/.disk/base_installable ]; then
  6. exit 0
  7. fi
  8. fs=iso9660
  9. if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
  10. fs="$RET"
  11. fi
  12. if [ "$fs" != iso9660 ]; then
  13. exit 0
  14. fi
  15. remount_cd() {
  16. if [ "$ROOT" ] && [ ! -d /hd-media ]; then
  17. db_get cdrom-detect/cdrom_device
  18. $logoutput mount -t "$fs" -o ro,exec $RET /cdrom || true
  19. fi
  20. }
  21. bail_out() {
  22. remount_cd
  23. rm -f $ROOT$tmp $ROOT$tmp~
  24. rm -f /var/lib/install-cd.id
  25. db_input critical apt-setup/cdrom/failed || true
  26. db_go || exit 10
  27. exit 1
  28. }
  29. # Save identification of installation CD
  30. save_label() {
  31. local ident
  32. if ! ident="$($logoutput_pass $chroot $ROOT apt-cdrom ident)"; then
  33. bail_out
  34. fi
  35. echo "$ident" | grep "^Identifying" | cut -d" " -f2 \
  36. >/var/lib/install-cd.id
  37. echo "$ident" | grep "^Stored label:" | sed "s/^[^:]*: //" \
  38. >>/var/lib/install-cd.id
  39. }
  40. logoutput=""
  41. logoutput_pass=""
  42. if [ "$CATCHLOG" ]; then
  43. logoutput="log-output -t apt-setup"
  44. logoutput_pass="$logoutput --pass-stdout"
  45. fi
  46. chroot=
  47. if [ "$ROOT" ]; then
  48. chroot=chroot
  49. # Allow apt-cdrom to manage mounting/unmounting CDs in /target
  50. # (except for hd-media installs)
  51. if [ ! -d /hd-media ]; then
  52. rm -f $ROOT/etc/apt/apt.conf.d/00NoMountCDROM
  53. # Also removes the bind-mount in /target
  54. $logoutput umount /cdrom || true
  55. fi
  56. fi
  57. tmp=$($chroot $ROOT tempfile)
  58. # apt-cdrom can be interactive, avoid that
  59. if $logoutput $chroot $ROOT apt-cdrom add \
  60. -o Dir::Etc::SourceList=$tmp \
  61. </dev/null; then
  62. cat $ROOT$tmp >> $file
  63. if [ "$ROOT" ] && [ ! -d /hd-media ]; then
  64. save_label
  65. fi
  66. else
  67. bail_out
  68. fi
  69. remount_cd
  70. rm -f $ROOT$tmp $ROOT$tmp~