live-build/helpers/lh_chroot_sources

250 lines
6.3 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
# lh_chroot_sources(1) - manage /etc/apt/sources.list
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/sources.list"
HELP=""
USAGE="${PROGRAM} {install|remove} [--force]"
Arguments "${@}"
2007-09-23 08:04:49 +00:00
Echo_debug "Init ${PROGRAM}"
2007-09-23 08:04:46 +00:00
# Reading configuration files
2007-09-23 08:04:49 +00:00
Read_conffile config/bootstrap
2007-09-23 08:04:46 +00:00
Read_conffile config/chroot
2007-09-23 08:04:49 +00:00
Read_conffile config/common
2007-09-23 08:04:46 +00:00
Read_conffile config/image
Set_defaults
2007-09-23 08:04:49 +00:00
Breakpoint "chroot_sources: Init"
2007-09-23 08:04:46 +00:00
# Requiring stage file
2007-09-23 08:04:47 +00:00
Require_stagefile .stage/bootstrap
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_sources
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:46 +00:00
# Configure custom sources.list
2007-09-23 08:04:48 +00:00
echo "deb ${LIVE_MIRROR_BUILD} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" > chroot/etc/apt/sources.list
2007-09-23 08:04:46 +00:00
if [ "${LIVE_SOURCE}" = "enabled" ]
then
2007-09-23 08:04:48 +00:00
echo "deb-src ${LIVE_MIRROR_BUILD} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
2007-09-23 08:04:46 +00:00
fi
if [ "${LIVE_SECURITY}" = "enabled" ]
then
2007-09-23 08:04:51 +00:00
case "${LH_MODE}" in
debian)
if [ "${LIVE_DISTRIBUTION}" != "sid" ] && [ "${LIVE_DISTRIBUTION}" != "unstable" ]
then
echo "deb ${LIVE_MIRROR_BUILD_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:51 +00:00
if [ "${LIVE_SOURCE}" = "enabled" ]
then
echo "deb-src ${LIVE_MIRROR_BUILD_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
fi
fi
;;
ubuntu)
echo "deb ${LIVE_MIRROR_BUILD_SECURITY} ${LIVE_DISTRIBUTION}-security ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
if [ "${LIVE_SOURCE}" = "enabled" ]
then
echo "deb-src ${LIVE_MIRROR_BUILD_SECURITY} ${LIVE_DISTRIBUTION}-security ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
fi
;;
esac
2007-09-23 08:04:46 +00:00
fi
2007-09-23 08:04:47 +00:00
# Check local sources.list
2007-09-23 08:04:49 +00:00
if ls config/chroot_sources/*.build &> /dev/null
2007-09-23 08:04:47 +00:00
then
echo "" >> chroot/etc/apt/sources.list
echo "# Custom repositories" >> chroot/etc/apt/sources.list
2007-09-23 08:04:49 +00:00
for FILE in config/chroot_sources/*.build
do
2007-09-23 08:04:50 +00:00
cat ${FILE} | grep -v "^##" >> chroot/etc/apt/sources.list
2007-09-23 08:04:49 +00:00
done
fi
# Check local gpg keys
if ls config/chroot_sources/*.build.gpg &> /dev/null
then
for FILE in config/chroot_sources/*.build.gpg
do
cp ${FILE} chroot/root
Chroot "apt-key add /root/`basename ${FILE}`"
rm -f chroot/root/`basename ${FILE}`
done
fi
# Check local keyring packages
if ls config/chroot_sources/*.deb &> /dev/null
then
for PACKAGE in config/chroot_sources/*.deb
do
cp ${PACKAGE} chroot/root
Chroot "dpkg -i `basename ${PACKAGE}`"
rm -f chroot/root/`basename ${PACKAGE}`
done
2007-09-23 08:04:47 +00:00
fi
2007-09-23 08:04:46 +00:00
# Installing aptitude
2007-09-23 08:04:50 +00:00
if [ "${LH_APT}" = "apt" ] || [ "${LH_APT}" = "apt-get" ]
2007-09-23 08:04:46 +00:00
then
Chroot "apt-get update"
elif [ "${LH_APT}" = "aptitude" ]
then
2007-09-23 08:04:47 +00:00
if [ ! -x /usr/bin/aptitude ]
2007-09-23 08:04:46 +00:00
then
Chroot "apt-get update"
Chroot "apt-get install --yes --force-yes aptitude"
fi
Chroot "aptitude update"
fi
2007-09-23 08:04:49 +00:00
# Installing keyring packages
if [ -n "${LIVE_KEYRING_PACKAGES}" ]
then
Chroot "apt-get install --yes --force-yes ${LIVE_KEYRING_PACKAGES}"
Chroot "apt-get update"
fi
2007-09-23 08:04:46 +00:00
# Creating stage file
2007-09-23 08:04:47 +00:00
Create_stagefile .stage/chroot_sources
2007-09-23 08:04:46 +00:00
;;
remove)
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
# Configure generic indices
if [ "${LH_APT_GENERIC}" = "enabled" ]
then
2007-09-23 08:04:49 +00:00
# Don't do anything if it's not required
if [ "${LIVE_MIRROR_BUILD}" = "${LIVE_MIRROR_IMAGE}" ] && \
[ "${LIVE_MIRROR_BUILD_SECURITY}" = "${LIVE_MIRROR_IMAGE_SECURITY}" ]
then
exit 0
fi
2007-09-23 08:04:46 +00:00
# Cleaning apt list cache
2007-09-23 08:04:47 +00:00
rm -rf chroot/var/lib/apt/lists
mkdir -p chroot/var/lib/apt/lists/partial
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:48 +00:00
echo "deb ${LIVE_MIRROR_IMAGE} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" > chroot/etc/apt/sources.list
2007-09-23 08:04:46 +00:00
if [ "${LIVE_SOURCE}" = "enabled" ]
then
2007-09-23 08:04:48 +00:00
echo "deb-src ${LIVE_MIRROR_IMAGE} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
2007-09-23 08:04:46 +00:00
fi
if [ "${LIVE_SECURITY}" = "enabled" ]
then
2007-09-23 08:04:51 +00:00
case "${LH_MODE}" in
debian)
if [ "${LIVE_DISTRIBUTION}" != "sid" ] && [ "${LIVE_DISTRIBUTION}" != "unstable" ]
then
echo "deb ${LIVE_MIRROR_IMAGE_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
if [ "${LIVE_SOURCE}" = "enabled" ]
then
echo "deb-src ${LIVE_MIRROR_IMAGE_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
fi
fi
;;
ubuntu)
echo "deb ${LIVE_MIRROR_IMAGE_SECURITY} ${LIVE_DISTRIBUTION}-security ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
if [ "${LIVE_SOURCE}" = "enabled" ]
then
echo "deb-src ${LIVE_MIRROR_IMAGE_SECURITY} ${LIVE_DISTRIBUTION}-security ${LIVE_SECTIONS}" >> chroot/etc/apt/sources.list
fi
;;
esac
2007-09-23 08:04:46 +00:00
fi
2007-09-23 08:04:47 +00:00
# Check local sources.list
2007-09-23 08:04:49 +00:00
if ls config/chroot_sources/*.image &> /dev/null
2007-09-23 08:04:47 +00:00
then
echo "" >> chroot/etc/apt/sources.list
echo "# Custom repositories" >> chroot/etc/apt/sources.list
2007-09-23 08:04:49 +00:00
2007-09-23 08:04:51 +00:00
for FILE in config/chroot_sources/*.image
2007-09-23 08:04:49 +00:00
do
2007-09-23 08:04:50 +00:00
cat ${FILE} | grep -v "^##" >> chroot/etc/apt/sources.list
2007-09-23 08:04:49 +00:00
done
fi
# Check local gpg keys
if ls config/chroot_sources/*.image.gpg &> /dev/null
then
for FILE in config/chroot_sources/*.image.gpg
do
cp ${FILE} chroot/root
Chroot "apt-key add /root/`basename ${FILE}`"
rm -f chroot/root/`basename ${FILE}`
done
2007-09-23 08:04:47 +00:00
fi
2007-09-23 08:04:46 +00:00
case "${LH_APT}" in
2007-09-23 08:04:47 +00:00
apt|apt-get)
2007-09-23 08:04:46 +00:00
Chroot "apt-get update"
;;
aptitude)
Chroot "aptitude update"
;;
esac
fi
# Cleaning apt packages 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
# Removing old files
2007-09-23 08:04:47 +00:00
rm -f chroot/var/lib/dpkg/available-old
rm -f chroot/var/lib/dpkg/diversions-old
rm -f chroot/var/lib/dpkg/statoverride-old
rm -f chroot/var/lib/dpkg/status-old
2007-09-23 08:04:46 +00:00
# Removing stage file
2007-09-23 08:04:47 +00:00
rm -f .stage/chroot_sources
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