From d96a1424d075aedfd9e924f4f7a3ba6901c2ce55 Mon Sep 17 00:00:00 2001
From: atz <atz@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Fri, 20 Aug 2010 20:13:36 +0000
Subject: [PATCH] Allow STAFF_CLIENT_BUILD_ID to be passed in or set in ENV

Deconflict actions for STAFF_CLIENT_BUILD_ID='current'.  Build will
always end up in datestamped directory, but a symlink will be added
to it w/ the build ID string.  That should keep everybody happy.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17296 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 build/tools/update.sh | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/build/tools/update.sh b/build/tools/update.sh
index 5b6e5293c6..c76605a7a9 100755
--- a/build/tools/update.sh
+++ b/build/tools/update.sh
@@ -153,11 +153,14 @@ if [ -n "$OPT_FULL"  ]; then
 fi
 sudo chown -R opensrf:opensrf $INSTALL
 
-BID=$(date +"%Y-%m-%dT%H:%M:%S");   # or "current"
+BIDDATE=$(date +"%Y-%m-%dT%H:%M:%S");
+BID=${STAFF_CLIENT_BUILD_ID:-$BIDDATE};   # or "current"
+
+rm -f "$XUL/current" || rm -rf "$XUL/current";      # removing the old link/build
 cd $ILS && sudo make install STAFF_CLIENT_BUILD_ID=$BID;
 sudo chown -R opensrf:opensrf $INSTALL
 
-[ -d "$XUL/$BID" ] || die_msg "New build directory $XUL/$BID was not created.  sudo make install failed?"
+[ -d "$XUL/$BID" ] || die_msg "New build directory $XUL/$BID was not created.  sudo make install failed?";
 
 if [ -z "$OPT_VERBOSE" ] ; then
     exec 1>&3   # Restore STDOUT
@@ -168,12 +171,20 @@ pwd;
 rm -f $XUL/current-client-build.zip;
 cp -r "$ILS/Open-ILS/xul/staff_client/build" ./
 zip -rq current-client-build.zip build;
-cat ./build/BUILD_ID
+cat ./build/BUILD_ID;
 rm -rf ./build;
 
+echo "build ID is '$BID'";
+
+if [ "$BID" != "$BIDDDATE" ] ; then
+    mv $BID $BIDDATE;    # Move the non-timestamp directory to timestamp-based spot
+    ln -s $BIDDATE $BID; # link back to it
+fi
 
 rm -f current;      # removing the link to the old build
-ln -s $BID current; # linking "current" to the new build
+ln -s $BIDDATE current; # linking "current" to the new build
+
+rm -f server;
 ln -s current/server server;
     
 
-- 
2.11.0