~timrchavez/live-build/lb-sg-2.x-add-suppport-for-pxz

« back to all changes in this revision

Viewing changes to scripts/build/binary_chroot

  • Committer: Daniel Baumann
  • Date: 2011-03-09 18:17:15 UTC
  • Revision ID: daniel@debian.org-20110309181715-2s6s9tqa8xup5aep
Rearranging helpers scripts in source tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# lh_binary_chroot(1) - copy chroot into chroot
 
4
# Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
 
5
#
 
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.
 
9
 
 
10
set -e
 
11
 
 
12
# Including common functions
 
13
. "${LH_BASE:-/usr/share/live-helper}"/scripts/build.sh
 
14
 
 
15
# Setting static variables
 
16
DESCRIPTION="$(Echo 'copy chroot into chroot')"
 
17
HELP=""
 
18
USAGE="${PROGRAM} [--force]"
 
19
 
 
20
Arguments "${@}"
 
21
 
 
22
# Reading configuration files
 
23
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
 
24
Set_defaults
 
25
 
 
26
Echo_message "Begin copying chroot..."
 
27
 
 
28
# Requiring stage file
 
29
Require_stagefile .stage/config .stage/bootstrap
 
30
 
 
31
# Checking stage file
 
32
Check_stagefile .stage/binary_chroot
 
33
 
 
34
# Checking lock file
 
35
Check_lockfile .lock
 
36
 
 
37
# Creating lock file
 
38
Create_lockfile .lock
 
39
 
 
40
# Normally, virtual filesystems are not mounted here, but people tend to be lazy
 
41
if [ -f chroot/proc/version ]
 
42
then
 
43
        if [ "${LH_USE_FAKEROOT}" != "true" ]
 
44
then
 
45
                ${LH_ROOT_COMMAND} umount chroot/proc
 
46
        else
 
47
                rm -rf chroot/proc
 
48
                mkdir -p chroot/proc
 
49
        fi
 
50
fi
 
51
 
 
52
if [ -d chroot/sys/kernel ]
 
53
then
 
54
        if [ "${LH_USE_FAKEROOT}" != "true" ]
 
55
        then
 
56
                ${LH_ROOT_COMMAND} umount chroot/sys
 
57
        else
 
58
                rm -rf chroot/sys
 
59
                mkdir -p chroot/sys
 
60
        fi
 
61
fi
 
62
 
 
63
# Copying /dev if using fakeroot
 
64
if [ "${LH_USE_FAKEROOT}" = "true" ]
 
65
then
 
66
        rm -rf chroot/dev
 
67
        find /dev | cpio -dmpu chroot
 
68
fi
 
69
 
 
70
if [ "${LH_BUILD_WITH_CHROOT}" = "false" ]
 
71
then
 
72
        exit 0
 
73
fi
 
74
 
 
75
if [ "${LH_CACHE}" = "true" ] && Find_files cache/stages_rootfs/filesystem*
 
76
then
 
77
        exit 0
 
78
fi
 
79
 
 
80
Echo_message "This may take a while."
 
81
 
 
82
# Removing old chroot
 
83
${LH_ROOT_COMMAND} rm -rf chroot/chroot
 
84
${LH_ROOT_COMMAND} rm -rf chroot.tmp
 
85
 
 
86
# Copying new chroot
 
87
if [ -d cache/stages_bootstrap ] && [ "${LH_CHROOT_FILESYSTEM}" != "plain" ]
 
88
then
 
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
 
92
else
 
93
        ${LH_ROOT_COMMAND} cp -a chroot chroot.tmp
 
94
fi
 
95
 
 
96
${LH_ROOT_COMMAND} mv chroot.tmp chroot/chroot
 
97
 
 
98
# Handling chroot excludes
 
99
if [ -f config/binary_rootfs/excludes ]
 
100
then
 
101
        case "${LH_BUILD_WITH_CHROOT}" in
 
102
                true)
 
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
 
106
                        ;;
 
107
 
 
108
                false)
 
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
 
112
                        ;;
 
113
        esac
 
114
fi
 
115
 
 
116
if [ -n "${LH_ROOT_COMMAND}" ]
 
117
then
 
118
        ${LH_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
 
119
fi
 
120
 
 
121
# Creating stage file
 
122
Create_stagefile .stage/binary_chroot