3
## live-build(7) - System Build Scripts
4
## Copyright (C) 2006-2011 Daniel Baumann <daniel@debian.org>
6
## live-build 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
. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
16
# Setting static variables
17
DESCRIPTION="$(Echo 'manage /etc/apt/sources.list')"
19
USAGE="${PROGRAM} {install|remove} [--force]"
23
# Reading configuration files
24
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
27
# Requiring stage file
28
Require_stagefile .stage/config .stage/bootstrap
30
_LB_LOCAL_KEY_EMAIL="live-build-local-key@invalid"
34
Echo_message "Configuring file /etc/apt/sources.list"
37
Check_stagefile .stage/chroot_archives
46
Restore_cache cache/packages_chroot
48
# Configure custom sources.list
50
cat > chroot/etc/apt/sources.list << EOF
51
# /etc/apt/sources.list
53
deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}
56
if [ "${LB_SOURCE}" = "true" ]
58
echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
61
if [ "${LB_DERIVATIVE}" = "true" ]
64
cat > chroot/etc/apt/sources.list.d/${LB_MODE}.list << EOF
65
# /etc/apt/sources.list.d/${LB_MODE}.list
69
case "${LB_DISTRIBUTION}" in
71
_DISTRIBUTIONS="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||') ${LB_DISTRIBUTION}"
75
_DISTRIBUTIONS="${LB_DISTRIBUTION}"
79
for _DISTRIBUTION in ${_DISTRIBUTIONS}
82
echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
84
if [ "${LB_SOURCE}" = "true" ]
86
echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
91
if [ "${LB_SECURITY}" = "true" ]
95
case "${LB_PARENT_DISTRIBUTION}" in
101
echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
103
if [ "${LB_SOURCE}" = "true" ]
105
echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
110
if [ "${LB_MODE}" = progress ]
112
case "${LB_DISTRIBUTION}" in
118
echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${LB_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
120
if [ "${LB_SOURCE}" = "true" ]
122
echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${LB_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
127
if [ "${LB_DERIVATIVE}" = "true" ]
129
echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${LB_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
131
if [ "${LB_SOURCE}" = "true" ]
133
echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${LB_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
140
echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
142
if [ "${LB_SOURCE}" = "true" ]
144
echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
150
if [ "${LB_VOLATILE}" = "true" ]
154
echo "deb ${LB_PARENT_MIRROR_CHROOT_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
156
if [ "${LB_SOURCE}" = "true" ]
158
echo "deb-src ${LB_PARENT_MIRROR_CHROOT_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
163
if [ "${LB_DERIVATIVE}" = "true" ] && [ "${LB_MIRROR_CHROOT_VOLATILE}" != "none" ]
165
echo "deb ${LB_MIRROR_CHROOT_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
167
if [ "${LB_SOURCE}" = "true" ]
169
echo "deb-src ${LB_PARENT_MIRROR_CHROOT_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
174
if [ "${LB_BACKPORTS}" = "true" ]
178
if [ "${LB_PARENT_DISTRIBUTION}" != "sid" ]
180
echo "deb ${LB_PARENT_MIRROR_CHROOT_BACKPORTS} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
182
if [ "${LB_SOURCE}" = "true" ]
184
echo "deb-src ${LB_PARENT_MIRROR_CHROOT_BACKPORTS} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
190
if [ "${LB_DERIVATIVE}" = "true" ] && [ "${LB_MIRROR_CHROOT_BACKPORTS}" != "none" ]
192
echo "deb ${LB_MIRROR_CHROOT_BACKPORTS} ${LB_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
194
if [ "${LB_SOURCE}" = "true" ]
196
echo "deb-src ${LB_MIRROR_CHROOT_BACKPORTS} ${LB_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
201
# Configure third-party archives
202
if [ -n "${LB_ARCHIVES}" ]
204
for REPOSITORY in ${LB_ARCHIVES}
206
# ubuntu workaround to allow using live.debian.net
207
if [ "${LB_MODE}" = "ubuntu" ] && [ "${REPOSITORY}" = "live.debian.net" ]
211
_DISTRIBUTION="${LB_PARENT_DISTRIBUTION}"
214
# Prefer archives from the config tree
215
# over the global ones.
216
if ! ls "${LB_BASE}/archives/${REPOSITORY}"* > /dev/null 2>&1
221
# Adding sources.list entries (chroot)
222
if [ -e "${LB_BASE}/archives/${REPOSITORY}.chroot" ]
224
sed -e "s|@DISTRIBUTION@|${_DISTRIBUTION}|g" \
225
-e "s|@ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
226
"${LB_BASE}/archives/${REPOSITORY}.chroot" > \
227
"chroot/etc/apt/sources.list.d/${REPOSITORY}.list"
228
elif [ -e "${LB_BASE}/archives/${REPOSITORY}" ]
230
sed -e "s|@DISTRIBUTION@|${_DISTRIBUTION}|g" \
231
-e "s|@ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
232
"${LB_BASE}/archives/${REPOSITORY}" > \
233
"chroot/etc/apt/sources.list.d/${REPOSITORY}.list"
236
if [ "${LB_APT_SECURE}" != false ]
238
# Adding archive signing keys (chroot)
239
if [ -e "${LB_BASE}/archives/${REPOSITORY}.chroot.key" ]
241
cat "${LB_BASE}/archives/${REPOSITORY}.chroot.key" | Chroot chroot "apt-key add -"
242
elif [ -e "${LB_BASE}/archives/${REPOSITORY}.key" ]
244
cat "${LB_BASE}/archives/${REPOSITORY}.key" | Chroot chroot "apt-key add -"
250
# Check local sources.list
251
if Find_files config/archives/*.chroot.list
253
for FILE in config/archives/*.chroot.list
255
sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION}|g" \
256
-e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
257
-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
258
-e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
259
"${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot.list).list"
263
# Configure local package repository
264
if Find_files config/chroot_packages/*.deb
266
rm -rf chroot/root/packages
267
mkdir -p chroot/root/packages
269
if [ "$(stat --printf %d config/chroot_packages)" = "$(stat --printf %d chroot/root/packages)" ]
275
if Find_files config/chroot_packages/*_"${LB_ARCHITECTURES}".deb
277
for FILE in config/chroot_packages/*_"${LB_ARCHITECTURES}".deb
281
cp -L config/chroot_packages/*_"${LB_ARCHITECTURES}".deb chroot/root/packages
283
cp ${CP_OPTIONS} config/chroot_packages/*_"${LB_ARCHITECTURES}".deb chroot/root/packages
288
if Find_files config/chroot_packages/*_all.deb
290
for FILE in config/chroot_packages/*_all.deb
294
cp -L config/chroot_packages/*_all.deb chroot/root/packages
296
cp ${CP_OPTIONS} config/chroot_packages/*_all.deb chroot/root/packages
301
if Find_files chroot/root/packages/*.deb
303
# If we bootstrapped a minimal chroot, we need
304
# to install apt-utils before we have have
305
# completed all the indices.
306
case "${LB_PACKAGE_LISTS}" in
313
Check_package chroot/usr/bin/apt-ftparchive apt-utils
318
# Generate Packages and Packages.gz
319
echo "cd /root/packages && apt-ftparchive packages . > Packages" | Chroot chroot sh
320
gzip -9 -c chroot/root/packages/Packages > chroot/root/packages/Packages.gz
323
echo "cd /root/packages && apt-ftparchive \
324
-o APT::FTPArchive::Release::Origin=chroot_packages \
325
release . > Release" | Chroot chroot sh
327
if [ "${LB_APT_SECURE}" = "true" ]
329
_LB_DOTGNUPG_EXISTED=0
330
if [ -d chroot/root/.gnupg ]
332
_LB_DOTGNUPG_EXISTED=1
335
# Ensure ~/.gnupg exists (required for gnupg >= ~1.4.9)
336
mkdir -p chroot/root/.gnupg
338
# Temporarily replace /dev/random with /dev/urandom so as not
339
# to block automated image builds; we don't care about the
340
# security of this key anyway.
341
if [ -e chroot/dev/random ]
343
mv chroot/dev/random chroot/dev/random.orig
344
cp -a chroot/dev/urandom chroot/dev/random
347
if Find_files cache/local-package-keyring.*
349
cp cache/local-package-keyring.* chroot/root
351
# Generate temporary key
356
Name-Real: live-build local packages key
357
Name-Email: ${_LB_LOCAL_KEY_EMAIL}
359
%secring /root/local-package-keyring.sec
360
%pubring /root/local-package-keyring.pub
361
%commit" | Chroot chroot "gpg --batch --gen-key" || _LB_RET=${?}
365
# Gnupg sometimes seems to return with a status of 2 when there was not
366
# enough entropy (and key creation blocks temporarily) even if the
367
# operation was ultimately successful.
370
Echo_error "GPG exited with error status %s" "${_LB_RET}"
375
# Save keyrings to avoid regeneration
376
cp chroot/root/local-package-keyring.* cache/
380
Chroot chroot "gpg --no-default-keyring --secret-keyring /root/local-package-keyring.sec \
381
--keyring /root/local-package-keyring.pub -abs -o \
382
/root/packages/Release.gpg /root/packages/Release"
385
Chroot chroot "gpg --no-default-keyring --secret-keyring /root/local-package-keyring.sec \
386
--keyring /root/local-package-keyring.pub --armor \
387
--export ${_LB_LOCAL_KEY_EMAIL}" | Chroot chroot "apt-key add -"
389
# Remove temporary keyrings
390
rm chroot/root/local-package-keyring.pub
391
rm chroot/root/local-package-keyring.sec
394
if [ -e chroot/dev/random.orig ]
396
mv chroot/dev/random.orig chroot/dev/random
399
# Remove /root/.gnupg if we created it during the signing process
400
if [ "${_LB_DOTGNUPG_EXISTED}" -eq 0 ]
402
rm -rf chroot/root/.gnupg
406
# Add to sources.list.d
407
echo "deb file:/root/packages ./" > chroot/etc/apt/sources.list.d/packages.list
412
Echo_warning "Local packages must be named with suffix '_all.deb' or '_\$architecture.deb'."
416
# Update indices from cache
417
if [ "${LB_CACHE_INDICES}" = "true" ] && [ -d cache/indices_bootstrap ]
419
if Find_files cache/indices_bootstrap/secring.gpg*
421
cp -f cache/indices_bootstrap/secring.gpg* chroot/etc/apt
424
if Find_files cache/indices_bootstrap/trusted.gpg*
426
cp -rf cache/indices_bootstrap/trusted.gpg* chroot/etc/apt
429
if [ -f cache/indices_bootstrap/pkgcache.bin ]
431
cp -f cache/indices_bootstrap/pkgcache.bin chroot/var/cache/apt
434
if [ -f cache/indices_bootstrap/srcpkgcache.bin ]
436
cp -f cache/indices_bootstrap/srcpkgcache.bin chroot/var/cache/apt
439
if Find_files cache/indices_bootstrap/*_Packages
441
cp -f cache/indices_bootstrap/*_Packages chroot/var/lib/apt/lists
444
if Find_files cache/indices_bootstrap/*_Sources
446
cp -f cache/indices_bootstrap/*_Sources chroot/var/lib/apt/lists
449
if Find_files cache/indices_bootstrap/*Release*
451
cp -f cache/indices_bootstrap/*Release* chroot/var/lib/apt/lists
454
if [ "${LB_APT}" = "aptitude" ] && [ ! -x /usr/bin/aptitude ]
456
Chroot chroot "apt-get ${APT_OPTIONS} update"
457
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
459
else # Get fresh indices
460
# Check local archive keys
461
if Find_files config/archives/*.chroot.key
463
for FILE in config/archives/*.chroot.key
465
cp ${FILE} chroot/root
466
Chroot chroot "apt-key add /root/$(basename ${FILE})"
467
rm -f chroot/root/$(basename ${FILE})
471
# Check local keyring packages
472
if Find_files config/archives/*.deb
474
for PACKAGE in config/archives/*.deb
476
cp ${PACKAGE} chroot/root
477
Chroot chroot "dpkg -i /root/$(basename ${PACKAGE})"
478
rm -f chroot/root/$(basename ${PACKAGE})
482
# Installing aptitude (FIXME)
483
if [ "${LB_APT}" = "aptitude" ] && [ ! -x /usr/bin/aptitude ]
485
Chroot chroot "apt-get ${APT_OPTIONS} update"
486
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
489
# Rebuild apt indices from scratch.
490
# Due to the fact that apt doesn't understand
491
# pinning on the fly, we need to manually remove
492
# the cached indices and rebuild them again.
493
rm -rf chroot/var/cache/apt/*.bin
497
# Installing keyring packages
498
if [ -n "${LB_KEYRING_PACKAGES}" ]
500
if [ "${LB_DERIVATIVE}" = "true" ]
502
# Temporary hack (FIXME)
503
Chroot chroot "apt-get ${APT_OPTIONS} --force-yes install ${LB_KEYRING_PACKAGES}"
505
Apt chroot "install ${LB_KEYRING_PACKAGES}"
509
rm -rf chroot/var/cache/apt/*.bin
513
Apt chroot "dist-upgrade"
515
if [ "${LB_CACHE_INDICES}" = "true" ]
517
mkdir -p cache/indices_bootstrap
519
cp -f chroot/etc/apt/secring.gpg* cache/indices_bootstrap
520
cp -rf chroot/etc/apt/trusted.gpg* cache/indices_bootstrap
522
cp -f chroot/var/cache/apt/pkgcache.bin cache/indices_bootstrap
524
if Find_files chroot/var/cache/apt/srcpkgcache.bin
526
cp -f chroot/var/cache/apt/srcpkgcache.bin cache/indices_bootstrap
529
cp -f chroot/var/lib/apt/lists/*_Packages cache/indices_bootstrap
531
if Find_files chroot/var/lib/apt/lists/*_Sources
533
cp -f chroot/var/lib/apt/lists/*_Sources cache/indices_bootstrap
536
cp -f chroot/var/lib/apt/lists/*Release* cache/indices_bootstrap
541
Save_cache cache/packages_chroot
543
# Creating stage file
544
Create_stagefile .stage/chroot_archives
548
Echo_message "Deconfiguring file /etc/apt/sources.list"
554
Create_lockfile .lock
556
# Configure generic indices
557
# Don't do anything if it's not required
558
if [ "${LB_PARENT_MIRROR_CHROOT}" = "${LB_PARENT_MIRROR_BINARY}" ] && \
559
[ "${LB_PARENT_MIRROR_CHROOT_SECURITY}" = "${LB_PARENT_MIRROR_BINARY_SECURITY}" ] && \
560
[ ! -d chroot/root/packages ]
562
# Removing stage file
563
rm -f .stage/chroot_archives
568
# Cleaning apt list cache
569
rm -rf chroot/var/lib/apt/lists
570
mkdir -p chroot/var/lib/apt/lists/partial
572
# Configure custom sources.list
574
cat > chroot/etc/apt/sources.list << EOF
575
# /etc/apt/sources.list
577
deb ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}
580
if [ "${LB_SOURCE}" = "true" ]
582
echo "deb-src ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
585
if [ "${LB_DERIVATIVE}" = "true" ]
588
cat > chroot/etc/apt/sources.list.d/${LB_MODE}.list << EOF
589
# /etc/apt/sources.list.d/${LB_MODE}.list
593
case "${LB_DISTRIBUTION}" in
595
_DISTRIBUTIONS="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||') ${LB_DISTRIBUTION}"
599
_DISTRIBUTIONS="${LB_DISTRIBUTION}"
603
for _DISTRIBUTION in ${_DISTRIBUTIONS}
606
echo "deb ${LB_MIRROR_BINARY} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
608
if [ "${LB_SOURCE}" = "true" ]
610
echo "deb-src ${LB_MIRROR_BINARY} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
615
if [ "${LB_SECURITY}" = "true" ]
619
case "${LB_PARENT_DISTRIBUTION}" in
625
echo "deb ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
627
if [ "${LB_SOURCE}" = "true" ]
629
echo "deb-src ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
634
if [ "${LB_MODE}" = progress ]
636
case "${LB_DISTRIBUTION}" in
642
echo "deb ${LB_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
644
if [ "${LB_SOURCE}" = "true" ]
646
echo "deb-src ${LB_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
651
if [ "${LB_DERIVATIVE}" = "true" ]
653
echo "deb ${LB_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
655
if [ "${LB_SOURCE}" = "true" ]
657
echo "deb-src ${LB_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
664
echo "deb ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
666
if [ "${LB_SOURCE}" = "true" ]
668
echo "deb-src ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
674
if [ "${LB_VOLATILE}" = "true" ]
678
echo "deb ${LB_PARENT_MIRROR_BINARY_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
680
if [ "${LB_SOURCE}" = "true" ]
682
echo "deb-src ${LB_PARENT_MIRROR_BINARY_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
687
if [ "${LB_DERIVATIVE}" = "true" ] && [ "${LB_MIRROR_BINARY_VOLATILE}" != "none" ]
689
echo "deb ${LB_MIRROR_BINARY_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
691
if [ "${LB_SOURCE}" = "true" ]
693
echo "deb-src ${LB_PARENT_MIRROR_BINARY_VOLATILE} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
698
if [ "${LB_BACKPORTS}" = "true" ]
702
if [ "${LB_PARENT_DISTRIBUTION}" != "sid" ]
704
echo "deb ${LB_PARENT_MIRROR_BINARY_BACKPORTS} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
706
if [ "${LB_SOURCE}" = "true" ]
708
echo "deb-src ${LB_PARENT_MIRROR_BINARY_BACKPORTS} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list
714
if [ "${LB_DERIVATIVE}" = "true" ] && [ "${LB_MIRROR_BINARY_BACKPORTS}" != "none" ]
716
echo "deb ${LB_MIRROR_BINARY_BACKPORTS} ${LB_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
718
if [ "${LB_SOURCE}" = "true" ]
720
echo "deb-src ${LB_MIRROR_BINARY_BACKPORTS} ${LB_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
725
# Configure third-party archives
726
if [ -n "${LB_ARCHIVES}" ]
728
for REPOSITORY in ${LB_ARCHIVES}
730
# Removing sources.list entries (chroot)
731
rm -f "chroot/etc/apt/sources.list.d/${REPOSITORY}.list"
733
# Prefer archives from the config tree
734
# over the global ones.
735
if ! ls "${LB_BASE}/archives/${REPOSITORY}"* > /dev/null 2>&1
740
# Adding sources.list entries (binary)
741
if [ -e "${LB_BASE}/archives/${REPOSITORY}.binary" ]
743
sed -e "s|@DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
744
-e "s|@ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
745
"${LB_BASE}/archives/${REPOSITORY}.binary" > \
746
"chroot/etc/apt/sources.list.d/${REPOSITORY}.list"
747
elif [ -e "${LB_BASE}/archives/${REPOSITORY}" ]
749
sed -e "s|@DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
750
-e "s|@ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
751
"${LB_BASE}/archives/${REPOSITORY}" > \
752
"chroot/etc/apt/sources.list.d/${REPOSITORY}.list"
755
if [ "${LB_APT_SECURE}" != false ]
757
# Adding archive signing keys (binary)
758
if [ -e "${LB_BASE}/archives/${REPOSITORY}.binary.key" ]
760
cat "${LB_BASE}/archives/${REPOSITORY}.binary.key" | Chroot chroot "apt-key add -"
761
elif [ -e "${LB_BASE}/archives/${REPOSITORY}.key" ]
763
cat "${LB_BASE}/archives/${REPOSITORY}.key" | Chroot chroot "apt-key add -"
769
# Check local sources.list
770
if Find_files config/archives/*.binary.list
772
for FILE in config/archives/*.binary.list
774
sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION}|g" \
775
-e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
776
-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
777
-e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
778
"${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .binary.list).list"
782
# Check local archive keys
783
if Find_files config/archives/*.binary.key
785
for FILE in config/archives/*.binary.key
787
cp ${FILE} chroot/root
788
Chroot chroot "apt-key add /root/$(basename ${FILE})"
789
rm -f chroot/root/$(basename ${FILE})
796
# Cleaning apt package cache
797
rm -rf chroot/var/cache/apt
798
mkdir -p chroot/var/cache/apt/archives/partial
800
# Cleaning apt package lists
801
if [ "${LB_APT_INDICES}" = "false" ]
803
rm -rf chroot/var/lib/apt/lists
804
mkdir -p chroot/var/lib/apt/lists/partial
807
# Remove local package repository
808
rm -f chroot/etc/apt/sources.list.d/packages.list
809
rm -rf chroot/root/packages
811
# Remove local packages key if it exists
812
if apt-key list | grep -q ${_LB_LOCAL_KEY_EMAIL}
814
apt-key del ${_LB_LOCAL_KEY_EMAIL}
817
# Removing stage file
818
rm -f .stage/chroot_archives