diff --git a/git-build.sh b/git-build.sh index a4d0b0b..eb17477 100755 --- a/git-build.sh +++ b/git-build.sh @@ -8,6 +8,13 @@ BASEDIR="$HOME/.git-build" +run() { + p_name="$1" + echo "[$p_name] RUN" + # Run in background and redirect output to $p_name.log + (GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2> $BASEDIR/$p_name.err) & +} + # So scripts can know we're still running (for autoupdater) touch $BASEDIR/.LOCK @@ -22,12 +29,13 @@ for project in $BASEDIR/*.source; do # Don't forget the git submodules! git clone --recursive "$source" "$p_dir" [[ $? != 0 ]] && echo "[$p_name] CLONE FAILED" && exit 1 + cd $p_dir if [[ "$p_branch" != "master" ]]; then - cd $p_dir echo "[$p_name] CHECKOUT BRANCH $p_branch" git checkout "$p_branch" [[ $? != 0 ]] && echo "[$p_name] CHECKOUT FAILED" && exit 1 fi + run $p_name fi cd "$p_dir" # Refresh remote before comparing with local @@ -38,10 +46,8 @@ for project in $BASEDIR/*.source; do # Update all submodules, for now only when the main repo changed (TODO) git pull --quiet --recurse-submodules [[ $? != 0 ]] && echo "[$p_name] PULL FAILED" && exit 1 - echo "[$p_name] RUN" + run $p_name fi - # Run in background and redirect output to $p_name.log - (GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2> $BASEDIR/$p_name.err) & done rm $BASEDIR/.LOCK