home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / ubiquity / apt-setup / generators / 90security < prev   
Encoding:
Text File  |  2006-08-30  |  2.0 KB  |  82 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. . /usr/share/debconf/confmodule
  5.  
  6. file="$1"
  7.  
  8. db_get apt-setup/security_host
  9. host="$RET"
  10. if [ -z "$host" ]; then
  11.     exit
  12. fi
  13. directory=/ubuntu
  14.  
  15. db_get mirror/protocol
  16. protocol="$RET"
  17.  
  18. # Awful Ubuntu-specific hack. *-security suites for ports architectures
  19. # aren't available on security.ubuntu.com, only on ports.ubuntu.com.
  20. if [ "$host" = security.ubuntu.com ]; then
  21.     db_get mirror/$protocol/hostname
  22.     if [ "$RET" = ports.ubuntu.com ]; then
  23.         host="$RET"
  24.         db_get mirror/$protocol/directory
  25.         directory="$RET"
  26.     fi
  27. fi
  28.  
  29. # To determine if non-free and contrib should be included, grep
  30. # the file to see if they are listed in it.
  31. dists="main"
  32. for dist in contrib non-free restricted; do
  33.     if grep -q '^[^#]*'$dist $ROOT/etc/apt/sources.list.new; then
  34.         dists="$dists $dist"
  35.     fi
  36. done
  37.  
  38. if ! db_get mirror/codename || [ -z "$RET" ]; then
  39.     db_get cdrom/codename
  40. fi
  41. codename="$RET"
  42.  
  43. # No updates for sid (unstable). Never mind.
  44. if [ "$codename" = sid ]; then
  45.     exit
  46. fi
  47.  
  48. # FIXME what if choose-mirror isn't available, i.e. full CD install?
  49. if db_get mirror/http/proxy && [ -n "$RET" ]; then
  50.     proxy="$RET"
  51.     if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
  52.         echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
  53.     fi
  54. fi
  55.  
  56. CODE=0
  57. echo "deb http://$host$directory $codename-security $dists" >> $file
  58. if ! apt-setup-verify $file; then
  59.     db_subst apt-setup/security-updates-failed SECURITY_HOST "$host"
  60.     db_input critical apt-setup/security-updates-failed || true
  61.     if ! db_go; then
  62.         exit 10 # back up
  63.     fi
  64.     CODE=9
  65. fi
  66.  
  67. echo "deb-src http://$host$directory $codename-security $dists" >> $file
  68.  
  69. # Security sources for Ubuntu universe; not used much, but e.g. unsupported
  70. # binary packages from a supported source package will end up here.
  71. if db_get apt-setup/universe && [ "$RET" = true ]; then
  72.     COMMENT=
  73. else
  74.     COMMENT='# '
  75. fi
  76. cat >> $file <<EOF
  77. ${COMMENT}deb http://$host$directory $codename-security universe
  78. ${COMMENT}deb-src http://$host$directory $codename-security universe
  79. EOF
  80.  
  81. exit $CODE
  82.