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

« back to all changes in this revision

Viewing changes to scripts/build/chroot_hooks

  • 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_chroot_hooks(1) - execute hooks in 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 'execute hooks in 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 executing hooks..."
 
27
 
 
28
# Requiring stage file
 
29
Require_stagefile .stage/config .stage/bootstrap
 
30
 
 
31
# Checking stage file
 
32
Check_stagefile .stage/chroot_hooks
 
33
 
 
34
# Checking lock file
 
35
Check_lockfile .lock
 
36
 
 
37
# Creating lock file
 
38
Create_lockfile .lock
 
39
 
 
40
# Processing hooks
 
41
HOOKS="$(echo ${LH_HOOKS} ${LH_PACKAGES_LISTS} ${LH_TASKS} | sed -e 's| |\n|g' | sort -u)"
 
42
 
 
43
for HOOK in ${HOOKS}
 
44
do
 
45
        if [ -f ${LH_BASE:-/usr/share/live-helper}/hooks/"${HOOK}" ]
 
46
        then
 
47
                # Copying hook
 
48
                cp ${LH_BASE:-/usr/share/live-helper}/hooks/"${HOOK}" chroot/root
 
49
 
 
50
                # Making hook executable
 
51
                if [ ! -x chroot/root/"${HOOK}" ]
 
52
                then
 
53
                        chmod +x chroot/root/"${HOOK}"
 
54
                fi
 
55
 
 
56
                # Executing hook
 
57
                Chroot chroot "./root/${HOOK}" || ( Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 )
 
58
 
 
59
                # Removing hook
 
60
                rm -f chroot/root/"${HOOK}"
 
61
 
 
62
                # Creating stage file
 
63
                Create_stagefile .stage/chroot_hooks
 
64
        fi
 
65
done