Moving partial python rewrite to separate branch, let's do it in the jessie+1 cycle...
[debian-live-build.git] / scripts / build / source_hooks
blob3c22edfd19a84dcc24102425003d07862b7813bc
1 #!/bin/sh
3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
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.
11 set -e
13 # Including common functions
14 [ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
16 # Setting static variables
17 DESCRIPTION="$(Echo 'execute hooks in source')"
18 HELP=""
19 USAGE="${PROGRAM} [--force]"
21 Arguments "${@}"
23 # Reading configuration files
24 Read_conffiles config/all config/common config/bootstrap config/chroot config/source config/source
25 Set_defaults
27 Echo_message "Begin executing hooks..."
29 # Requiring stage file
30 Require_stagefile .build/config .build/bootstrap
32 # Checking stage file
33 Check_stagefile .build/source_hooks
35 # Checking lock file
36 Check_lockfile .lock
38 # Creating lock file
39 Create_lockfile .lock
41 ## Processing distribution hooks
43 # Running hooks
44 for _HOOK in ${LB_BINARY_HOOKS}
46 for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks
48 for FILE in "${LOCATION}"/????-"${_HOOK}".source
50 if [ -e "${FILE}" ]
51 then
52 cd source
53 "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
54 cd "${OLDPWD}"
56 done
57 done
58 done
60 ## Processing local hooks
62 if Find_files config/hooks/*.source
63 then
64 for HOOK in config/hooks/*.source
66 # Making hook executable
67 if [ ! -x "${HOOK}" ]
68 then
69 chmod +x "${HOOK}"
72 # Executing hook
73 ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
74 done
76 # Creating stage file
77 Create_stagefile .build/source_hooks