Skip to content

Commit

Permalink
save and restore environment when running recipe functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kived committed Jan 27, 2015
1 parent 6c27ac9 commit 63e0dbc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions distribute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,23 @@ function run_get_packages() {
done
}

function envfn() {
envsave=$(mktemp)
envrestore=$(mktemp)
set > $envsave
$1
set > $envrestore
eval $(grep -v -F -f$envrestore $envsave)
rm -f $envsave $envrestore
}

function run_prebuild() {
info "Run prebuild"
cd $BUILD_PATH
for module in $MODULES; do
fn=$(echo prebuild_$module)
debug "Call $fn"
$fn
envfn $fn
done
}

Expand Down Expand Up @@ -707,7 +717,7 @@ function run_build() {
if [ "X$DO_BUILD" == "X1" ] || [ ! -f "$MARKER_FN" ]; then
debug "Call $fn"
rm -f "$MARKER_FN"
$fn
envfn $fn
touch "$MARKER_FN"
else
debug "Skipped $fn"
Expand All @@ -721,7 +731,7 @@ function run_postbuild() {
for module in $MODULES; do
fn=$(echo postbuild_$module)
debug "Call $fn"
$fn
envfn $fn
done
}

Expand Down

0 comments on commit 63e0dbc

Please sign in to comment.