From 49cbfdd72d0743ef27877b8826810107283e977b Mon Sep 17 00:00:00 2001 From: Salvador Cuñat Date: Sun, 11 Jun 2017 21:58:44 +0200 Subject: smtk2ssrf-mxe-build.sh: add a flag for git repo Previous script would fail on git folders that pull from more than one repo. That's not a general case, but pretty usual for developers pulling/pushing to github. BTW in this cases, a lind git pull doesn't ensure we are pulling from the right repo. When run without flag, default to pull --rebase. At the same time introduce a tiny func to return a message and bail out after some command failures. --- packaging/windows/smtk2ssrf-mxe-build.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/packaging/windows/smtk2ssrf-mxe-build.sh b/packaging/windows/smtk2ssrf-mxe-build.sh index d0a5bf53f..126dd1bd2 100755 --- a/packaging/windows/smtk2ssrf-mxe-build.sh +++ b/packaging/windows/smtk2ssrf-mxe-build.sh @@ -62,6 +62,15 @@ EXECDIR=$(pwd) BASEDIR=$(cd "$EXECDIR/.."; pwd) BUILDDIR=$(cd "$EXECDIR"; pwd) +GITREPO="" + +# Display an error message if we need to bail out +# +function aborting() { + echo -e "$RED----> $1. Aborting.$DEFAULT" + exit 1 +} + echo -e "$BLUE-> $BUILDDIR$DEFAULT" if [[ ! -d "$BASEDIR"/mxe ]] ; then @@ -87,6 +96,8 @@ else shift;; -d|--dir) DATADIR="$2" shift;; + -r|--repo) GITREPO="$2" + shift;; esac shift done @@ -134,11 +145,7 @@ if [ ! -f "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib/libmdb.a ]; then --enable-shared \ --disable-man \ --disable-gmdb2 - make $JOBS >/dev/null - if [ $? -ne 0 ]; then - echo -e "$RED---> Building mdbtools failed. Aborting ...$DEFAULT " - exit 1 - fi + make $JOBS >/dev/null || aborting "Building mdbtools failed." make install else echo -e "$BLUE---> Prebuilt mxe mdbtools ... $DEFAULT" @@ -148,19 +155,15 @@ fi # cd "$BASEDIR/subsurface" git reset --hard master && echo -e "$BLUE---> Uncommited changes to Subsurface (if any) dropped$DEFAULT" -git pull "$(git remote -v |grep fetch |awk '{print $1}')" master -if [ $? -ne 0 ]; then - echo -e "$RED---> git pull failed, Subsurface not updated$DEFAULT" +if [ ! -z "$GITREPO" ]; then + git pull --rebase "$GITREPO" master || aborting "git pull failed, Subsurface not updated" else - echo -e "$BLUE---> Subsurface updated$DEFAULT" + git pull --rebase || aborting "git pull failed, Subsurface not updated" fi +echo -e "$BLUE---> Subsurface updated$DEFAULT" if [ "$SSRF_TAG" != "" ]; then - git checkout "$SSRF_TAG" - if [ $? -ne 0 ]; then - echo -e "$RED---> Failed to checkout Subsurface's $SSRF_TAG. Abort building. $DEFAULT" - exit 1 - fi + git checkout "$SSRF_TAG" || aborting "Failed to checkout Subsurface's $SSRF_TAG." fi # Every thing is ok. Go on. -- cgit v1.2.3-70-g09d2