]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/schroot/files/schroot-setup.d/99builddsourceslist
3828c175b6d14aeaa1e7ca4ca29a579b191f9c81
[dsa-puppet.git] / modules / schroot / files / schroot-setup.d / 99builddsourceslist
1 #!/bin/bash
2
3 ##
4 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
5 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
6 ##
7
8 # vim:set et ts=4 sw=4:
9 # Copyright © 2010 Marc Brockschmidt <he@debian.org>
10 # Copyright © 2010 Andreas Barth <aba@not.so.argh.org>
11 # Copyright © 2010 Philipp Kern <pkern@debian.org>
12 #
13 # buildd is free software: you can redistribute it and/or modify it
14 # under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # buildd is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 # General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program.  If not, see
25 # <http://www.gnu.org/licenses/>.
26 #
27 #####################################################################
28
29 set -e
30 shopt -s extglob
31
32 [ "$CHROOT_PROFILE" = "buildd" ] || exit 0
33
34 . "$SETUP_DATA_DIR/common-data"
35 . "$SETUP_DATA_DIR/common-functions"
36 . "$SETUP_DATA_DIR/common-config"
37
38 # The test below tries to determine if a source chroot is being used.
39 # The apt configuration is generated only for non-source chroots.
40 #
41 # It originally tested CHROOT_SESSION_PURGE, but while it works for
42 # LVM based chroots, it doesn't for tar based chroots which always
43 # needed to be purged.
44 #
45 # Future versions of schroot will implement CHROOT_SESSION_SOURCE for
46 # a more robust way to check for source chroots.
47 #
48 # See bug#718127 for more details.
49 if ! echo "$CHROOT_DESCRIPTION" | grep -q '(source chroot)' ; then
50     CHROOT_ALIAS="${CHROOT_ALIAS/#experimental-/sid-experimental-}"
51     case $CHROOT_ALIAS in
52         +([^-])-+([^-])-@(kfreebsd|hurd)-*-sbuild*)
53         SUITE_BASE=$(echo $CHROOT_ALIAS | cut -f1 -d-)
54         SUITE_VARIANT=$(echo $CHROOT_ALIAS | cut -f2 -d-)
55         ;;
56         *-*-*-*-sbuild*)
57         SUITE_BASE=$(echo $CHROOT_ALIAS | cut -f1 -d-)
58         SUITE_VARIANT=$(echo $CHROOT_ALIAS | cut -f2,3 -d-)
59         ;;
60         +([^-])-@(kfreebsd|hurd)-*-sbuild*)
61         SUITE_BASE=$(echo $CHROOT_ALIAS | cut -f1 -d-)
62         if [ ${SUITE_BASE} != "sid" ]; then
63             SUITE_VARIANT="proposed-updates"
64         fi
65         ;;
66         *-*-*-sbuild*)
67         SUITE_BASE=$(echo $CHROOT_ALIAS | cut -f1 -d-)
68         SUITE_VARIANT=$(echo $CHROOT_ALIAS | cut -f2 -d-)
69         ;;
70         *-*-sbuild*)
71         SUITE_BASE=$(echo $CHROOT_ALIAS | cut -f1 -d-)
72         if [ ${SUITE_BASE} != "sid" ]; then
73             SUITE_VARIANT="proposed-updates"
74         fi
75         ;;
76     esac
77 fi
78
79 VERBOSE=""
80 if [ "$AUTH_VERBOSITY" = "verbose" ]; then
81       VERBOSE="--verbose"
82 fi
83
84 if [ -f /etc/schroot/dsa/default-mirror ]; then
85     debian_mirror=$(cat /etc/schroot/dsa/default-mirror)
86 elif [ -f /etc/schroot/conf.buildd ]; then
87     . /etc/schroot/conf.buildd
88 fi
89
90 function domirror() {
91     for SUITE in ${SUITES:-SUITE}; do
92         echo deb $1     | sed -e "s,COMPONENT,${COMPONENT},"     -e "s,SUITE,${SUITE}," >> $2
93         echo deb-src $1 | sed -e "s,COMPONENT,${COMPONENT_SRC}," -e "s,SUITE,${SUITE}," >> $2
94     done
95 }
96
97 if [ "$1" = "setup-start" ] || [ "$1" = "setup-recover" ]; then
98     if [ -n "${SUITE_BASE}" ] && ( [ -f /etc/schroot/conf.buildd ] || [ -f /etc/schroot/dsa/default-mirror ] ); then
99         APT_LIST="${CHROOT_PATH}/etc/apt/sources.buildd.list"
100         APT_CONF="${CHROOT_PATH}/etc/apt/apt.conf.d/99buildd.conf"
101         APT_KEYS=""
102         rm -f "${APT_LIST}" "${APT_CONF}"
103
104         COMPONENT="main contrib"
105         COMPONENT_SRC="main contrib non-free"
106
107         if [ "${SUITE_VARIANT}" = 'proposed-updates' ]; then
108             SUITES="${SUITE_BASE} ${SUITE_BASE}-proposed-updates"
109             [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE COMPONENT" ${APT_LIST}
110             domirror "http://ftp.debian.org/debian SUITE COMPONENT" ${APT_LIST}
111             if [ "${debian_incoming}" != 'no' ]; then
112                 SUITES="${SUITE_BASE}-proposed-updates"
113                 domirror "http://incoming.debian.org/debian-buildd buildd-SUITE COMPONENT" ${APT_LIST}
114             fi
115
116         elif [ "${SUITE_VARIANT}" = 'lts' ]; then
117             SUITES="${SUITE_BASE} ${SUITE_BASE}-lts"
118             [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE COMPONENT" ${APT_LIST}
119             domirror "http://ftp.debian.org/debian SUITE COMPONENT" ${APT_LIST}
120             if [ "${debian_incoming}" != 'no' ]; then
121                 SUITES="${SUITE_BASE}-lts"
122                 domirror "http://incoming.debian.org/debian-buildd buildd-SUITE COMPONENT" ${APT_LIST}
123             fi
124
125         elif [ "${SUITE_VARIANT}" = 'security' ]; then
126             SUITES="${SUITE_BASE}"
127             [ -n "${debian_mirror}" ] && domirror "${debian_mirror} ${SUITE_BASE} COMPONENT" ${APT_LIST}
128             domirror "http://ftp.debian.org/debian ${SUITE_BASE} COMPONENT" ${APT_LIST}
129             [ -n "${security_mirror}" ] && domirror "${security_mirror} ${SUITE_BASE}/updates COMPONENT" ${APT_LIST}
130             domirror "http://security-master.debian.org/debian-security ${SUITE_BASE}/updates COMPONENT" ${APT_LIST}
131             domirror "http://security-master.debian.org/debian-security-buildd buildd-${SUITE_BASE}/updates COMPONENT" ${APT_LIST}
132
133         elif [ "${SUITE_VARIANT%%-sloppy}" = 'backports' ]; then
134             SUITES="${SUITE_BASE}"
135             [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE COMPONENT" ${APT_LIST}
136             domirror "http://ftp.debian.org/debian SUITE COMPONENT" ${APT_LIST}
137             if [ "$SUITE" != "squeeze" ]; then
138                 [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE-backports COMPONENT" ${APT_LIST}
139                 domirror "http://ftp.debian.org/debian SUITE-backports COMPONENT" ${APT_LIST}
140             else
141                 [ -n "${backports_mirror}" ] && domirror "${backports_mirror} SUITE COMPONENT" ${APT_LIST}
142                 domirror "http://backports.debian.org/debian-backports/ SUITE-backports COMPONENT" ${APT_LIST}
143             fi
144             if [ "${debian_incoming}" != 'no' ]; then
145                 domirror "http://incoming.debian.org/debian-buildd buildd-SUITE-backports COMPONENT" ${APT_LIST}
146             fi
147             if [ "$(echo ${SUITE_VARIANT} | cut -d - -f 2)" = "sloppy" ]; then
148                 if [ "$SUITE" != "squeeze" ]; then
149                     [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE-backports-sloppy COMPONENT" ${APT_LIST}
150                     domirror "http://ftp.debian.org/debian SUITE-backports-sloppy COMPONENT" ${APT_LIST}
151                 else
152                     [ -n "${backports_mirror}" ] && domirror "${backports_mirror} SUITE-backports-sloppy COMPONENT" ${APT_LIST}
153                     domirror "http://backports.debian.org/debian-backports/ SUITE-backports-sloppy COMPONENT" ${APT_LIST}
154                 fi
155                 if [ "${debian_incoming}" != 'no' ]; then
156                     domirror "http://incoming.debian.org/debian-buildd buildd-SUITE-backports-sloppy COMPONENT" ${APT_LIST}
157                 fi
158             fi
159
160         elif [ "${SUITE_VARIANT}" = 'edu' ]; then
161             SUITES="${SUITE_BASE} ${SUITE_BASE}-proposed-updates"
162             [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE COMPONENT" ${APT_LIST}
163             domirror "http://ftp.debian.org/debian SUITE COMPONENT" ${APT_LIST}
164             SUITES="${SUITE_BASE} ${SUITE_BASE}-test"
165             [ -n "${edu_mirror}" ] && domirror "${edu_mirror} SUITE local" ${APT_LIST}
166             domirror "http://ftp.skolelinux.no/skolelinux/ SUITE local" ${APT_LIST}
167             APT_KEYS="${APT_KEYS} debian-edu"
168
169         elif [ "${SUITE_BASE}" = 'sid' ]; then
170             SUITES="unstable"
171             if [ "${SUITE_VARIANT}" = "experimental" ]; then
172                 SUITES="unstable experimental"
173             fi
174             [ -n "${debian_mirror}" ] && domirror "${debian_mirror} SUITE COMPONENT" ${APT_LIST}
175             domirror "http://ftp.debian.org/debian SUITE COMPONENT" ${APT_LIST}
176             if [ "${debian_incoming}" != 'no' ]; then
177                 domirror "http://incoming.debian.org/debian-buildd buildd-SUITE COMPONENT" ${APT_LIST}
178             fi
179
180         else
181             echo "ERROR: cannot adjust sources.list: ${SUITE_BASE}/${SUITE_VARIANT} unknown - exiting"
182             exit 1
183
184         fi
185         echo 'Acquire::PDiffs "false";' >> ${APT_CONF}
186         echo 'APT::Install-Recommends 0;' >> ${APT_CONF}
187         echo 'Dir::Etc::SourceList "sources.buildd.list";' >> ${APT_CONF}
188         echo 'Acquire::Languages "none";' >> ${APT_CONF}
189
190         if [ -n "${APT_KEYS}" ]; then
191             for KEY in ${APT_KEYS}; do
192                 if [ -f /usr/share/buildd/${KEY}.asc ]; then
193                     chroot ${CHROOT_PATH} apt-key add - < /usr/share/buildd/${KEY}.asc >&2
194                 else
195                     echo W: should add apt key ${KEY} but not found >&2
196                 fi
197             done
198         fi
199     else
200     if [ -n "$SUITE_VARIANT" ]; then
201         SOURCES_FILE_NAME="${SUITE_BASE}-${SUITE_VARIANT}.sources"
202         SOURCES_FILE_PATH="/etc/schroot/buildd.d/${SOURCES_FILE_NAME}"
203                 APT_LIST_AUTO="${CHROOT_PATH}/etc/apt/sources.list.d/auto.list"
204
205         if [ -f "$SOURCES_FILE_PATH" ]; then
206                 cp $VERBOSE ${SOURCES_FILE_PATH} "${CHROOT_PATH}/etc/apt/sources.list.d/${SOURCES_FILE_NAME}.list"
207                 elif [ ${SUITE_VARIANT} = 'security' ]; then
208                         : > ${APT_LIST_AUTO}
209                     if [ -n "${security_mirror}" ]; then
210                         echo deb ${security_mirror} ${SUITE_BASE}/updates main contrib >> ${APT_LIST_AUTO}
211                         echo deb-src ${security_mirror} ${SUITE_BASE}/updates main contrib >> ${APT_LIST_AUTO}
212                     fi
213                     echo deb http://security-master.debian.org/debian-security ${SUITE_BASE}/updates main contrib >> ${APT_LIST_AUTO}
214                     echo deb-src http://security-master.debian.org/debian-security ${SUITE_BASE}/updates main contrib >> ${APT_LIST_AUTO}
215                     echo deb http://security-master.debian.org/debian-security-buildd buildd-${SUITE_BASE}/updates main contrib >> ${APT_LIST_AUTO}
216                     echo deb-src http://security-master.debian.org/debian-security-buildd buildd-${SUITE_BASE}/updates main contrib >> ${APT_LIST_AUTO}
217                 elif [ ${SUITE_VARIANT%%-sloppy} = 'backports' ]; then
218                         : > ${APT_LIST_AUTO}
219                     if [ -n "${backports_mirror}" ]; then
220                         echo deb ${backports_mirror} ${SUITE_BASE}-backports main contrib >> ${APT_LIST_AUTO}
221                         echo deb-src ${backports_mirror} ${SUITE_BASE}-backports main contrib non-free >> ${APT_LIST_AUTO}
222                     fi
223                     echo deb http://backports.debian.org/debian-backports/ ${SUITE_BASE}-backports main contrib >> ${APT_LIST_AUTO}
224                     echo deb-src http://backports.debian.org/debian-backports/ ${SUITE_BASE}-backports main contrib non-free >> ${APT_LIST_AUTO}
225                     echo deb http://backports-master.debian.org/buildd/${SUITE_BASE}-backports / >> ${APT_LIST_AUTO}
226                     echo deb-src http://backports-master.debian.org/buildd/${SUITE_BASE}-backports / >> ${APT_LIST_AUTO}
227                     if [ "$(echo ${SUITE_VARIANT} | cut -d - -f 2)" = "sloppy" ]; then
228                         if [ -n "${backports_mirror}" ]; then
229                             echo deb ${backports_mirror} ${SUITE_BASE}-backports-sloppy main contrib >> ${APT_LIST_AUTO}
230                             echo deb-src ${backports_mirror} ${SUITE_BASE}-backports-sloppy main contrib non-free >> ${APT_LIST_AUTO}
231                         fi
232                         echo deb http://backports.debian.org/debian-backports/ ${SUITE_BASE}-backports-sloppy main contrib >> ${APT_LIST_AUTO}
233                         echo deb-src http://backports.debian.org/debian-backports/ ${SUITE_BASE}-backports-sloppy main contrib non-free >> ${APT_LIST_AUTO}
234                         echo deb http://backports-master.debian.org/buildd/${SUITE_BASE}-backports-sloppy / >> ${APT_LIST_AUTO}
235                         echo deb-src http://backports-master.debian.org/buildd/${SUITE_BASE}-backports-sloppy / >> ${APT_LIST_AUTO}
236                     fi
237                 elif [ ${SUITE_VARIANT} = 'experimental' ]; then
238                     : > ${APT_LIST_AUTO}
239                     if [ -n "${debian_mirror}" ]; then
240                         echo deb ${debian_mirror} experimental main contrib >> ${APT_LIST_AUTO}
241                         echo deb-src ${debian_mirror} experimental main contrib non-free >> ${APT_LIST_AUTO}
242                     fi
243                     echo deb     http://ftp.debian.org/debian experimental main contrib >> ${APT_LIST_AUTO}
244                     echo deb-src http://ftp.debian.org/debian experimental main contrib non-free >> ${APT_LIST_AUTO}
245                     echo deb     http://incoming.debian.org/debian-buildd buildd-experimental main contrib >> ${APT_LIST_AUTO}
246                     echo deb-src http://incoming.debian.org/debian-buildd buildd-experimental main contrib non-free >> ${APT_LIST_AUTO}
247         fi
248     fi
249     fi
250 elif [ "$1" = "setup-stop" ]; then
251     if [ -n "${SUITE_BASE}" ] && ( [ -f /etc/schroot/conf.buildd ] || [ -f /etc/schroot/dsa/default-mirror ] ); then
252         APT_LIST="${CHROOT_PATH}/etc/apt/sources.buildd.list"
253         APT_CONF="${CHROOT_PATH}/etc/apt/apt.conf.d/99buildd.conf"
254         rm -f "${APT_LIST}" "${APT_CONF}"
255     else
256     if [ -n "$SUITE_VARIANT" ]; then
257         SOURCES_FILE_NAME="${SUITE_BASE}-${SUITE_VARIANT}.sources"
258         SOURCES_FILE_PATH="/etc/schroot/buildd.d/${SOURCES_FILE_NAME}"
259
260         if [ -f "$SOURCES_FILE_PATH" ]; then
261                 rm -f $VERBOSE "${CHROOT_PATH}/etc/apt/sources.list.d/${SOURCES_FILE_NAME}.list"
262                 elif [ ${SUITE_VARIANT} = 'security' ] || [ ${SUITE_VARIANT} = 'backports' ] || [ ${SUITE_VARIANT} = 'experimental' ] ; then
263                 rm -f $VERBOSE "${CHROOT_PATH}/etc/apt/sources.list.d/auto.list"
264         fi
265     fi
266     fi
267 fi