source: ubiquity/trunk/fuentes/d-i/source/apt-setup/generators/50mirror.ubuntu @ 3069

Last change on this file since 3069 was 3069, checked in by kbut, 3 years ago

Update from upstream

  • Property svn:executable set to *
File size: 7.3 KB
RevLine 
[1053]1#!/bin/sh
2set -e
3
4. /usr/share/debconf/confmodule
5
6file="$1"
7
8log() {
9        logger -t apt-setup "$@"
10}
11warning() {
12        log "warning: $@"
13}
14
15# Ask if a mirror should be used if the base system can be installed from CD
16if [ -e /cdrom/.disk/base_installable ] || [ "$OVERRIDE_BASE_INSTALLABLE" ]; then
17        if ! search-path choose-mirror; then
18                warning "choose-mirror is not available; cannot offer network mirror"
19                exit 1
20        fi
21
22        # Set default if no value (see Debian mirror generator)
23        db_get apt-setup/use_mirror
24        [ "$RET" ] || db_set apt-setup/use_mirror true 
25
26        # Text is variable for Debian
27        db_metaget apt-setup/use/netinst_old description
28        db_subst apt-setup/use_mirror EXPLANATION "$RET"
29
30        db_input medium apt-setup/use_mirror || [ $? -eq 30 ]
31        db_go # or exit 10
32
33        db_get apt-setup/use_mirror
34        if [ "$RET" = false ]; then
35                exit 1
36        fi
37
38        if db_get cdrom/codename && [ "$RET" ]; then
39                db_set mirror/codename $RET
40        fi
41        if db_get cdrom/suite && [ "$RET" ]; then
42                db_set mirror/suite $RET
43        fi
44        choose-mirror -n # no progress bar
45        db_capb backup progresscancel
46fi
47
48STATE=1
49while :; do
50        case "$STATE" in
51                1)
52                        db_input low apt-setup/restricted || true
53                ;;
54                2)
55                        db_input low apt-setup/universe || true
56                ;;
57                3)
58                        db_input low apt-setup/multiverse || true
59                ;;
60                4)
61                        db_input low apt-setup/backports || true
62                ;;
63                5)
64                        if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
65                           (db_get apt-setup/multiverse && [ "$RET" = true ]); then
66                                db_input low apt-setup/partner || true
67                        fi
68                ;;
69                6)
70                        db_input low apt-setup/enable-source-repositories || true
71                ;;
72                *)
73                        break
74                ;;
75        esac
76
77        if db_go; then
78                STATE=$(($STATE + 1))
79        else
80                STATE=$(($STATE - 1))
81        fi
82done
83if [ $STATE -eq 0 ]; then
84        exit 10
85fi
86
87dists="main"
88alldists="main"
89db_get apt-setup/restricted
90if [ "$RET" = true ]; then
91        dists="$dists restricted"
92        alldists="$alldists restricted"
93else
94        # Remove restricted from any previous cdrom entry if necessary.
95        for srcfile in $ROOT/etc/apt/sources.list.base \
96                    $ROOT/etc/apt/sources.list.new; do
97                if [ -e "$srcfile" ]; then
98                        sed -i '/deb cdrom:/s/ restricted//g' "$srcfile"
99                fi
100        done
101fi
102
103db_get mirror/protocol
104protocol="$RET"
105db_get mirror/codename
106codename="$RET"
107db_get mirror/$protocol/hostname
108hostname="$RET"
109db_get mirror/$protocol/directory
110directory="/${RET#/}"
111
112deb_src="deb-src"
113db_get apt-setup/enable-source-repositories
114if [ "$RET" = false ]; then
115        deb_src="# deb-src"
116fi
117
118# Awful hack. Source for ports architectures is only available on
119# archive.ubuntu.com, not ports.ubuntu.com.
120if [ "$hostname" = ports.ubuntu.com ]; then
121        srchostname=archive.ubuntu.com
122        srcdirectory=/ubuntu
123else
124        srchostname="$hostname"
125        srcdirectory="$directory"
126fi
127
128case $protocol in
129    http|https)
130        db_get mirror/$protocol/proxy
131        proxy="$RET"
132        if [ -n "$proxy" ]; then
133                if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
134                        echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
135                fi
136        fi
137        ;;
138esac
139
140db_get apt-setup/proposed
141PROPOSED="$RET"
142
143cat >> $file <<EOF
144# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
145# newer versions of the distribution.
146
147deb $protocol://$hostname$directory $codename $dists
148$deb_src $protocol://$srchostname$srcdirectory $codename $dists
149
150## Major bug fix updates produced after the final release of the
151## distribution.
152deb $protocol://$hostname$directory $codename-updates $dists
153$deb_src $protocol://$srchostname$srcdirectory $codename-updates $dists
154EOF
155if [ "$PROPOSED" = true ]; then
156        cat >> $file <<EOF
157
158## Proposed updates undergoing testing.
159deb $protocol://$hostname$directory $codename-proposed $dists
160$deb_src $protocol://$srchostname$srcdirectory $codename-proposed $dists
161EOF
162fi
163
164# Even if universe isn't enabled, we write example lines for it.
165echo >> $file
166if db_get apt-setup/universe && [ "$RET" = true ]; then
167        alldists="$alldists universe"
168        DEB='deb'
169        DEB_SRC="$deb_src"
170else
171        cat >> $file <<EOF
172## Uncomment the following two lines to add software from the 'universe'
173## repository.
174EOF
175        DEB='# deb'
176        DEB_SRC='# deb-src'
177fi
178cat >> $file <<EOF
179## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
[3069]180## team. Also, please note that software in universe WILL NOT receive any
181## review or updates from the Ubuntu security team.
[1053]182${DEB} $protocol://$hostname$directory $codename universe
183${DEB_SRC} $protocol://$srchostname$srcdirectory $codename universe
184${DEB} $protocol://$hostname$directory $codename-updates universe
185${DEB_SRC} $protocol://$srchostname$srcdirectory $codename-updates universe
186EOF
187if [ "$PROPOSED" = true ]; then
188        cat >> $file <<EOF
189${DEB} $protocol://$hostname$directory $codename-proposed universe
190${DEB_SRC} $protocol://$srchostname$srcdirectory $codename-proposed universe
191EOF
192fi
193
194# Multiverse is different, don't write anything unless enabled.
195if db_get apt-setup/multiverse && [ "$RET" = true ]; then
196        alldists="$alldists multiverse"
197        cat >> $file <<EOF
198
199## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
200## team, and may not be under a free licence. Please satisfy yourself as to
201## your rights to use the software. Also, please note that software in
202## multiverse WILL NOT receive any review or updates from the Ubuntu
203## security team.
204deb $protocol://$hostname$directory $codename multiverse
205$deb_src $protocol://$srchostname$srcdirectory $codename multiverse
206deb $protocol://$hostname$directory $codename-updates multiverse
207$deb_src $protocol://$srchostname$srcdirectory $codename-updates multiverse
208EOF
209        if [ "$PROPOSED" = true ]; then
210                cat >> $file <<EOF
211deb $protocol://$hostname$directory $codename-proposed multiverse
212$deb_src $protocol://$srchostname$srcdirectory $codename-proposed multiverse
213EOF
214        fi
215fi
216
217# Even if the backports repository isn't enabled, we write example lines for
218# it.
219echo >> $file
220if db_get apt-setup/backports && [ "$RET" = true ]; then
221        DEB='deb'
222        DEB_SRC="$deb_src"
223else
224        cat >> $file <<EOF
225## Uncomment the following two lines to add software from the 'backports'
226## repository.
227EOF
228        DEB='# deb'
229        DEB_SRC='# deb-src'
230fi
231cat >> $file <<EOF
232## N.B. software from this repository may not have been tested as
233## extensively as that contained in the main release, although it includes
234## newer versions of some applications which may provide useful features.
235## Also, please note that software in backports WILL NOT receive any review
236## or updates from the Ubuntu security team.
237${DEB} $protocol://$hostname$directory $codename-backports $alldists
238${DEB_SRC} $protocol://$srchostname$srcdirectory $codename-backports $alldists
239EOF
240
241if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
242   (db_get apt-setup/multiverse && [ "$RET" = true ]) || \
243   (db_get apt-setup/partner && [ "$RET" = true ]); then
244        echo >> $file
245        if db_get apt-setup/partner && [ "$RET" = true ]; then
246                DEB='deb'
247                DEB_SRC="$deb_src"
248        else
249                cat >> $file <<EOF
250## Uncomment the following two lines to add software from Canonical's
251## 'partner' repository.
252EOF
253                DEB='# deb'
254                DEB_SRC='# deb-src'
255        fi
256        cat >> $file <<EOF
257## This software is not part of Ubuntu, but is offered by Canonical and the
258## respective vendors as a service to Ubuntu users.
259${DEB} http://archive.canonical.com/ubuntu $codename partner
260${DEB_SRC} http://archive.canonical.com/ubuntu $codename partner
261EOF
262
263        if db_get apt-setup/partner && [ "$RET" = true ]; then
264                apt-setup-signed-release archive.canonical.com "$file"
265        fi
266fi
267
268apt-setup-signed-release archive.ubuntu.com "$file"
Note: See TracBrowser for help on using the repository browser.