3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
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.
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')"
19 USAGE
="${PROGRAM} [--force]"
29 # Reading configuration files
30 Read_conffiles config
/all config
/common config
/bootstrap config
/chroot config
/binary config
/source
33 # Requiring stage file
34 Require_stagefile .build
/config .build
/bootstrap
36 case "${LB_DERIVATIVE}" in
38 _PARENT_FILE
="sources.list.d/debian.list"
42 _PARENT_FILE
="sources.list"
46 Echo_message
"Configuring file /etc/apt/sources.list"
49 Check_stagefile .build
/chroot_archives
58 Restore_cache cache
/packages.chroot
60 # Configure custom sources.list
62 if echo "${LB_PARENT_MIRROR_CHROOT}" |
grep -q '^file:/'
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}
71 if [ "${_PASS}" = "source" ] ||
[ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
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
" ]
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" ]
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
" ]
93 debian|progress-linux)
94 case "${LB_PARENT_DISTRIBUTION}" in
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" ]
104 echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
109 if [ "${LB_MODE}" = progress-linux ]
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" ]
115 echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
118 if [ "${LB_DERIVATIVE}" = "true
" ]
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" ]
124 echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
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" ]
135 echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
141 if [ "${LB_UPDATES}" = "true
" ]
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" ]
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
" ]
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" ]
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
" ]
165 if [ "${LB_PARENT_DISTRIBUTION}" != "sid
" ]
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" ]
171 echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
177 if [ "${LB_DERIVATIVE}" = "true
" ]
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" ]
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
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
" ]
201 # Strip out source archives
202 sed "/^deb-src
/d
" "chroot
/etc
/apt
/sources.list.d
/$
(basename ${FILE} .chroot
)"
207 # Adding local apt configuration (chroot)
208 for FILE in config/archives/*.conf config/archives/*.conf.chroot
212 cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot)
216 # Adding local apt preferences (chroot)
217 for FILE in config/archives/*.pref config/archives/*.pref.chroot
221 cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot)
225 # Check local archive keys
226 if Find_files config/archives/*.key || \
227 Find_files config/archives/*.key.chroot
229 for FILE in config/archives/*.key \
230 config/archives/*.key.chroot
234 cp ${FILE} chroot/root
235 Chroot chroot "apt-key add
/root
/$
(basename ${FILE})"
236 rm -f chroot/root/$(basename ${FILE})
241 # Check local keyring packages
242 if Find_files config/archives/*.deb
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})
252 # Installing aptitude
253 if [ "${LB_APT}" = "aptitude
" ] && [ ! -x chroot/usr/bin/aptitude ]
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
267 # Installing keyring packages
268 if [ -n "${LB_KEYRING_PACKAGES}" ]
270 Apt chroot "install ${LB_KEYRING_PACKAGES}"
273 rm -rf chroot/var/cache/apt/*.bin
277 Apt chroot "dist-upgrade
"
280 Save_cache cache/packages.chroot
282 # Creating stage file
283 Create_stagefile .build/bootstrap_archives