2007-09-23 08:04:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2020-03-11 09:07:21 -01:00
|
|
|
## Copyright (C) 2016-2020 The Debian Live team
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Including common functions
|
2012-08-27 13:52:29 +00:00
|
|
|
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Setting static variables
|
2015-02-05 02:30:47 -01:00
|
|
|
DESCRIPTION="Manage /etc/apt/sources.list"
|
2020-03-05 23:53:44 -01:00
|
|
|
USAGE="${PROGRAM} {source|binary|chroot} {install|remove} [--force]"
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2011-08-24 18:34:01 +00:00
|
|
|
_PASS="${1}"
|
|
|
|
shift
|
|
|
|
|
2020-03-10 16:35:03 -01:00
|
|
|
if ! In_list "${_PASS}" "binary" "chroot" "source"; then
|
2020-02-22 00:06:40 -01:00
|
|
|
Usage
|
|
|
|
fi
|
|
|
|
|
2015-02-05 02:30:47 -01:00
|
|
|
# Processing arguments and configuration files
|
|
|
|
Init_config_data "${@}"
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
# Requiring stage file
|
2012-06-03 20:42:41 +00:00
|
|
|
Require_stagefile .build/config .build/bootstrap
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
install)
|
2007-09-23 08:05:12 +00:00
|
|
|
Echo_message "Configuring file /etc/apt/sources.list"
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Checking stage file
|
2012-06-03 20:42:41 +00:00
|
|
|
Check_stagefile .build/chroot_archives
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2015-02-05 02:30:47 -01:00
|
|
|
# Aquire lock file
|
|
|
|
Acquire_lockfile
|
2007-09-23 08:04:50 +00:00
|
|
|
|
2010-06-23 16:30:13 +00:00
|
|
|
# Restoring cache
|
2015-01-06 02:46:37 -01:00
|
|
|
Restore_package_cache chroot
|
2010-06-23 16:30:13 +00:00
|
|
|
|
2015-01-05 20:25:01 -01:00
|
|
|
# Mount local repository
|
2020-02-10 14:48:49 -01:00
|
|
|
if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
|
|
|
|
then
|
|
|
|
Chroot_bind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
|
|
|
|
fi
|
2014-11-28 18:53:50 -01:00
|
|
|
|
2015-01-05 20:25:01 -01:00
|
|
|
# Configure custom sources.list
|
2015-02-05 02:33:14 -01:00
|
|
|
Create_apt_sources_list chroot
|
2010-09-16 12:15:30 +00:00
|
|
|
|
2012-12-04 10:04:47 -01:00
|
|
|
# Adding local apt sources (chroot)
|
|
|
|
for FILE in config/archives/*.list config/archives/*.list.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2019-12-19 16:18:44 -01:00
|
|
|
sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION_CHROOT}|g" \
|
|
|
|
-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION_CHROOT}|g" \
|
2014-12-10 05:41:29 -01:00
|
|
|
-e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
|
2014-12-10 07:19:07 -01:00
|
|
|
-e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
|
2012-12-04 10:04:47 -01:00
|
|
|
"${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
|
|
|
|
|
|
|
|
if [ "${_PASS}" != "source" ] && [ "${LB_APT_SOURCE_ARCHIVES}" = "false" ]
|
2012-07-18 19:03:20 +00:00
|
|
|
then
|
2020-02-25 01:33:50 -01:00
|
|
|
# Disable source archives
|
|
|
|
sed -i "s/^deb-src/#deb-src/g" "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
|
2012-07-18 19:03:20 +00:00
|
|
|
fi
|
2012-12-04 10:04:47 -01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-12-04 10:07:51 -01:00
|
|
|
# Adding local apt configuration (chroot)
|
|
|
|
for FILE in config/archives/*.conf config/archives/*.conf.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2014-12-10 05:56:10 -01:00
|
|
|
cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot)
|
2012-12-04 10:07:51 -01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-12-04 10:04:47 -01:00
|
|
|
# Adding local apt preferences (chroot)
|
|
|
|
for FILE in config/archives/*.pref config/archives/*.pref.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot)
|
|
|
|
fi
|
|
|
|
done
|
2012-07-18 19:03:20 +00:00
|
|
|
|
2019-10-03 14:38:54 +00:00
|
|
|
# Check local archive keys (chroot)
|
|
|
|
if Find_files config/archives/*.key || \
|
|
|
|
Find_files config/archives/*.key.chroot
|
|
|
|
then
|
|
|
|
for FILE in config/archives/*.key \
|
|
|
|
config/archives/*.key.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
if grep -q "PGP PUBLIC KEY BLOCK" "${FILE}"
|
|
|
|
then
|
|
|
|
cp ${FILE} chroot/etc/apt/trusted.gpg.d/$(basename ${FILE}).asc
|
|
|
|
else
|
|
|
|
cp ${FILE} chroot/etc/apt/trusted.gpg.d/$(basename ${FILE}).gpg
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2008-04-16 05:53:34 +00:00
|
|
|
# Configure local package repository
|
2011-09-07 15:33:53 +00:00
|
|
|
if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
|
2008-04-16 05:53:34 +00:00
|
|
|
then
|
2011-06-15 20:08:23 +00:00
|
|
|
rm -rf chroot/root/packages
|
|
|
|
mkdir -p chroot/root/packages
|
2008-04-16 05:53:34 +00:00
|
|
|
|
2015-08-10 19:45:00 +00:00
|
|
|
if [ "$(stat --printf %d config/packages.chroot/)" = "$(stat --printf %d chroot/root/packages/)" ] ||
|
|
|
|
[ "$(stat --printf %d config/packages/)" = "$(stat --printf %d chroot/root/packages/)" ]
|
2008-08-07 17:45:24 +00:00
|
|
|
then
|
|
|
|
CP_OPTIONS="-l"
|
|
|
|
fi
|
|
|
|
|
2008-04-16 05:53:34 +00:00
|
|
|
# Copy packages
|
2014-12-10 05:39:58 -01:00
|
|
|
if Find_files config/packages.chroot/*_"${LB_ARCHITECTURES}".deb || Find_files config/packages/*_"${LB_ARCHITECTURES}".deb
|
2008-04-16 05:53:34 +00:00
|
|
|
then
|
2014-12-10 05:39:58 -01:00
|
|
|
for FILE in config/packages.chroot/*_"${LB_ARCHITECTURES}".deb config/packages/*_"${LB_ARCHITECTURES}".deb
|
2010-09-16 16:16:19 +00:00
|
|
|
do
|
|
|
|
if [ -L "${FILE}" ]
|
|
|
|
then
|
2011-09-07 15:33:53 +00:00
|
|
|
cp -L "${FILE}" chroot/root/packages
|
|
|
|
elif [ -e "${FILE}" ]
|
2011-09-07 15:37:37 +00:00
|
|
|
then
|
2011-09-07 15:33:53 +00:00
|
|
|
cp ${CP_OPTIONS} "${FILE}" chroot/root/packages
|
2010-09-16 16:16:19 +00:00
|
|
|
fi
|
|
|
|
done
|
2008-04-16 05:53:34 +00:00
|
|
|
fi
|
|
|
|
|
2011-09-07 15:33:53 +00:00
|
|
|
if Find_files config/packages.chroot/*_all.deb || Find_files config/packages/*_all.deb
|
2008-04-16 05:53:34 +00:00
|
|
|
then
|
2011-09-07 15:33:53 +00:00
|
|
|
for FILE in config/packages.chroot/*_all.deb config/packages/*_all.deb
|
2010-09-16 16:16:19 +00:00
|
|
|
do
|
|
|
|
if [ -L "${FILE}" ]
|
|
|
|
then
|
2011-09-07 15:33:53 +00:00
|
|
|
cp -L "${FILE}" chroot/root/packages
|
|
|
|
elif [ -e "${FILE}" ]
|
2011-09-07 15:37:37 +00:00
|
|
|
then
|
2011-09-07 15:33:53 +00:00
|
|
|
cp ${CP_OPTIONS} "${FILE}" chroot/root/packages
|
2010-09-16 16:16:19 +00:00
|
|
|
fi
|
|
|
|
done
|
2008-04-16 05:53:34 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-15 20:08:23 +00:00
|
|
|
if Find_files chroot/root/packages/*.deb
|
2008-04-16 05:53:34 +00:00
|
|
|
then
|
2008-09-03 19:56:56 +00:00
|
|
|
# If we bootstrapped a minimal chroot, we need
|
2012-08-27 12:07:34 +00:00
|
|
|
# to install apt-utils before we have
|
2008-09-03 19:56:56 +00:00
|
|
|
# completed all the indices.
|
2012-08-27 12:07:34 +00:00
|
|
|
if [ ! -e chroot/usr/bin/apt-ftparchive ]
|
2012-07-28 22:24:11 +00:00
|
|
|
then
|
|
|
|
Apt chroot update
|
|
|
|
fi
|
2008-09-03 19:56:56 +00:00
|
|
|
|
2008-06-15 01:55:33 +00:00
|
|
|
# Check depends
|
2015-01-04 16:08:09 -01:00
|
|
|
Check_package chroot /usr/bin/apt-ftparchive apt-utils
|
2008-06-15 01:55:33 +00:00
|
|
|
|
|
|
|
# Installing depends
|
|
|
|
Install_package
|
|
|
|
|
2011-09-07 15:33:53 +00:00
|
|
|
# Generate Packages and Packages.gz
|
2011-06-15 20:08:23 +00:00
|
|
|
echo "cd /root/packages && apt-ftparchive packages . > Packages" | Chroot chroot sh
|
|
|
|
gzip -9 -c chroot/root/packages/Packages > chroot/root/packages/Packages.gz
|
2008-07-04 23:40:20 +00:00
|
|
|
|
2008-08-14 00:39:03 +00:00
|
|
|
# Generate Release
|
2011-06-15 20:08:23 +00:00
|
|
|
echo "cd /root/packages && apt-ftparchive \
|
2011-09-07 14:02:03 +00:00
|
|
|
-o APT::FTPArchive::Release::Origin=config/packages.chroot \
|
2008-11-14 14:11:13 -01:00
|
|
|
release . > Release" | Chroot chroot sh
|
2008-08-14 00:39:03 +00:00
|
|
|
|
2010-02-14 14:00:48 -01:00
|
|
|
# Add to sources.list.d
|
2016-10-27 14:16:19 +00:00
|
|
|
echo "deb [ trusted=yes ] file:/root/packages ./" > chroot/etc/apt/sources.list.d/packages.list
|
2008-06-15 01:55:33 +00:00
|
|
|
|
2011-10-03 10:38:51 +00:00
|
|
|
# Move top-level sources away, otherwise apt always preferes it (#644148)
|
2011-09-30 13:42:51 +00:00
|
|
|
if [ -e chroot/etc/apt/sources.list ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/sources.list chroot/etc/apt/sources.list.d/zz-sources.list
|
|
|
|
fi
|
2011-09-30 13:26:34 +00:00
|
|
|
|
2008-06-15 01:55:33 +00:00
|
|
|
# Removing depends
|
|
|
|
Remove_package
|
2008-04-16 05:53:34 +00:00
|
|
|
else
|
|
|
|
Echo_warning "Local packages must be named with suffix '_all.deb' or '_\$architecture.deb'."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-08-16 18:55:47 +00:00
|
|
|
if Find_files chroot/root/packages/*.deb
|
|
|
|
then
|
|
|
|
gunzip < chroot/root/packages/Packages.gz | awk '/^Package: / { print $2 }' \
|
2011-09-07 13:59:48 +00:00
|
|
|
>> chroot/root/packages.chroot
|
2011-08-16 18:55:47 +00:00
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:52 +00:00
|
|
|
# Update indices from cache
|
2012-06-04 08:52:28 +00:00
|
|
|
if [ "${LB_CACHE_INDICES}" = "true" ] && [ -d cache/indices.bootstrap ]
|
2007-09-23 08:04:49 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
if Find_files cache/indices.bootstrap/secring.gpg*
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f cache/indices.bootstrap/secring.gpg* chroot/etc/apt
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
if Find_files cache/indices.bootstrap/trusted.gpg*
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -rf cache/indices.bootstrap/trusted.gpg* chroot/etc/apt
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
2007-09-23 08:04:47 +00:00
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
if [ -f cache/indices.bootstrap/pkgcache.bin ]
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f cache/indices.bootstrap/pkgcache.bin chroot/var/cache/apt
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
if [ -f cache/indices.bootstrap/srcpkgcache.bin ]
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f cache/indices.bootstrap/srcpkgcache.bin chroot/var/cache/apt
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
if Find_files cache/indices.bootstrap/*_Packages
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f cache/indices.bootstrap/*_Packages chroot/var/lib/apt/lists
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
if Find_files cache/indices.bootstrap/*_Sources
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f cache/indices.bootstrap/*_Sources chroot/var/lib/apt/lists
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
if Find_files cache/indices.bootstrap/*Release*
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f cache/indices.bootstrap/*Release* chroot/var/lib/apt/lists
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-12 11:32:06 -01:00
|
|
|
if [ "${LB_APT}" = "aptitude" ] && [ ! $(which aptitude) ]
|
2007-09-23 08:04:46 +00:00
|
|
|
then
|
2011-04-23 15:44:01 +00:00
|
|
|
Chroot chroot "apt-get ${APT_OPTIONS} update"
|
2008-10-28 14:44:06 -01:00
|
|
|
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
|
2007-09-23 08:04:46 +00:00
|
|
|
fi
|
2007-09-23 08:04:52 +00:00
|
|
|
else # Get fresh indices
|
|
|
|
# Check local keyring packages
|
2011-06-15 19:01:48 +00:00
|
|
|
if Find_files config/archives/*.deb
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2011-06-15 19:01:48 +00:00
|
|
|
for PACKAGE in config/archives/*.deb
|
2007-09-23 08:04:52 +00:00
|
|
|
do
|
|
|
|
cp ${PACKAGE} chroot/root
|
2008-10-28 14:44:06 -01:00
|
|
|
Chroot chroot "dpkg -i /root/$(basename ${PACKAGE})"
|
2007-09-24 06:47:42 +00:00
|
|
|
rm -f chroot/root/$(basename ${PACKAGE})
|
2007-09-23 08:04:52 +00:00
|
|
|
done
|
|
|
|
fi
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2014-11-10 17:48:53 -01:00
|
|
|
# Installing aptitude
|
2020-02-22 13:33:01 -01:00
|
|
|
if [ "${LB_APT}" = "aptitude" ] && [ ! $(Chroot chroot "which aptitude") ]
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2008-10-28 14:44:06 -01:00
|
|
|
Chroot chroot "apt-get ${APT_OPTIONS} update"
|
|
|
|
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2011-04-23 16:13:58 +00:00
|
|
|
# Rebuild apt indices from scratch.
|
|
|
|
# Due to the fact that apt doesn't understand
|
|
|
|
# pinning on the fly, we need to manually remove
|
|
|
|
# the cached indices and rebuild them again.
|
|
|
|
rm -rf chroot/var/cache/apt/*.bin
|
2011-02-14 12:32:10 -01:00
|
|
|
|
2010-12-05 12:06:12 -01:00
|
|
|
Apt chroot update
|
2008-02-21 18:03:57 -01:00
|
|
|
|
2007-09-23 08:04:52 +00:00
|
|
|
# Installing keyring packages
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_KEYRING_PACKAGES}" ]
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2013-01-27 09:16:25 -01:00
|
|
|
Apt chroot "install ${LB_KEYRING_PACKAGES}"
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2011-04-23 16:13:58 +00:00
|
|
|
rm -rf chroot/var/cache/apt/*.bin
|
|
|
|
|
|
|
|
Apt chroot update
|
|
|
|
Apt chroot "upgrade"
|
|
|
|
Apt chroot "dist-upgrade"
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_CACHE_INDICES}" = "true" ]
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
mkdir -p cache/indices.bootstrap
|
2007-09-23 08:04:52 +00:00
|
|
|
|
2012-07-18 15:45:52 +00:00
|
|
|
if Find_files chroot/etc/apt/secring.gpg*
|
|
|
|
then
|
|
|
|
cp -f chroot/etc/apt/secring.gpg* cache/indices.bootstrap
|
|
|
|
fi
|
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -rf chroot/etc/apt/trusted.gpg* cache/indices.bootstrap
|
2007-09-23 08:04:52 +00:00
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f chroot/var/cache/apt/pkgcache.bin cache/indices.bootstrap
|
2008-06-09 08:04:44 +00:00
|
|
|
|
2008-08-09 01:20:56 +00:00
|
|
|
if Find_files chroot/var/cache/apt/srcpkgcache.bin
|
2008-06-09 08:04:44 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f chroot/var/cache/apt/srcpkgcache.bin cache/indices.bootstrap
|
2008-06-09 08:04:44 +00:00
|
|
|
fi
|
2007-09-23 08:04:52 +00:00
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f chroot/var/lib/apt/lists/*_Packages cache/indices.bootstrap
|
2008-06-09 08:04:44 +00:00
|
|
|
|
2008-08-09 01:20:56 +00:00
|
|
|
if Find_files chroot/var/lib/apt/lists/*_Sources
|
2008-06-09 08:04:44 +00:00
|
|
|
then
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f chroot/var/lib/apt/lists/*_Sources cache/indices.bootstrap
|
2008-06-09 08:04:44 +00:00
|
|
|
fi
|
|
|
|
|
2012-06-04 08:52:28 +00:00
|
|
|
cp -f chroot/var/lib/apt/lists/*Release* cache/indices.bootstrap
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
2007-09-23 08:04:49 +00:00
|
|
|
fi
|
|
|
|
|
2010-06-23 16:30:13 +00:00
|
|
|
# Saving cache
|
2015-01-06 02:46:37 -01:00
|
|
|
Save_package_cache chroot
|
2010-06-23 16:30:13 +00:00
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Creating stage file
|
2012-06-03 20:42:41 +00:00
|
|
|
Create_stagefile .build/chroot_archives
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
remove)
|
2007-09-23 08:05:12 +00:00
|
|
|
Echo_message "Deconfiguring file /etc/apt/sources.list"
|
|
|
|
|
2015-02-05 02:30:47 -01:00
|
|
|
# Aquire lock file
|
|
|
|
Acquire_lockfile
|
2007-09-23 08:04:50 +00:00
|
|
|
|
2011-09-30 13:26:34 +00:00
|
|
|
# Restore top-level sources
|
2011-09-30 13:42:51 +00:00
|
|
|
if [ -e chroot/etc/apt/sources.list.d/zz-sources.list ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/sources.list.d/zz-sources.list chroot/etc/apt/sources.list
|
|
|
|
fi
|
2011-09-30 13:26:34 +00:00
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Configure generic indices
|
2010-01-31 15:07:09 -01:00
|
|
|
# Cleaning apt list cache
|
|
|
|
rm -rf chroot/var/lib/apt/lists
|
|
|
|
mkdir -p chroot/var/lib/apt/lists/partial
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2011-02-14 12:32:10 -01:00
|
|
|
# Configure custom sources.list
|
2015-02-05 02:33:14 -01:00
|
|
|
Create_apt_sources_list binary
|
2010-09-16 12:15:30 +00:00
|
|
|
|
2013-09-17 11:28:00 +00:00
|
|
|
# Removing chroot-only apt sources
|
|
|
|
for FILE in config/archives/*.list.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
rm -f "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2013-09-18 08:48:21 +00:00
|
|
|
# Removing chroot-only apt configuration
|
|
|
|
for FILE in config/archives/*.conf.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2014-12-10 05:56:10 -01:00
|
|
|
rm -f "chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot)"
|
2013-09-18 08:48:21 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Removing chroot-only apt preferences
|
|
|
|
for FILE in config/archives/*.pref.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
rm -f "chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot)"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-12-04 10:04:47 -01:00
|
|
|
# Adding local apt sources (binary)
|
|
|
|
for FILE in config/archives/*.list config/archives/*.list.binary
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2019-12-19 16:18:44 -01:00
|
|
|
sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION_BINARY}|g" \
|
|
|
|
-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION_BINARY}|g" \
|
2014-12-10 05:41:29 -01:00
|
|
|
-e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
|
2014-12-10 07:19:07 -01:00
|
|
|
-e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
|
2012-12-04 10:04:47 -01:00
|
|
|
"${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .binary)"
|
|
|
|
|
|
|
|
if [ "${_PASS}" != "source" ] && [ "${LB_APT_SOURCE_ARCHIVES}" = "false" ]
|
2011-08-09 11:05:29 +00:00
|
|
|
then
|
2020-02-25 01:33:50 -01:00
|
|
|
# Disable source archives
|
|
|
|
sed -i "s/^deb-src/#deb-src/g" "chroot/etc/apt/sources.list.d/$(basename ${FILE} .binary)"
|
2011-08-09 11:05:29 +00:00
|
|
|
fi
|
2012-12-04 10:04:47 -01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-12-04 10:07:51 -01:00
|
|
|
# Adding local apt configuration (binary)
|
|
|
|
for FILE in config/archives/*.conf config/archives/*.conf.binary
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2014-12-10 05:56:10 -01:00
|
|
|
cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .binary)
|
2012-12-04 10:07:51 -01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-12-04 10:04:47 -01:00
|
|
|
# Adding local apt preferences (binary)
|
|
|
|
for FILE in config/archives/*.pref config/archives/*.pref.binary
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .binary)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Adding local apt keys (binary)
|
|
|
|
for FILE in config/archives/*.key config/archives/*.key.binary
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2018-06-01 13:29:05 +00:00
|
|
|
cp ${FILE} chroot/etc/apt/trusted.gpg.d/$(basename ${FILE}).asc
|
2012-12-04 10:04:47 -01:00
|
|
|
fi
|
|
|
|
done
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2010-01-31 15:07:09 -01:00
|
|
|
# Updating indices
|
2010-12-05 12:06:12 -01:00
|
|
|
Apt chroot update
|
2010-01-31 15:07:09 -01:00
|
|
|
|
2018-02-22 23:00:20 -01:00
|
|
|
# Unmount local repository - after apt update or it will fail due to missing files
|
|
|
|
if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
|
|
|
|
then
|
|
|
|
Chroot_unbind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
|
|
|
|
fi
|
|
|
|
|
2009-01-11 15:05:30 -01:00
|
|
|
# Cleaning apt package cache
|
2007-09-23 08:04:47 +00:00
|
|
|
rm -rf chroot/var/cache/apt
|
|
|
|
mkdir -p chroot/var/cache/apt/archives/partial
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2009-02-13 08:17:29 -01:00
|
|
|
# Cleaning apt package lists
|
2010-11-21 15:17:48 -01:00
|
|
|
if [ "${LB_APT_INDICES}" = "false" ]
|
2009-02-13 08:17:29 -01:00
|
|
|
then
|
|
|
|
rm -rf chroot/var/lib/apt/lists
|
|
|
|
mkdir -p chroot/var/lib/apt/lists/partial
|
|
|
|
fi
|
2009-01-11 15:05:30 -01:00
|
|
|
|
2008-04-16 05:53:34 +00:00
|
|
|
# Remove local package repository
|
2011-06-15 20:08:23 +00:00
|
|
|
rm -f chroot/etc/apt/sources.list.d/packages.list
|
|
|
|
rm -rf chroot/root/packages
|
2008-04-16 05:53:34 +00:00
|
|
|
|
2015-01-22 11:39:22 -01:00
|
|
|
# Ensure package list is removed
|
|
|
|
rm -f chroot/root/packages.chroot
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Removing stage file
|
2012-06-03 20:42:41 +00:00
|
|
|
rm -f .build/chroot_archives
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2007-09-23 08:04:48 +00:00
|
|
|
Usage
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
esac
|