2007-09-23 08:04:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2011-01-11 12:49:49 -01:00
|
|
|
## Copyright (C) 2006-2011 Daniel Baumann <daniel@debian.org>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
|
|
|
## live-build comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
|
|
|
## 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
|
2010-09-07 13:11:20 +00:00
|
|
|
. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Setting static variables
|
2009-01-15 01:37:42 -01:00
|
|
|
DESCRIPTION="$(Echo 'manage /etc/apt/apt.conf')"
|
2007-09-23 08:04:48 +00:00
|
|
|
HELP=""
|
2008-08-14 00:39:48 +00:00
|
|
|
USAGE="${PROGRAM} {install|install-binary|remove} [--force]"
|
2007-09-23 08:04:48 +00:00
|
|
|
|
|
|
|
Arguments "${@}"
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Reading configuration files
|
2008-10-28 14:26:17 -01:00
|
|
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
2007-09-23 08:04:46 +00:00
|
|
|
Set_defaults
|
|
|
|
|
|
|
|
# Requiring stage file
|
2008-10-14 19:32:50 +00:00
|
|
|
Require_stagefile .stage/config .stage/bootstrap
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
case "${1}" 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
|
2007-09-23 08:04:47 +00:00
|
|
|
Check_stagefile .stage/chroot_apt
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:04:50 +00:00
|
|
|
# Checking lock file
|
|
|
|
Check_lockfile .lock
|
|
|
|
|
|
|
|
# Creating lock file
|
|
|
|
Create_lockfile .lock
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
mkdir -p chroot/etc/apt/apt.conf.d
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
# Configuring apt ftp proxy
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_APT_FTP_PROXY}" ]
|
2007-09-23 08:04:46 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
echo "Acquire::ftp::Proxy \"${LB_APT_FTP_PROXY}\";" > chroot/etc/apt/apt.conf.d/00ftp-proxy
|
2007-09-23 08:04:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Configuring apt http proxy
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_APT_HTTP_PROXY}" ]
|
2007-09-23 08:04:46 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
echo "Acquire::http::Proxy \"${LB_APT_HTTP_PROXY}\";" > chroot/etc/apt/apt.conf.d/00http-proxy
|
2007-09-23 08:04:46 +00:00
|
|
|
fi
|
|
|
|
|
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
|
2010-09-07 13:11:20 +00:00
|
|
|
echo "Acquire::http::Pipeline-Depth \"${LB_APT_PIPELINE}\";" > chroot/etc/apt/apt.conf.d/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)
|
2007-09-23 08:05:17 +00:00
|
|
|
echo "APT::Install-Recommends \"true\";" > chroot/etc/apt/apt.conf.d/00recommends
|
|
|
|
echo "Aptitude::Recommends-Important \"true\";" >> chroot/etc/apt/apt.conf.d/00recommends
|
|
|
|
;;
|
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
false)
|
2007-09-23 08:05:17 +00:00
|
|
|
echo "APT::Install-Recommends \"false\";" > chroot/etc/apt/apt.conf.d/00recommends
|
|
|
|
echo "Aptitude::Recommends-Important \"false\";" >> chroot/etc/apt/apt.conf.d/00recommends
|
|
|
|
;;
|
|
|
|
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)
|
2008-03-11 15:32:03 -01:00
|
|
|
echo "APT::Get::AllowUnauthenticated \"false\";" > chroot/etc/apt/apt.conf.d/00secure
|
2007-09-23 08:05:09 +00:00
|
|
|
echo "Aptitude::CmdLine::Ignore-Trust-Violations \"false\";" >> chroot/etc/apt/apt.conf.d/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)
|
2008-03-11 15:32:03 -01:00
|
|
|
echo "APT::Get::AllowUnauthenticated \"true\";" > chroot/etc/apt/apt.conf.d/00secure
|
2007-09-23 08:05:09 +00:00
|
|
|
echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> chroot/etc/apt/apt.conf.d/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
|
|
|
|
if [ -f config/chroot_apt/apt.conf ]
|
|
|
|
then
|
|
|
|
if [ -f chroot/etc/apt/apt.conf ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/apt.conf chroot/etc/apt/apt.conf.orig
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp config/chroot_apt/apt.conf chroot/etc/apt/apt.conf
|
|
|
|
fi
|
|
|
|
|
2007-10-14 19:47:35 +00:00
|
|
|
# Configuring apt preferences
|
|
|
|
if [ -f config/chroot_apt/preferences ]
|
|
|
|
then
|
|
|
|
if [ -f chroot/etc/apt/preferences ]
|
|
|
|
then
|
2008-02-13 08:20:42 -01:00
|
|
|
mv chroot/etc/apt/preferences chroot/etc/apt/preferences.orig
|
2007-10-14 19:47:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cp config/chroot_apt/preferences chroot/etc/apt/preferences
|
|
|
|
fi
|
|
|
|
|
2012-01-07 17:47:41 -01:00
|
|
|
if Find_files config/chroot_apt/*.pref
|
|
|
|
then
|
|
|
|
for _FILE in config/chroot_apt/*.pref
|
|
|
|
do
|
|
|
|
if [ -f chroot/etc/apt/preferences.d/$(basename ${_FILE}) ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/preferences.d/$(basename ${_FILE}) chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp ${_FILE} chroot/etc/apt/preferences.d
|
|
|
|
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
|
|
|
|
echo >> chroot/etc/apt/preferences
|
2010-11-23 08:36:48 -01:00
|
|
|
echo "# Added by lb_chroot_apt ${@}" >> chroot/etc/apt/preferences
|
2008-08-10 06:03:27 +00:00
|
|
|
echo "Package: *" >> chroot/etc/apt/preferences
|
2011-09-07 14:02:03 +00:00
|
|
|
echo "Pin: release o=config/packages.chroot" >> chroot/etc/apt/preferences
|
2008-08-12 18:17:39 +00:00
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
install)
|
|
|
|
# Ensure local packages have priority
|
|
|
|
echo "Pin-Priority: 1001" >> chroot/etc/apt/preferences
|
|
|
|
;;
|
|
|
|
|
|
|
|
install-binary)
|
2010-11-23 08:36:48 -01:00
|
|
|
# Ensure local packages are not re-installed during lb_binary
|
2008-08-12 18:17:39 +00:00
|
|
|
echo "Pin-Priority: 99" >> chroot/etc/apt/preferences
|
|
|
|
|
|
|
|
echo >> chroot/etc/apt/preferences
|
|
|
|
echo "Package: *" >> chroot/etc/apt/preferences
|
|
|
|
echo "Pin: release o=debian" >> chroot/etc/apt/preferences
|
|
|
|
echo "Pin-Priority: 99" >> chroot/etc/apt/preferences
|
|
|
|
;;
|
|
|
|
esac
|
2008-08-10 06:03:27 +00:00
|
|
|
fi
|
|
|
|
|
2011-05-15 19:23:03 +00:00
|
|
|
case "${LB_MODE}" in
|
|
|
|
progress)
|
|
|
|
echo "# /etc/apt/preferences.d/progress.pref" > chroot/etc/apt/preferences.d/progress.pref
|
|
|
|
|
|
|
|
case "${LB_DISTRIBUTION}" in
|
|
|
|
*-backports)
|
|
|
|
_DISTRIBUTIONS="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||') ${LB_DISTRIBUTION}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
_DISTRIBUTIONS="${LB_DISTRIBUTION}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ "${LB_SECURITY}" = "true" ]
|
|
|
|
then
|
|
|
|
case "${LB_DISTRIBUTION}" in
|
|
|
|
artax)
|
|
|
|
_DISTRIBUTION="${_DISTRIBUTION} ${LB_DISTRIBUTION}-security"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
for _DISTRIBUTION in ${_DISTRIBUTIONS}
|
|
|
|
do
|
|
|
|
|
|
|
|
cat >> chroot/etc/apt/preferences.d/progress.pref << EOF
|
|
|
|
|
|
|
|
Package: *
|
|
|
|
Pin: release n=${_DISTRIBUTION}
|
|
|
|
Pin-Priority: 999
|
|
|
|
EOF
|
|
|
|
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Creating stage file
|
2007-09-23 08:04:47 +00:00
|
|
|
Create_stagefile .stage/chroot_apt
|
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"
|
|
|
|
|
2007-09-23 08:04:50 +00:00
|
|
|
# Checking lock file
|
|
|
|
Check_lockfile .lock
|
|
|
|
|
|
|
|
# Creating lock file
|
|
|
|
Create_lockfile .lock
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
# Deconfiguring aptitude ftp proxy
|
2007-09-23 08:04:50 +00:00
|
|
|
rm -f chroot/etc/apt/apt.conf.d/00ftp-proxy
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
# Deconfiguring aptitude http proxy
|
2007-09-23 08:04:50 +00:00
|
|
|
rm -f chroot/etc/apt/apt.conf.d/00http-proxy
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Deconfiguring aptitude pipeline
|
|
|
|
rm -f chroot/etc/apt/apt.conf.d/00pipeline
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Deconfiguring aptitude recommends
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_APT_RECOMMENDS}" = "true" ]
|
2008-08-16 01:15:40 +00:00
|
|
|
then
|
|
|
|
rm -f chroot/etc/apt/apt.conf.d/00recommends
|
|
|
|
fi
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:04:48 +00:00
|
|
|
# Deconfiguring aptitude secure
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_APT_SECURE}" = "true" ]
|
2008-08-16 01:15:40 +00:00
|
|
|
then
|
|
|
|
rm -f chroot/etc/apt/apt.conf.d/00secure
|
|
|
|
fi
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2009-01-09 14:17:31 -01:00
|
|
|
# Configuring apt config
|
|
|
|
if [ -f config/chroot_apt/apt.conf ]
|
|
|
|
then
|
|
|
|
if [ -f chroot/etc/apt/apt.conf ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/apt.conf chroot/etc/apt/apt.conf.orig
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp config/chroot_apt/apt.conf chroot/etc/apt/apt.conf
|
2009-10-28 11:10:38 -01:00
|
|
|
|
|
|
|
if [ -f chroot/etc/apt/apt.conf.orig ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/apt.conf.orig chroot/etc/apt/apt.conf
|
|
|
|
fi
|
2009-01-09 14:17:31 -01:00
|
|
|
fi
|
|
|
|
|
2007-10-14 19:47:35 +00:00
|
|
|
# Deconfiguring apt preferences
|
2009-10-28 11:10:38 -01:00
|
|
|
if [ -f config/chroot_apt/preferences ]
|
|
|
|
then
|
|
|
|
if [ -f chroot/etc/apt/preferences ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/preferences chroot/etc/apt/preferences.orig
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp config/chroot_apt/preferences chroot/etc/apt/preferences
|
|
|
|
|
|
|
|
if [ -f chroot/etc/apt/preferences.orig ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/preferences.orig chroot/etc/apt/preferences
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-01-07 17:47:41 -01:00
|
|
|
if Find_files config/chroot_apt/*.pref
|
|
|
|
then
|
|
|
|
for _FILE in config/chroot_apt/*.pref
|
|
|
|
do
|
|
|
|
if [ -f chroot/etc/apt/preferences.d/$(basename ${_FILE}) ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/preferences.d/$(basename ${_FILE}) chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp ${_FILE} chroot/etc/apt/preferences.d
|
|
|
|
|
|
|
|
if [ -f chroot/etc/apt/preferences.d/$(basename ${_FILE}) ]
|
|
|
|
then
|
|
|
|
mv chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig chroot/etc/apt/preferences.d/$(basename ${_FILE})
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2011-09-07 15:33:53 +00:00
|
|
|
if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
|
2007-10-14 19:47:35 +00:00
|
|
|
then
|
2009-10-28 11:10:38 -01:00
|
|
|
if [ -f chroot/etc/apt/preferences ]
|
|
|
|
then
|
2010-11-23 08:36:48 -01:00
|
|
|
# delete additions from lb_chroot_apt install|install-binary to preferences
|
|
|
|
sed -i '/# Added by lb_chroot_apt/,$d' chroot/etc/apt/preferences
|
2009-10-28 11:10:38 -01:00
|
|
|
# delete the last empty line
|
|
|
|
sed -i '${/^[[:blank:]]*$/d;}' chroot/etc/apt/preferences
|
|
|
|
# if the resulting preferences file is empty there was no user additions, remove it
|
|
|
|
if [ ! -s chroot/etc/apt/preferences ]
|
|
|
|
then
|
|
|
|
rm -rf chroot/etc/apt/preferences
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-10-14 19:47:35 +00:00
|
|
|
fi
|
|
|
|
|
2011-05-15 19:23:03 +00:00
|
|
|
rm -f "chroot/etc/apt/preferences.d/${LB_MODE}.pref"
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Removing stage file
|
2007-09-23 08:04:47 +00:00
|
|
|
rm -f .stage/chroot_apt
|
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
|