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/apt.conf"
|
2008-08-14 00:39:48 +00:00
|
|
|
USAGE="${PROGRAM} {install|install-binary|remove} [--force]"
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2015-02-05 02:30:47 -01:00
|
|
|
# Processing arguments and configuration files
|
|
|
|
Init_config_data "${@}"
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2020-05-02 23:58:18 +00:00
|
|
|
_ACTION="${1}"
|
|
|
|
shift
|
|
|
|
|
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-04-04 17:59:11 +00:00
|
|
|
CONFD="chroot/etc/apt/apt.conf.d"
|
|
|
|
|
2020-05-02 12:41:01 +00:00
|
|
|
case "${_ACTION}" in
|
2008-08-14 00:39:48 +00:00
|
|
|
install|install-binary)
|
2007-09-23 08:05:12 +00:00
|
|
|
Echo_message "Configuring file /etc/apt/apt.conf"
|
|
|
|
|
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:48 +00:00
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
mkdir -p ${CONFD}
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Configuring apt pipeline
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_APT_PIPELINE}" ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "Acquire::http::Pipeline-Depth \"${LB_APT_PIPELINE}\";" > ${CONFD}/00pipeline
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Configuring apt recommends
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_APT_RECOMMENDS}" in
|
2009-12-13 19:17:45 -01:00
|
|
|
true)
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "APT::Install-Recommends \"true\";" > ${CONFD}/00recommends
|
|
|
|
echo "Aptitude::Recommends-Important \"true\";" >> ${CONFD}/00recommends
|
2007-09-23 08:05:17 +00:00
|
|
|
;;
|
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
false)
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "APT::Install-Recommends \"false\";" > ${CONFD}/00recommends
|
|
|
|
echo "Aptitude::Recommends-Important \"false\";" >> ${CONFD}/00recommends
|
2007-09-23 08:05:17 +00:00
|
|
|
;;
|
|
|
|
esac
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:04:48 +00:00
|
|
|
# Configuring apt secure
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_APT_SECURE}" in
|
2009-12-13 19:17:45 -01:00
|
|
|
true)
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "APT::Get::AllowUnauthenticated \"false\";" > ${CONFD}/00secure
|
|
|
|
echo "Aptitude::CmdLine::Ignore-Trust-Violations \"false\";" >> ${CONFD}/00secure
|
|
|
|
echo "Acquire::AllowInsecureRepositories \"false\";" >> ${CONFD}/00secure
|
2007-09-23 08:04:50 +00:00
|
|
|
;;
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
false)
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "APT::Get::AllowUnauthenticated \"true\";" > ${CONFD}/00secure
|
|
|
|
echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> ${CONFD}/00secure
|
|
|
|
echo "Acquire::AllowInsecureRepositories \"true\";" >> ${CONFD}/00secure
|
2007-09-23 08:04:50 +00:00
|
|
|
;;
|
|
|
|
esac
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2009-01-09 14:17:31 -01:00
|
|
|
# Configuring apt config
|
2020-04-04 17:59:11 +00:00
|
|
|
CONFIG_FILE="config/apt/apt.conf"
|
|
|
|
CHROOT_FILE="chroot/etc/apt/apt.conf"
|
|
|
|
if [ -f ${CONFIG_FILE} ]; then
|
|
|
|
if [ -f ${CHROOT_FILE} ]; then
|
|
|
|
mv ${CHROOT_FILE} ${CHROOT_FILE}.orig
|
2009-01-09 14:17:31 -01:00
|
|
|
fi
|
2020-04-04 17:59:11 +00:00
|
|
|
cp ${CONFIG_FILE} ${CHROOT_FILE}
|
2009-01-09 14:17:31 -01:00
|
|
|
fi
|
|
|
|
|
2007-10-14 19:47:35 +00:00
|
|
|
# Configuring apt preferences
|
2020-04-04 17:59:11 +00:00
|
|
|
CONFIG_FILE="config/apt/preferences"
|
|
|
|
CHROOT_FILE="chroot/etc/apt/preferences"
|
|
|
|
if [ -f ${CONFIG_FILE} ]; then
|
|
|
|
if [ -f ${CHROOT_FILE} ]; then
|
|
|
|
mv ${CHROOT_FILE} ${CHROOT_FILE}.orig
|
2007-10-14 19:47:35 +00:00
|
|
|
fi
|
2020-04-04 17:59:11 +00:00
|
|
|
cp ${CONFIG_FILE} ${CHROOT_FILE}
|
2007-10-14 19:47:35 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
if Find_files config/apt/*.pref; then
|
|
|
|
for CONFIG_FILE in config/apt/*.pref; do
|
|
|
|
CHROOT_FILE="chroot/etc/apt/preferences.d/$(basename ${CONFIG_FILE})"
|
|
|
|
if [ -f ${CHROOT_FILE} ]; then
|
|
|
|
mv ${CHROOT_FILE} ${CHROOT_FILE}.orig
|
2012-01-07 17:47:41 -01:00
|
|
|
fi
|
2020-04-04 17:59:11 +00:00
|
|
|
cp -aL ${CONFIG_FILE} chroot/etc/apt/preferences.d
|
2012-01-07 17:47:41 -01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2011-09-07 15:33:53 +00:00
|
|
|
if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
|
2008-08-10 06:03:27 +00:00
|
|
|
then
|
2020-04-04 17:59:11 +00:00
|
|
|
CHROOT_FILE="chroot/etc/apt/preferences"
|
|
|
|
echo >> ${CHROOT_FILE}
|
2020-05-18 23:14:20 +00:00
|
|
|
echo "# Added by lb_chroot_apt ${_ACTION} ${@}" >> ${CHROOT_FILE}
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "Package: *" >> ${CHROOT_FILE}
|
|
|
|
echo "Pin: release o=config/packages.chroot" >> ${CHROOT_FILE}
|
2008-08-12 18:17:39 +00:00
|
|
|
|
2020-05-18 23:14:20 +00:00
|
|
|
case "${_ACTION}" in
|
2008-08-12 18:17:39 +00:00
|
|
|
install)
|
|
|
|
# Ensure local packages have priority
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "Pin-Priority: 1001" >> ${CHROOT_FILE}
|
2008-08-12 18:17:39 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
install-binary)
|
2010-11-23 08:36:48 -01:00
|
|
|
# Ensure local packages are not re-installed during lb_binary
|
2020-04-04 17:59:11 +00:00
|
|
|
echo "Pin-Priority: 99" >> ${CHROOT_FILE}
|
2008-08-12 18:17:39 +00:00
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
echo >> ${CHROOT_FILE}
|
|
|
|
echo "Package: *" >> ${CHROOT_FILE}
|
|
|
|
echo "Pin: release o=debian" >> ${CHROOT_FILE}
|
|
|
|
echo "Pin-Priority: 99" >> ${CHROOT_FILE}
|
2008-08-12 18:17:39 +00:00
|
|
|
;;
|
|
|
|
esac
|
2008-08-10 06:03:27 +00:00
|
|
|
fi
|
|
|
|
|
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/apt.conf"
|
|
|
|
|
2020-04-02 19:23:57 +00:00
|
|
|
# Checking stage file
|
|
|
|
Ensure_stagefile_exists
|
|
|
|
|
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:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Deconfiguring aptitude pipeline
|
2020-04-04 17:59:11 +00:00
|
|
|
rm -f ${CONFD}/00pipeline
|
2007-09-23 08:05:11 +00:00
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Deconfiguring aptitude recommends
|
2020-04-04 17:59:11 +00:00
|
|
|
if [ "${LB_APT_RECOMMENDS}" = "true" ]; then
|
|
|
|
rm -f ${CONFD}/00recommends
|
2008-08-16 01:15:40 +00:00
|
|
|
fi
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:04:48 +00:00
|
|
|
# Deconfiguring aptitude secure
|
2020-04-04 17:59:11 +00:00
|
|
|
if [ "${LB_APT_SECURE}" = "true" ]; then
|
|
|
|
rm -f ${CONFD}/00secure
|
2008-08-16 01:15:40 +00:00
|
|
|
fi
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2009-01-09 14:17:31 -01:00
|
|
|
# Configuring apt config
|
2020-04-04 17:59:11 +00:00
|
|
|
CONFIG_FILE="config/apt/apt.conf"
|
|
|
|
CHROOT_FILE="chroot/etc/apt/apt.conf"
|
|
|
|
if [ -f ${CONFIG_FILE} ]; then
|
2020-04-04 19:20:07 +00:00
|
|
|
rm -f ${CHROOT_FILE}
|
2009-10-28 11:10:38 -01:00
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
if [ -f ${CHROOT_FILE}.orig ]; then
|
|
|
|
mv ${CHROOT_FILE}.orig ${CHROOT_FILE}
|
2009-10-28 11:10:38 -01:00
|
|
|
fi
|
2009-01-09 14:17:31 -01:00
|
|
|
fi
|
|
|
|
|
2007-10-14 19:47:35 +00:00
|
|
|
# Deconfiguring apt preferences
|
2020-04-04 17:59:11 +00:00
|
|
|
CONFIG_FILE="config/apt/preferences"
|
|
|
|
CHROOT_FILE="chroot/etc/apt/preferences"
|
|
|
|
if [ -f ${CONFIG_FILE} ]; then
|
2020-04-04 19:20:07 +00:00
|
|
|
rm -f ${CHROOT_FILE}
|
2009-10-28 11:10:38 -01:00
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
if [ -f ${CHROOT_FILE}.orig ]; then
|
|
|
|
mv ${CHROOT_FILE}.orig ${CHROOT_FILE}
|
2009-10-28 11:10:38 -01:00
|
|
|
fi
|
2020-04-04 19:20:07 +00:00
|
|
|
elif [ -f ${CHROOT_FILE} ]; then
|
|
|
|
# delete additions from lb_chroot_apt install|install-binary to preferences
|
|
|
|
sed -i '/# Added by lb_chroot_apt/,$d' ${CHROOT_FILE}
|
|
|
|
# delete the last empty line
|
|
|
|
sed -i '${/^[[:blank:]]*$/d;}' ${CHROOT_FILE}
|
|
|
|
# if the resulting preferences file is empty, we must have created it, remove it
|
|
|
|
if [ ! -s ${CHROOT_FILE} ]; then
|
|
|
|
rm -f ${CHROOT_FILE}
|
|
|
|
fi
|
2009-10-28 11:10:38 -01:00
|
|
|
fi
|
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
if Find_files config/apt/*.pref; then
|
|
|
|
for CONFIG_FILE in config/apt/*.pref; do
|
|
|
|
CHROOT_FILE="chroot/etc/apt/preferences.d/$(basename ${CONFIG_FILE})"
|
2012-01-07 17:47:41 -01:00
|
|
|
|
2020-04-04 19:20:07 +00:00
|
|
|
rm -f ${CHROOT_FILE}
|
2012-01-07 17:47:41 -01:00
|
|
|
|
2020-04-04 17:59:11 +00:00
|
|
|
if [ -f ${CHROOT_FILE}.orig ]; then
|
|
|
|
mv ${CHROOT_FILE}.orig ${CHROOT_FILE}
|
2012-01-07 17:47:41 -01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
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
|