home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / ubiquity / apt-setup / generators / 40cdrom < prev    next >
Encoding:
Text File  |  2009-01-14  |  2.0 KB  |  101 lines

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