live-build/helpers/lh_bootstrap_cdebootstrap

160 lines
3.4 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
# lh_bootstrap_cdebootstrap(1) - bootstrap a Debian system with cdebootstrap(1)
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="bootstrap a Debian system with cdebootstrap(1)"
HELP=""
USAGE="${PROGRAM} [--force]"
Arguments "${@}"
2007-09-23 08:04:46 +00:00
# Ensure that a system is built as root
lh_testroot
2007-09-23 08:04:49 +00:00
# Starting helper
Echo_debug "Init ${PROGRAM}"
2007-09-23 08:04:46 +00:00
# Reading configuration files
Read_conffile config/common
Read_conffile config/bootstrap
Set_defaults
2007-09-23 08:04:49 +00:00
if [ "${LH_BOOTSTRAP}" != "cdebootstrap" ]
then
exit 0
fi
2007-09-23 08:04:46 +00:00
# Checking stage file
2007-09-23 08:04:47 +00:00
Check_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
# Creating chroot directory
2007-09-23 08:04:47 +00:00
if [ ! -d chroot ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:47 +00:00
mkdir -p chroot
2007-09-23 08:04:46 +00:00
fi
# Setting cdebootstrap options
if [ -n "${LIVE_ARCHITECTURE}" ]
then
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --arch=${LIVE_ARCHITECTURE}"
fi
if [ -n "${LIVE_DISTRIBUTION_CONFIG}" ]
then
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --suite-config=${LIVE_DISTRIBUTION_CONFIG}"
fi
2007-09-23 08:04:48 +00:00
if [ "${LIVE_PACKAGES_LISTS}" != "minimal" ] && [ "${LIVE_PACKAGES_LISTS}" != "mini" ]
2007-09-23 08:04:46 +00:00
then
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --flavour=standard"
2007-09-23 08:04:48 +00:00
else
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --flavour=minimal"
2007-09-23 08:04:46 +00:00
fi
2007-09-23 08:04:49 +00:00
if [ "${DEBUG}" = "true" ]
then
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --debug"
fi
if [ "${QUIET}" = "true" ]
then
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --quiet"
fi
if [ "${VERBOSE}" = "true" ]
then
CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --verbose"
fi
2007-09-23 08:04:46 +00:00
if [ -x "/usr/bin/cdebootstrap" ]
then
if [ "${LH_CACHE}" = "enabled" ]
then
2007-09-23 08:04:48 +00:00
# Restore old cache
2007-09-23 08:04:49 +00:00
if [ -d cache/chroot_bootstrap ]
then
cp -a cache/chroot_bootstrap/* chroot
# Creating stage file
Create_stagefile .stage/bootstrap
exit 0
fi
2007-09-23 08:04:48 +00:00
if [ -d cache/bootstrap ]
then
mkdir -p chroot/var/cache/bootstrap
cp cache/bootstrap/*.deb chroot/var/cache/bootstrap
fi
2007-09-23 08:04:46 +00:00
# Executing cdebootstrap (download-only)
2007-09-23 08:04:48 +00:00
cdebootstrap ${CDEBOOTSTRAP_OPTIONS} --download-only "${LIVE_DISTRIBUTION}" chroot "${LIVE_MIRROR_BUILD}"
2007-09-23 08:04:46 +00:00
# Removing old cache
2007-09-23 08:04:47 +00:00
if [ -d cache/bootstrap ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:47 +00:00
rm -f cache/bootstrap/*.deb
2007-09-23 08:04:46 +00:00
fi
# Saving new cache
2007-09-23 08:04:47 +00:00
if [ ! -d cache/bootstrap ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:47 +00:00
mkdir -p cache/bootstrap
2007-09-23 08:04:46 +00:00
fi
2007-09-23 08:04:47 +00:00
cp chroot/var/cache/bootstrap/*.deb cache/bootstrap
2007-09-23 08:04:46 +00:00
fi
# Executing cdebootstrap (regular run)
2007-09-23 08:04:48 +00:00
cdebootstrap ${CDEBOOTSTRAP_OPTIONS} "${LIVE_DISTRIBUTION}" chroot "${LIVE_MIRROR_BUILD}"
# Remove cdebootstrap-helper-diverts (needed at least for minimal flavours)
if [ "${LIVE_BOOTSTRAP_FLAVOUR}" = "minimal" ] || [ "${LIVE_BOOTSTRAP_FLAVOUR}" = "mini" ]
then
Chroot "dpkg -P cdebootstrap-helper-diverts"
fi
# Removing bootstrap cache
if [ -d chroot/var/cache/bootstrap ]
then
rm -rf chroot/var/cache/bootstrap
fi
2007-09-23 08:04:49 +00:00
# Saving new cache
if [ "${LH_CACHE}" = "enabled" ]
then
if [ -d cache/chroot_bootstrap ]
then
rm -rf cache/chroot_bootstrap
fi
cp -a chroot cache/chroot_bootstrap
fi
2007-09-23 08:04:48 +00:00
# Creating stage file
Create_stagefile .stage/bootstrap
2007-09-23 08:04:46 +00:00
else
echo "E: Can't process file /usr/bin/cdebootstrap (FIXME)"
exit 1
fi