2007-09-23 08:04:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# lh_bootstrap_debootstrap(1) - bootstrap a Debian system with debootstrap(8)
|
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 debootstrap(8)"
|
|
|
|
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
|
|
|
Echo_debug "Init ${PROGRAM}"
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Reading configuration files
|
|
|
|
Read_conffile config/bootstrap
|
2007-09-23 08:04:49 +00:00
|
|
|
Read_conffile config/chroot
|
|
|
|
Read_conffile config/common
|
|
|
|
Read_conffile config/image
|
2007-09-23 08:04:46 +00:00
|
|
|
Set_defaults
|
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
Breakpoint "bootstrap_debootstrap: Init"
|
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
if [ "${LH_BOOTSTRAP}" != "debootstrap" ]
|
|
|
|
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 debootstrap options
|
|
|
|
if [ -n "${LIVE_ARCHITECTURE}" ]
|
|
|
|
then
|
|
|
|
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --arch ${LIVE_ARCHITECTURE}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${LIVE_BOOTSTRAP_CONFIG}" ]
|
|
|
|
then
|
|
|
|
LIVE_DEBOOTSTRAP_SCRIPT="/usr/lib/debootstrap/scripts/${LIVE_BOOTSTRAP_CONFIG}"
|
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
if [ "${LH_VERBOSE}" = "true" ]
|
2007-09-23 08:04:49 +00:00
|
|
|
then
|
|
|
|
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --verbose"
|
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
if [ -x "/usr/sbin/debootstrap" ]
|
|
|
|
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
|
2007-09-23 08:04:51 +00:00
|
|
|
${LH_ROOT_COMMAND} cp -a cache/chroot_bootstrap/* chroot
|
|
|
|
|
|
|
|
if [ -n "${LH_ROOT_COMMAND}" ]
|
|
|
|
then
|
|
|
|
${LH_ROOT_COMMAND} chown -R `whoami`:`whoami` chroot
|
|
|
|
fi
|
2007-09-23 08:04:49 +00:00
|
|
|
|
|
|
|
# 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/apt/archives
|
|
|
|
cp cache/bootstrap/*.deb chroot/var/cache/apt/archives
|
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Executing debootstrap (download-only)
|
2007-09-23 08:04:51 +00:00
|
|
|
${LH_ROOT_COMMAND} debootstrap ${DEBOOTSTRAP_OPTIONS} --download-only "${LIVE_DISTRIBUTION}" chroot "${LIVE_MIRROR_BUILD}" "${LIVE_DEBOOTSTRAP_SCRIPT}"
|
|
|
|
|
|
|
|
if [ -n "${LH_ROOT_COMMAND}" ]
|
|
|
|
then
|
|
|
|
${LH_ROOT_COMMAND} chown -R `whoami`:`whoami` chroot
|
|
|
|
fi
|
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/apt/archives/*.deb cache/bootstrap
|
2007-09-23 08:04:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Executing debootstrap (regular run)
|
2007-09-23 08:04:51 +00:00
|
|
|
${LH_ROOT_COMMAND} debootstrap ${DEBOOTSTRAP_OPTIONS} "${LIVE_DISTRIBUTION}" chroot "${LIVE_MIRROR_BUILD}" "${LIVE_DEBOOTSTRAP_SCRIPT}"
|
|
|
|
|
|
|
|
if [ -n "${LH_ROOT_COMMAND}" ]
|
|
|
|
then
|
|
|
|
${LH_ROOT_COMMAND} chown -R `whoami`:`whoami` chroot
|
|
|
|
fi
|
2007-09-23 08:04:48 +00:00
|
|
|
|
|
|
|
# Removing bootstrap cache
|
|
|
|
rm -rf chroot/var/cache/apt/archives/*.deb
|
|
|
|
|
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
|
|
|
|
|
2007-09-23 08:04:51 +00:00
|
|
|
${LH_ROOT_COMMAND} cp -a chroot cache/chroot_bootstrap
|
|
|
|
|
|
|
|
if [ -n "${LH_ROOT_COMMAND}" ]
|
|
|
|
then
|
|
|
|
${LH_ROOT_COMMAND} chown -R `whoami`:`whoami` cache/chroot_bootstrap
|
|
|
|
fi
|
2007-09-23 08:04:49 +00:00
|
|
|
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
|
2007-09-23 08:04:50 +00:00
|
|
|
Echo_error "Can't process file /usr/bin/debootstrap (FIXME)"
|
2007-09-23 08:04:46 +00:00
|
|
|
exit 1
|
|
|
|
fi
|