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.

50mirror.ubuntu 5.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #!/bin/sh
  2. set -e
  3. . /usr/share/debconf/confmodule
  4. file="$1"
  5. log() {
  6. logger -t apt-setup "$@"
  7. }
  8. warning() {
  9. log "warning: $@"
  10. }
  11. # Ask if a mirror should be used if the base system can be installed from CD
  12. if [ -e /cdrom/.disk/base_installable ]; then
  13. if ! search-path choose-mirror; then
  14. warning "choose-mirror is not available; cannot offer network mirror"
  15. exit 1
  16. fi
  17. # Set default if no value (see Debian mirror generator)
  18. db_get apt-setup/use_mirror
  19. [ "$RET" ] || db_set apt-setup/use_mirror true
  20. # Text is variable for Debian
  21. db_metaget apt-setup/use/netinst_old description
  22. db_subst apt-setup/use_mirror EXPLANATION "$RET"
  23. db_input medium apt-setup/use_mirror || [ $? -eq 30 ]
  24. db_go # or exit 10
  25. db_get apt-setup/use_mirror
  26. if [ "$RET" = false ]; then
  27. exit 1
  28. fi
  29. if db_get cdrom/codename && [ "$RET" ]; then
  30. db_set mirror/codename $RET
  31. fi
  32. if db_get cdrom/suite && [ "$RET" ]; then
  33. db_set mirror/suite $RET
  34. fi
  35. choose-mirror -n # no progress bar
  36. db_capb backup progresscancel
  37. fi
  38. STATE=1
  39. while :; do
  40. case "$STATE" in
  41. 1)
  42. db_input low apt-setup/restricted || true
  43. ;;
  44. 2)
  45. db_input low apt-setup/universe || true
  46. ;;
  47. 3)
  48. db_input low apt-setup/multiverse || true
  49. ;;
  50. 4)
  51. db_input low apt-setup/backports || true
  52. ;;
  53. 5)
  54. if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
  55. (db_get apt-setup/multiverse && [ "$RET" = true ]); then
  56. db_input low apt-setup/partner || true
  57. fi
  58. ;;
  59. *)
  60. break
  61. ;;
  62. esac
  63. if db_go; then
  64. STATE=$(($STATE + 1))
  65. else
  66. STATE=$(($STATE - 1))
  67. fi
  68. done
  69. if [ $STATE -eq 0 ]; then
  70. exit 10
  71. fi
  72. dists="main"
  73. db_get apt-setup/restricted
  74. if [ "$RET" = true ]; then
  75. dists="$dists restricted"
  76. fi
  77. db_get mirror/protocol
  78. protocol="$RET"
  79. db_get mirror/codename
  80. codename="$RET"
  81. db_get mirror/$protocol/hostname
  82. hostname="$RET"
  83. db_get mirror/$protocol/directory
  84. directory="/${RET#/}"
  85. # Awful hack. Source for ports architectures is only available on
  86. # archive.ubuntu.com, not ports.ubuntu.com.
  87. if [ "$hostname" = ports.ubuntu.com ]; then
  88. srchostname=archive.ubuntu.com
  89. srcdirectory=/ubuntu
  90. else
  91. srchostname="$hostname"
  92. srcdirectory="$directory"
  93. fi
  94. if [ "$protocol" = http ]; then
  95. db_get mirror/$protocol/proxy
  96. proxy="$RET"
  97. if [ -n "$proxy" ]; then
  98. if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
  99. echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
  100. fi
  101. fi
  102. fi
  103. db_get apt-setup/proposed
  104. PROPOSED="$RET"
  105. cat >> $file <<EOF
  106. deb $protocol://$hostname$directory $codename $dists
  107. deb-src $protocol://$srchostname$srcdirectory $codename $dists
  108. ## Major bug fix updates produced after the final release of the
  109. ## distribution.
  110. deb $protocol://$hostname$directory $codename-updates $dists
  111. deb-src $protocol://$srchostname$srcdirectory $codename-updates $dists
  112. EOF
  113. if [ "$PROPOSED" = true ]; then
  114. cat >> $file <<EOF
  115. ## Proposed updates undergoing testing.
  116. deb $protocol://$hostname$directory $codename-proposed $dists
  117. deb-src $protocol://$srchostname$srcdirectory $codename-proposed $dists
  118. EOF
  119. fi
  120. # Even if universe isn't enabled, we write example lines for it.
  121. echo >> $file
  122. if db_get apt-setup/universe && [ "$RET" = true ]; then
  123. COMMENT=
  124. else
  125. cat >> $file <<EOF
  126. ## Uncomment the following two lines to add software from the 'universe'
  127. ## repository.
  128. EOF
  129. COMMENT='# '
  130. fi
  131. cat >> $file <<EOF
  132. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  133. ## team, and may not be under a free licence. Please satisfy yourself as to
  134. ## your rights to use the software. Also, please note that software in
  135. ## universe WILL NOT receive any review or updates from the Ubuntu security
  136. ## team.
  137. ${COMMENT}deb $protocol://$hostname$directory $codename universe
  138. ${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename universe
  139. EOF
  140. # Multiverse is different, don't write anything unless enabled.
  141. if db_get apt-setup/multiverse && [ "$RET" = true ]; then
  142. cat >> $file <<EOF
  143. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  144. ## team, and may not be under a free licence. Please satisfy yourself as to
  145. ## your rights to use the software. Also, please note that software in
  146. ## multiverse WILL NOT receive any review or updates from the Ubuntu
  147. ## security team.
  148. deb $protocol://$hostname$directory $codename multiverse
  149. deb-src $protocol://$srchostname$srcdirectory $codename multiverse
  150. EOF
  151. fi
  152. # Even if the backports repository isn't enabled, we write example lines for
  153. # it.
  154. echo >> $file
  155. if db_get apt-setup/backports && [ "$RET" = true ]; then
  156. COMMENT=
  157. else
  158. cat >> $file <<EOF
  159. ## Uncomment the following two lines to add software from the 'backports'
  160. ## repository.
  161. EOF
  162. COMMENT='# '
  163. fi
  164. cat >> $file <<EOF
  165. ## N.B. software from this repository may not have been tested as
  166. ## extensively as that contained in the main release, although it includes
  167. ## newer versions of some applications which may provide useful features.
  168. ## Also, please note that software in backports WILL NOT receive any review
  169. ## or updates from the Ubuntu security team.
  170. ${COMMENT}deb $protocol://$hostname$directory $codename-backports main restricted universe multiverse
  171. ${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename-backports main restricted universe multiverse
  172. EOF
  173. if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
  174. (db_get apt-setup/multiverse && [ "$RET" = true ]) || \
  175. (db_get apt-setup/partner && [ "$RET" = true ]); then
  176. echo >> $file
  177. if db_get apt-setup/partner && [ "$RET" = true ]; then
  178. COMMENT=
  179. else
  180. cat >> $file <<EOF
  181. ## Uncomment the following two lines to add software from Canonical's
  182. ## 'partner' repository.
  183. EOF
  184. COMMENT='# '
  185. fi
  186. cat >> $file <<EOF
  187. ## This software is not part of Ubuntu, but is offered by Canonical and the
  188. ## respective vendors as a service to Ubuntu users.
  189. ${COMMENT}deb http://archive.canonical.com/ubuntu $codename partner
  190. ${COMMENT}deb-src http://archive.canonical.com/ubuntu $codename partner
  191. EOF
  192. fi