Cleaning up from python removal (LIVE_IMAGE_PARENT_ARCHIVE_AREAS).
[debian-live-build.git] / scripts / build / bootstrap_archives
blob6353019134b2849c32db7c8ac1f3c5016f39ba8c
1 #!/bin/sh
3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
5 ##
6 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7 ## This is free software, and you are welcome to redistribute it
8 ## under certain conditions; see COPYING for details.
11 set -e
13 # Including common functions
14 [ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
16 # Setting static variables
17 DESCRIPTION="$(Echo 'manage /etc/apt/sources.list')"
18 HELP=""
19 USAGE="${PROGRAM} [--force]"
21 _PASS="${1:-binary}"
22 if [ -n "${1}" ]
23 then
24 shift
27 Arguments "${@}"
29 # Reading configuration files
30 Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
31 Set_defaults
33 # Requiring stage file
34 Require_stagefile .build/config .build/bootstrap
36 case "${LB_DERIVATIVE}" in
37 true)
38 _PARENT_FILE="sources.list.d/debian.list"
41 false)
42 _PARENT_FILE="sources.list"
44 esac
46 Echo_message "Configuring file /etc/apt/sources.list"
48 # Checking stage file
49 Check_stagefile .build/chroot_archives
51 # Checking lock file
52 Check_lockfile .lock
54 # Creating lock file
55 Create_lockfile .lock
57 # Restoring cache
58 Restore_cache cache/packages.chroot
60 # Configure custom sources.list
62 if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
63 then
64 Chroot_bind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
67 cat > chroot/etc/apt/${_PARENT_FILE} << EOF
68 deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}
69 EOF
71 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
72 then
73 echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
76 if [ "${LB_DERIVATIVE}" = "true" ]
77 then
78 rm -f chroot/etc/apt/sources.list.d/${LB_MODE}.list
80 _DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||')"
82 echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
84 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
85 then
86 echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
90 if [ "${LB_SECURITY}" = "true" ]
91 then
92 case "${LB_MODE}" in
93 debian|progress-linux)
94 case "${LB_PARENT_DISTRIBUTION}" in
95 sid)
100 echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
102 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
103 then
104 echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
107 esac
109 if [ "${LB_MODE}" = progress-linux ]
110 then
111 echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
113 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
114 then
115 echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
117 else
118 if [ "${LB_DERIVATIVE}" = "true" ]
119 then
120 echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
122 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
123 then
124 echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
130 ubuntu)
131 echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
133 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
134 then
135 echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
138 esac
141 if [ "${LB_UPDATES}" = "true" ]
142 then
143 echo "deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
145 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
146 then
147 echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
150 if [ "${LB_DERIVATIVE}" = "true" ]
151 then
152 echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
154 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
155 then
156 echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
161 if [ "${LB_BACKPORTS}" = "true" ]
162 then
163 case "${LB_MODE}" in
164 debian)
165 if [ "${LB_PARENT_DISTRIBUTION}" != "sid" ]
166 then
167 echo "deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
169 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
170 then
171 echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
175 esac
177 if [ "${LB_DERIVATIVE}" = "true" ]
178 then
179 echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
181 if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
182 then
183 echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
188 # Adding local apt sources (chroot)
189 for FILE in config/archives/*.list config/archives/*.list.chroot
191 if [ -e "${FILE}" ]
192 then
193 sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION}|g" \
194 -e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
195 -e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
196 -e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
197 "${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
199 if [ "${_PASS}" != "source" ] && [ "${LB_APT_SOURCE_ARCHIVES}" = "false" ]
200 then
201 # Strip out source archives
202 sed "/^deb-src /d" "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
205 done
207 # Adding local apt configuration (chroot)
208 for FILE in config/archives/*.conf config/archives/*.conf.chroot
210 if [ -e "${FILE}" ]
211 then
212 cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot)
214 done
216 # Adding local apt preferences (chroot)
217 for FILE in config/archives/*.pref config/archives/*.pref.chroot
219 if [ -e "${FILE}" ]
220 then
221 cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot)
223 done
225 # Check local archive keys
226 if Find_files config/archives/*.key || \
227 Find_files config/archives/*.key.chroot
228 then
229 for FILE in config/archives/*.key \
230 config/archives/*.key.chroot
232 if [ -e "${FILE}" ]
233 then
234 cp ${FILE} chroot/root
235 Chroot chroot "apt-key add /root/$(basename ${FILE})"
236 rm -f chroot/root/$(basename ${FILE})
238 done
241 # Check local keyring packages
242 if Find_files config/archives/*.deb
243 then
244 for PACKAGE in config/archives/*.deb
246 cp ${PACKAGE} chroot/root
247 Chroot chroot "dpkg -i /root/$(basename ${PACKAGE})"
248 rm -f chroot/root/$(basename ${PACKAGE})
249 done
252 # Installing aptitude
253 if [ "${LB_APT}" = "aptitude" ] && [ ! -x chroot/usr/bin/aptitude ]
254 then
255 Chroot chroot "apt-get ${APT_OPTIONS} update"
256 Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
259 # Rebuild apt indices from scratch.
260 # Due to the fact that apt doesn't understand
261 # pinning on the fly, we need to manually remove
262 # the cached indices and rebuild them again.
263 rm -rf chroot/var/cache/apt/*.bin
265 Apt chroot update
267 # Installing keyring packages
268 if [ -n "${LB_KEYRING_PACKAGES}" ]
269 then
270 Apt chroot "install ${LB_KEYRING_PACKAGES}"
273 rm -rf chroot/var/cache/apt/*.bin
275 Apt chroot update
276 Apt chroot "upgrade"
277 Apt chroot "dist-upgrade"
279 # Saving cache
280 Save_cache cache/packages.chroot
282 # Creating stage file
283 Create_stagefile .build/bootstrap_archives