3
# lh_binary_chroot(1) - copy chroot into chroot
4
# Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
6
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7
# This is free software, and you are welcome to redistribute it
8
# under certain conditions; see COPYING for details.
12
# Including common functions
13
. "${LH_BASE:-/usr/share/live-helper}"/scripts/build.sh
15
# Setting static variables
16
DESCRIPTION="$(Echo 'copy chroot into chroot')"
18
USAGE="${PROGRAM} [--force]"
22
# Reading configuration files
23
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
26
Echo_message "Begin copying chroot..."
28
# Requiring stage file
29
Require_stagefile .stage/config .stage/bootstrap
32
Check_stagefile .stage/binary_chroot
40
# Normally, virtual filesystems are not mounted here, but people tend to be lazy
41
if [ -f chroot/proc/version ]
43
if [ "${LH_USE_FAKEROOT}" != "true" ]
45
${LH_ROOT_COMMAND} umount chroot/proc
52
if [ -d chroot/sys/kernel ]
54
if [ "${LH_USE_FAKEROOT}" != "true" ]
56
${LH_ROOT_COMMAND} umount chroot/sys
63
# Copying /dev if using fakeroot
64
if [ "${LH_USE_FAKEROOT}" = "true" ]
67
find /dev | cpio -dmpu chroot
70
if [ "${LH_BUILD_WITH_CHROOT}" = "false" ]
75
if [ "${LH_CACHE}" = "true" ] && Find_files cache/stages_rootfs/filesystem*
80
Echo_message "This may take a while."
83
${LH_ROOT_COMMAND} rm -rf chroot/chroot
84
${LH_ROOT_COMMAND} rm -rf chroot.tmp
87
if [ -d cache/stages_bootstrap ] && [ "${LH_CHROOT_FILESYSTEM}" != "plain" ]
89
${LH_ROOT_COMMAND} mv chroot chroot.tmp
90
${LH_ROOT_COMMAND} cp -a cache/stages_bootstrap chroot
91
${LH_ROOT_COMMAND} touch chroot/chroot.cache
93
${LH_ROOT_COMMAND} cp -a chroot chroot.tmp
96
${LH_ROOT_COMMAND} mv chroot.tmp chroot/chroot
98
# Handling chroot excludes
99
if [ -f config/binary_rootfs/excludes ]
101
case "${LH_BUILD_WITH_CHROOT}" in
103
cp config/binary_rootfs/excludes chroot/chroot/excludes
104
chroot chroot/chroot /usr/bin/env -i xargs --arg-file=/excludes -I FILE bash -c 'rm -rf FILE'
105
rm -f chroot/chroot/excludes
109
cp config/binary_rootfs/excludes chroot/excludes
110
chroot chroot /usr/bin/env -i xargs --arg-file=/excludes -I FILE bash -c 'rm -rf FILE'
111
rm -f chroot/excludes
116
if [ -n "${LH_ROOT_COMMAND}" ]
118
${LH_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
121
# Creating stage file
122
Create_stagefile .stage/binary_chroot