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
|
|
|
|
2020-05-02 23:58:18 +00:00
|
|
|
# Processing arguments and configuration files
|
|
|
|
Init_config_data "${@}"
|
|
|
|
|
2011-08-24 18:34:01 +00:00
|
|
|
_PASS="${1}"
|
2020-03-18 15:56:57 -01:00
|
|
|
_ACTION="${2}"
|
|
|
|
shift 2
|
2011-08-24 18:34:01 +00:00
|
|
|
|
2020-03-10 16:35:03 -01:00
|
|
|
if ! In_list "${_PASS}" "binary" "chroot" "source"; then
|
2020-05-02 23:59:37 +00:00
|
|
|
Echo_error "Invalid pass parameter: '${_PASS}'"
|
2020-04-23 14:38:59 +00:00
|
|
|
Usage --fail
|
2020-02-22 00:06:40 -01:00
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Requiring stage file
|
2020-03-15 12:05:44 -01:00
|
|
|
Require_stagefiles config bootstrap
|
2020-03-12 00:21:39 -01:00
|
|
|
|
2020-03-18 15:56:57 -01:00
|
|
|
case "${_ACTION}" in
|
2007-09-23 08:04:46 +00:00
|
|
|
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
|
2020-03-13 16:11:53 -01:00
|
|
|
Check_stagefile
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2020-03-13 15:19:59 -01:00
|
|
|
# Acquire lock file
|
2015-02-05 02:30:47 -01:00
|
|
|
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
|
2020-03-18 15:55:37 -01:00
|
|
|
Create_apt_sources_list chroot "${_PASS}"
|
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
|
|
|
|
2021-09-15 08:53:04 +00:00
|
|
|
# Adding local apt auth (chroot)
|
|
|
|
# Note: .conf is assumed to be apt.conf, so use new suffix .auth
|
|
|
|
for FILE in config/archives/*.auth
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
cp ${FILE} chroot/etc/apt/auth.conf.d/$(basename ${FILE} .auth).conf
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Adding local apt auth (chroot)
|
|
|
|
# Note: .conf is assumed to be apt.conf, so use new suffix .auth
|
|
|
|
for FILE in config/archives/*.auth.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
cp ${FILE} chroot/etc/apt/auth.conf.d/$(basename ${FILE} .auth.chroot).conf
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
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
|
2023-12-01 14:59:31 -01:00
|
|
|
rm -rf chroot/packages
|
|
|
|
mkdir -p chroot/packages
|
2008-04-16 05:53:34 +00:00
|
|
|
|
2023-12-01 14:59:31 -01:00
|
|
|
if [ "$(stat --printf %d config/packages.chroot/)" = "$(stat --printf %d chroot/packages/)" ] ||
|
|
|
|
[ "$(stat --printf %d config/packages/)" = "$(stat --printf %d chroot/packages/)" ]
|
2008-08-07 17:45:24 +00:00
|
|
|
then
|
|
|
|
CP_OPTIONS="-l"
|
|
|
|
fi
|
|
|
|
|
2008-04-16 05:53:34 +00:00
|
|
|
# Copy packages
|
2020-04-01 09:58:47 +00:00
|
|
|
if Find_files config/packages.chroot/*_"${LB_ARCHITECTURE}".deb || Find_files config/packages/*_"${LB_ARCHITECTURE}".deb
|
2008-04-16 05:53:34 +00:00
|
|
|
then
|
2020-04-01 09:58:47 +00:00
|
|
|
for FILE in config/packages.chroot/*_"${LB_ARCHITECTURE}".deb config/packages/*_"${LB_ARCHITECTURE}".deb
|
2010-09-16 16:16:19 +00:00
|
|
|
do
|
|
|
|
if [ -L "${FILE}" ]
|
|
|
|
then
|
2023-12-01 14:59:31 -01:00
|
|
|
cp -L "${FILE}" chroot/packages
|
2011-09-07 15:33:53 +00:00
|
|
|
elif [ -e "${FILE}" ]
|
2011-09-07 15:37:37 +00:00
|
|
|
then
|
2023-12-01 14:59:31 -01:00
|
|
|
cp ${CP_OPTIONS} "${FILE}" chroot/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
|
2023-12-01 14:59:31 -01:00
|
|
|
cp -L "${FILE}" chroot/packages
|
2011-09-07 15:33:53 +00:00
|
|
|
elif [ -e "${FILE}" ]
|
2011-09-07 15:37:37 +00:00
|
|
|
then
|
2023-12-01 14:59:31 -01:00
|
|
|
cp ${CP_OPTIONS} "${FILE}" chroot/packages
|
2010-09-16 16:16:19 +00:00
|
|
|
fi
|
|
|
|
done
|
2008-04-16 05:53:34 +00:00
|
|
|
fi
|
|
|
|
|
2023-12-01 14:59:31 -01:00
|
|
|
if Find_files chroot/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
|
2020-05-05 15:42:44 +00:00
|
|
|
Install_packages
|
2008-06-15 01:55:33 +00:00
|
|
|
|
2011-09-07 15:33:53 +00:00
|
|
|
# Generate Packages and Packages.gz
|
2023-12-01 14:59:31 -01:00
|
|
|
echo "cd /packages && apt-ftparchive packages . > Packages" | Chroot chroot sh
|
|
|
|
gzip -9 -c chroot/packages/Packages > chroot/packages/Packages.gz
|
2008-07-04 23:40:20 +00:00
|
|
|
|
2008-08-14 00:39:03 +00:00
|
|
|
# Generate Release
|
2023-12-01 14:59:31 -01:00
|
|
|
echo "cd /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
|
2023-12-01 14:59:31 -01:00
|
|
|
echo "deb [ trusted=yes ] file:/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
|
2020-05-05 15:45:57 +00:00
|
|
|
Remove_packages
|
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
|
|
|
|
|
2023-12-01 14:59:31 -01:00
|
|
|
if Find_files chroot/packages/*.deb
|
2011-08-16 18:55:47 +00:00
|
|
|
then
|
2023-12-01 14:59:31 -01:00
|
|
|
gunzip < chroot/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-05-01 02:23:39 +00:00
|
|
|
if [ "${LB_APT}" = "aptitude" ] && ! command -v aptitude >/dev/null
|
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
|
2020-03-13 16:11:53 -01:00
|
|
|
Create_stagefile
|
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"
|
|
|
|
|
2020-03-13 15:19:59 -01:00
|
|
|
# Acquire lock file
|
2015-02-05 02:30:47 -01:00
|
|
|
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
|
2020-03-18 15:55:37 -01:00
|
|
|
Create_apt_sources_list binary "${_PASS}"
|
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
|
|
|
|
|
2021-09-15 08:53:04 +00:00
|
|
|
# Remve chroot-only apt auth
|
|
|
|
# Note: .conf is assumed to be apt.conf, so use new suffix .auth
|
|
|
|
for FILE in config/archives/*.auth.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
rm "chroot/etc/apt/auth.conf.d/$(basename ${FILE} .auth.chroot).conf"
|
|
|
|
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
|
|
|
|
|
2021-09-15 08:53:04 +00:00
|
|
|
# Adding local apt auth (chroot)
|
|
|
|
# Note: .conf is assumed to be apt.conf, so use new suffix .auth
|
|
|
|
for FILE in config/archives/*.auth.binary
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
|
|
|
cp ${FILE} chroot/etc/apt/auth.conf.d/$(basename ${FILE} .auth.binary).conf
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-12-04 10:04:47 -01:00
|
|
|
# Adding local apt keys (binary)
|
|
|
|
for FILE in config/archives/*.key config/archives/*.key.binary
|
|
|
|
do
|
|
|
|
if [ -e "${FILE}" ]
|
|
|
|
then
|
2023-01-05 07:20:28 -01:00
|
|
|
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
|
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
|
2023-12-01 14:59:31 -01:00
|
|
|
rm -rf chroot/packages
|
|
|
|
rm -f chroot/var/lib/apt/lists/_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
|
2020-03-13 16:11:53 -01:00
|
|
|
Remove_stagefile
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2020-05-02 12:41:01 +00:00
|
|
|
Echo_error "Invalid action parameter: '${_ACTION}'"
|
2020-04-23 14:38:59 +00:00
|
|
|
Usage --fail
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
esac
|