live-build/helpers/lh_chroot_apt

186 lines
4.2 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
# lh_chroot_apt(1) - manage /etc/apt/apt.conf
2007-09-23 08:04:48 +00:00
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper 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
# Source common functions
for FUNCTION in /usr/share/live-helper/functions/*.sh
do
. ${FUNCTION}
done
2007-09-23 08:04:48 +00:00
# Set static variables
DESCRIPTION="manage /etc/apt/apt.conf"
HELP=""
USAGE="${PROGRAM} {install|remove} [--force]"
Arguments "${@}"
2007-09-23 08:04:46 +00:00
# Reading configuration files
Read_conffile config/common
Read_conffile config/chroot
Set_defaults
# Requiring stage file
2007-09-23 08:04:47 +00:00
Require_stagefile .stage/bootstrap
2007-09-23 08:04:46 +00:00
# Checking lock file
2007-09-23 08:04:47 +00:00
Check_lockfile .lock
2007-09-23 08:04:46 +00:00
# Creating lock file
2007-09-23 08:04:47 +00:00
Create_lockfile .lock
2007-09-23 08:04:46 +00:00
case "${1}" in
install)
# 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:48 +00:00
if [ -f chroot/etc/apt/apt.conf ]
then
# Remove old /etc/apt/apt.conf
rm -f chroot/etc/apt/apt.conf
fi
2007-09-23 08:04:47 +00:00
if [ "${LH_APT}" = "aptitude" ] && [ ! -d chroot/etc/apt/apt.conf.d ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:47 +00:00
mkdir -p chroot/etc/apt/apt.conf.d
2007-09-23 08:04:46 +00:00
fi
# Configuring apt ftp proxy
if [ -n "${LH_APT_FTPPROXY}" ]
then
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
echo "Acquire::ftp::Proxy \"${LH_APT_FTPPROXY}\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
;;
aptitude)
2007-09-23 08:04:47 +00:00
echo "Acquire::ftp::Proxy \"${LH_APT_FTPPROXY}\";" > chroot/etc/apt/apt.conf.d/ftp-proxy
2007-09-23 08:04:46 +00:00
;;
esac
fi
# Configuring apt http proxy
if [ -n "${LH_APT_HTTPPROXY}" ]
then
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
echo "Acquire::http::Proxy \"${LH_APT_HTTPPROXY}\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
;;
aptitude)
2007-09-23 08:04:47 +00:00
echo "Acquire::http::Proxy \"${LH_APT_HTTPPROXY}\";" > chroot/etc/apt/apt.conf.d/http-proxy
2007-09-23 08:04:46 +00:00
;;
esac
fi
# Configuring apt pdiffs
if [ "${LH_APT_PDIFFS}" = "enabled" ]
then
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
echo "Acquire::PDiffs \"true\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
;;
aptitude)
2007-09-23 08:04:47 +00:00
echo "Acquire::PDiffs \"true\";" > chroot/etc/apt/apt.conf.d/pdiffs
2007-09-23 08:04:46 +00:00
;;
esac
else
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
echo "Acquire::PDiffs \"false\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
;;
aptitude)
2007-09-23 08:04:47 +00:00
echo "Acquire::PDiffs \"false\";" > chroot/etc/apt/apt.conf.d/pdiffs
2007-09-23 08:04:46 +00:00
;;
esac
fi
# Configuring apt recommends
if [ "${LH_APT_RECOMMENDS}" = "enabled" ]
then
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
echo "Aptitude::Recommends-Important \"true\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
;;
aptitude)
2007-09-23 08:04:47 +00:00
echo "Aptitude::Recommends-Important \"true\";" > chroot/etc/apt/apt.conf.d/recommends
2007-09-23 08:04:46 +00:00
;;
esac
else
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
echo "Aptitude::Recommends-Important \"false\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
;;
aptitude)
2007-09-23 08:04:47 +00:00
echo "Aptitude::Recommends-Important \"false\";" > chroot/etc/apt/apt.conf.d/recommends
2007-09-23 08:04:46 +00:00
;;
esac
fi
2007-09-23 08:04:48 +00:00
# Configuring apt secure
if [ "${LH_APT_SECURE}" = "enabled" ]
then
case "${LH_APT}" in
apt|apt-get)
2007-09-23 08:04:49 +00:00
echo "APT::Get::AllowUnauthenticated \"true\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:48 +00:00
;;
aptitude)
2007-09-23 08:04:49 +00:00
echo "APT::Get::AllowUnauthenticated \"true\";" > chroot/etc/apt/apt.conf.d/secure
2007-09-23 08:04:48 +00:00
;;
esac
else
case "${LH_APT}" in
apt|apt-get)
2007-09-23 08:04:49 +00:00
echo "APT::Get::AllowUnauthenticated \"false\";" >> chroot/etc/apt/apt.conf
2007-09-23 08:04:48 +00:00
;;
aptitude)
2007-09-23 08:04:49 +00:00
echo "APT::Get::AllowUnauthenticated \"false\";" > chroot/etc/apt/apt.conf.d/secure
2007-09-23 08:04:48 +00:00
;;
esac
fi
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)
# Deconfiguring apt settings
2007-09-23 08:04:47 +00:00
rm -f chroot/etc/apt/apt.conf
2007-09-23 08:04:46 +00:00
# Deconfiguring aptitude ftp proxy
2007-09-23 08:04:47 +00:00
rm -f chroot/etc/apt/apt.conf.d/ftp-proxy
2007-09-23 08:04:46 +00:00
# Deconfiguring aptitude http proxy
2007-09-23 08:04:47 +00:00
rm -f chroot/etc/apt/apt.conf.d/http-proxy
2007-09-23 08:04:46 +00:00
# Deconfiguring aptitude pdiffs
2007-09-23 08:04:47 +00:00
rm -f chroot/etc/apt/apt.conf.d/pdiffs
2007-09-23 08:04:46 +00:00
# Deconfiguring aptitude recommends
2007-09-23 08:04:47 +00:00
rm -f chroot/etc/apt/apt.conf.d/recommends
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:48 +00:00
# Deconfiguring aptitude secure
rm -f chroot/etc/apt/apt.conf.d/secure
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