From 1e309b660925ea615025cec119c0ab3b7432771f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 22 Sep 2013 10:03:04 -0700 Subject: [PATCH] scripts: PACKER_NO_BUILD_PARALLEL to build in sequence --- scripts/build.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 8d0976b6b..8ba8d3d4f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -26,6 +26,9 @@ if [ "$(go env GOOS)" = "windows" ]; then EXTENSION=".exe" fi +# Make sure that if we're killed, we kill all our subprocseses +trap "kill 0" SIGINT SIGTERM EXIT + # If we're building a race-enabled build, then set that up. if [ ! -z $PACKER_RACE ]; then echo -e "${OK_COLOR}--> Building with race detection enabled${NO_COLOR}" @@ -50,7 +53,16 @@ waitAll() { fi } -echo -e "${OK_COLOR}--> NOTE: Compilation of components will be done in parallel.${NO_COLOR}" +waitSingle() { + if [ ! -z $PACKER_NO_BUILD_PARALLEL ]; then + waitAll + fi +} + +if [ -z $PACKER_NO_BUILD_PARALLEL ]; then + echo -e "${OK_COLOR}--> NOTE: Compilation of components " \ + "will be done in parallel.${NO_COLOR}" +fi # Compile the main Packer app echo -e "${OK_COLOR}--> Compiling Packer${NO_COLOR}" @@ -62,6 +74,8 @@ go build \ -o bin/packer${EXTENSION} . ) & +waitSingle + # Go over each plugin and build it for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do PLUGIN_NAME=$(basename ${PLUGIN}) @@ -73,6 +87,8 @@ for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do -v \ -o bin/packer-${PLUGIN_NAME}${EXTENSION} ${PLUGIN} ) & + + waitSingle done waitAll