source: live-build/trunk/fuentes/scripts/build/lb_binary_chroot @ 900

Last change on this file since 900 was 900, checked in by kbut, 4 years ago

add original source

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program 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
11set -e
12
13# Including common functions
14( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
15
16# Setting static variables
17DESCRIPTION="$(Echo 'copy chroot into chroot')"
18HELP=""
19USAGE="${PROGRAM} [--force]"
20
21Arguments "${@}"
22
23# Reading configuration files
24Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25Set_defaults
26
27Echo_message "Begin copying chroot..."
28
29# Requiring stage file
30Require_stagefile .build/config .build/bootstrap
31
32# Checking stage file
33Check_stagefile .build/binary_chroot
34
35# Checking lock file
36Check_lockfile .lock
37
38# Creating lock file
39Create_lockfile .lock
40
41# Normally, virtual filesystems are not mounted here, but people tend to be lazy
42if [ -f chroot/proc/version ]
43then
44        if [ "${LB_USE_FAKEROOT}" != "true" ]
45        then
46                ${LB_ROOT_COMMAND} umount chroot/proc
47        else
48                rm -rf chroot/proc
49                mkdir -p chroot/proc
50        fi
51fi
52
53if [ -d chroot/sys/kernel ]
54then
55        if [ "${LB_USE_FAKEROOT}" != "true" ]
56        then
57                ${LB_ROOT_COMMAND} umount chroot/sys
58        else
59                rm -rf chroot/sys
60                mkdir -p chroot/sys
61        fi
62fi
63
64# Copying /dev if using fakeroot
65if [ "${LB_USE_FAKEROOT}" = "true" ]
66then
67        rm -rf chroot/dev
68        find /dev | cpio -dmpu chroot
69fi
70
71if [ "${LB_BUILD_WITH_CHROOT}" = "false" ]
72then
73        exit 0
74fi
75
76if [ "${LB_CACHE}" = "true" ] && Find_files cache/binary_rootfs/filesystem*
77then
78        exit 0
79fi
80
81Echo_message "This may take a while."
82
83# Removing old chroot
84${LB_ROOT_COMMAND} rm -rf chroot/chroot
85${LB_ROOT_COMMAND} rm -rf chroot.tmp
86
87# Copying new chroot
88if [ -d cache/bootstrap ] && [ "${LB_CHROOT_FILESYSTEM}" != "none" ]
89then
90        ${LB_ROOT_COMMAND} mv chroot chroot.tmp
91        ${LB_ROOT_COMMAND} cp -a cache/bootstrap chroot
92        ${LB_ROOT_COMMAND} touch chroot/chroot.cache
93else
94        ${LB_ROOT_COMMAND} cp -a chroot chroot.tmp
95fi
96
97${LB_ROOT_COMMAND} mv chroot.tmp chroot/chroot
98
99# Handling chroot excludes
100if [ -f config/binary_rootfs/excludes ] && [ "${LB_CHROOT_FILESYSTEM}" != "squashfs" ]
101then
102        case "${LB_BUILD_WITH_CHROOT}" in
103                true)
104                        cp config/binary_rootfs/excludes chroot/chroot/excludes
105                        # Not using Chroot() here because we want explicitly /bin/bash (for the time being)
106                        chroot chroot/chroot /usr/bin/env -i xargs --arg-file=/excludes -I FILE bash -c 'rm -rf FILE'
107                        rm -f chroot/chroot/excludes
108                        ;;
109
110                false)
111                        cp config/binary_rootfs/excludes chroot/excludes
112                        # Not using Chroot() here because we want explicitly /bin/bash (for the time being)
113                        chroot chroot /usr/bin/env -i xargs --arg-file=/excludes -I FILE bash -c 'rm -rf FILE'
114                        rm -f chroot/excludes
115                        ;;
116        esac
117fi
118
119if [ -n "${LB_ROOT_COMMAND}" ]
120then
121        ${LB_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
122fi
123
124# Creating stage file
125Create_stagefile .build/binary_chroot
Note: See TracBrowser for help on using the repository browser.