LP#1718036: Adding more information to About page
[working/Evergreen.git] / build / tools / make_release
index 03f09a5..b870309 100755 (executable)
@@ -2,7 +2,7 @@
 
 GIT_ABS=`git rev-parse --show-toplevel`
 GIT_BRANCH=`git rev-parse --abbrev-ref HEAD | sed 's|.*/||'`
-HEADURLBASE="http://git.evergreen-ils.org/Evergreen.git?h=refs/heads/"
+HEADURLBASE="http://git.evergreen-ils.org/?p=Evergreen.git;a=shortlog;h=refs/heads/tags/"
 HEADURL="$HEADURLBASE$GIT_BRANCH"
 
 # Drop to the root of the checkout
@@ -15,8 +15,16 @@ NO_UPGRADE=AUTO # -n
 IS_PREVIEW=AUTO # -p
 TAG_ONLY=NO # -t
 BUILD_ONLY=NO # -b
+UPGRADE_PREVIEW=NO # -r
+SKIP_I18N=NO # -i
+BUILD_BROWSER_CLIENT=NO # -c
+SKIP_XUL=NO # -x
 
-while getopts ":hv:f:F:nptb" opt; do
+# path to OpenSRF libraries
+[ "$(which osrf_config)" ] && OSRF_JS_PATH="$(osrf_config --libdir)/javascript";
+
+
+while getopts ":hv:f:F:nptbrij:cx" opt; do
     case $opt in
         v)
             VERSION=$OPTARG
@@ -30,6 +38,12 @@ while getopts ":hv:f:F:nptb" opt; do
         n)
             NO_UPGRADE=YES
         ;;
+        r)
+            UPGRADE_PREVIEW=YES
+        ;;
+        i)
+            SKIP_I18N=YES
+        ;;
         p)
             IS_PREVIEW=YES
         ;;
@@ -39,6 +53,16 @@ while getopts ":hv:f:F:nptb" opt; do
         b)
             BUILD_ONLY=YES
         ;;
+
+        j)
+            OSRF_JS_PATH="$OPTARG"
+        ;;
+        c)
+            BUILD_BROWSER_CLIENT=YES
+        ;;
+        x)
+            SKIP_XUL=YES
+        ;;
         \?)
             echo "Invalid Option: -$OPTARG"
             exit 1
@@ -56,21 +80,31 @@ while getopts ":hv:f:F:nptb" opt; do
             echo "   -p specifies that this is a preview build."
             echo "   -t turns on tag only mode."
             echo "   -b turns on build only mode."
+            echo "   -r prompt to preview upgrade SQL in editor before committing."
+            echo "   -i skip i18n; primarily useful for (quickly) testing this script."
+            echo "   -j opensrf javascript library path.  If osrf_config is found, the value derived from osrf_config --libdir."
+            echo "   -c build the experimental browser client;  requires nodejs/grunt-cli"
+            echo "   -x skip building the XUL client"
             echo "   NOTE: -t and -b override PREV_BRANCH/PREV_VERSION, but -b overrides -t."
             exit -1
         ;;
     esac
 done
 
-if [ $TAG_ONLY = "YES" ]; then
+if [ -z "$OSRF_JS_PATH" ]; then
+    echo "Unable to find OpenSRF JavaScript library path.  Specify with -j";
+    exit 1;
+fi;
+
+if [ "$TAG_ONLY" == "YES" ]; then
     PREV_BRANCH="TAG"
 fi
 
-if [ $BUILD_ONLY = "YES" ]; then
+if [ "$BUILD_ONLY" == "YES" ]; then
     PREV_BRANCH="PACKAGE"
 fi
 
-if [ $VERSION = "AUTO" ]; then
+if [ "$VERSION" == "AUTO" ]; then
     # Auto-pick version based on branch name
     echo AUTO VERSION
     VERSION=`echo $GIT_BRANCH | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)_\([0-9]\+\)_\(.\+\)$/\1.\2.\3-\4/'`
@@ -119,8 +153,8 @@ PREAMBLE
 # This defines what the preamble comes before
 RELEASE_PREAMBLE_BEFORE="Preamble: Developer instructions"
 
-if [ $PREV_BRANCH != "TAG" -a $PREV_BRANCH != "PACKAGE" ]; then
-    if [ $PREV_BRANCH = "AUTO" ]; then
+if [ "$PREV_BRANCH" != "TAG" -a "$PREV_BRANCH" != "PACKAGE" ]; then
+    if [ "$PREV_BRANCH" == "AUTO" ]; then
         echo "AUTO PREVIOUS BRANCH"
         PREV_BRANCH=`echo ${UNDER_VERSION%_*}`
         PREV_BRANCH=`git branch -r | grep "rel_${PREV_BRANCH}_[^_]\+$" | sort -rV | head -n1`
@@ -136,14 +170,14 @@ if [ $PREV_BRANCH != "TAG" -a $PREV_BRANCH != "PACKAGE" ]; then
         echo "PREVIOUS VERSION COMMIT NOT FOUND";
         exit 1
     fi
-    if [ $PREV_VERSION = "AUTO" ]; then
+    if [ "$PREV_VERSION" == "AUTO" ]; then
         echo "AUTO PREVIOUS VERSION"
         PREV_BRANCH_END=`echo $PREV_BRANCH | sed 's|.*/||'`
         PREV_VERSION=`echo $PREV_BRANCH_END | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)_\([0-9]\+\)_\(.\+\)$/\1.\2.\3-\4/'`
         PREV_VERSION=`echo $PREV_VERSION | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)_\([0-9]\+\)$/\1.\2.\3/'`
         PREV_VERSION=`echo $PREV_VERSION | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)_\(.\+\)$/\1.\2-\3/'`
         PREV_VERSION=`echo $PREV_VERSION | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)$/\1.\2/'`
-        if [ "$PREV_VERSION" = "$PREV_BRANCH_END" ]; then
+        if [ "$PREV_VERSION" == "$PREV_BRANCH_END" ]; then
             echo "AUTO PREVIOUS VERSION FAILED."
             exit 1
         fi
@@ -153,7 +187,7 @@ else
     echo "Tagging or packaging, no need for previous version"
 fi
 
-if [ $PREV_BRANCH != "PACKAGE" ]; then
+if [ "$PREV_BRANCH" != "PACKAGE" ]; then
 
     echo "Applying to Application.pm - HEAD -> $DASH_VERSION"
     echo "Alt: $SHORT_DASH_VERSION -> $DASH_VERSION"
@@ -168,7 +202,7 @@ if [ $PREV_BRANCH != "PACKAGE" ]; then
     echo "STAMP_ID with $UNDER_VERSION"
     sed -i -e "s/STAMP_ID=rel_[^ ]*/STAMP_ID=rel_$UNDER_VERSION/" $GIT_ABS/README
 
-    if [ $PREV_BRANCH != "TAG" ]; then
+    if [ "$PREV_BRANCH" != "TAG" ]; then
         if [ "$(grep "$RELEASE_PREAMBLE_HEAD" $GIT_ABS/README )" ]; then
             echo "Updating old download links"
             sed -i -e "s|\(previews/\)\?Evergreen-ILS-.*\.tar\.gz|${PREVIEW_TEXT}Evergreen-ILS-$VERSION.tar.gz|" $GIT_ABS/README
@@ -185,14 +219,14 @@ if [ $PREV_BRANCH != "PACKAGE" ]; then
 
     echo "Finding/updating old \$HeadURL\$ entries"
     HEADURLBASE=`echo ${HEADURLBASE} | sed 's/\?/\\?/'`
-    for file in `grep -Rl --exclude=make_release.sh "$HEADURLBASE" $GIT_ABS`
+    for file in `grep -Rl --exclude=make_release "$HEADURLBASE" $GIT_ABS`
     do
         echo $file
         sed -i "s|${HEADURLBASE}[A-Za-z0-9_]*|$HEADURL|" $file
     done
 
     echo "Applying \$HeadURL\$ - $HEADURL"
-    for file in `grep -Rl --exclude=apply_version.sh '\\$HeadURL\\$' $GIT_ABS`
+    for file in `grep -Rl --exclude=make_release '\\$HeadURL\\$' $GIT_ABS`
     do
         echo $file
         sed -i "s|\\\$HeadURL\\\$|$HEADURL|" $file
@@ -208,7 +242,7 @@ if [ $PREV_BRANCH != "PACKAGE" ]; then
     echo "config.upgrade_log entry for $VERSION"
     sed -i -e "s/\(INSERT INTO config.upgrade_log (version[^)]*) VALUES ('\)[0-9]*\('.*;\).*/&\n\1$VERSION\2/" $GIT_ABS/Open-ILS/src/sql/Pg/002.schema.config.sql;
 
-    if [ "$NO_UPGRADE" = "AUTO" ]; then
+    if [ "$NO_UPGRADE" == "AUTO" ]; then
         echo "Checking for DB upgrade potential...."
         git ls-tree --name-only $PREV_BRANCH -- Open-ILS/src/sql/Pg/upgrade/ | cut -d/ -f6 | cut -d. -f1 | sort > old_upgrades.txt
         git ls-tree --name-only HEAD -- Open-ILS/src/sql/Pg/upgrade/ | cut -d/ -f6 | cut -d. -f1 | sort > new_upgrades.txt
@@ -217,9 +251,10 @@ if [ $PREV_BRANCH != "PACKAGE" ]; then
         if [ -f "$UPGRADE_FILE" ]; then
             echo "Upgrade script for $PREV_VERSION-$VERSION already exists. Skipping."
             UPGRADE_FILE=""
-        elif [ -n "$UPGRADE_CHECK" ]; then
-            echo "Found Upgrade Files! Building Upgrade Script."
+        else
+            echo "Building Upgrade Script."
             echo "--Upgrade Script for $PREV_VERSION to $VERSION" > $UPGRADE_FILE
+            echo "\set eg_version '''$VERSION'''" >> $UPGRADE_FILE
             echo "BEGIN;" >> $UPGRADE_FILE
             grep "config.upgrade_log.*$VERSION" Open-ILS/src/sql/Pg/002.schema.config.sql >> $UPGRADE_FILE
             for NUM in $UPGRADE_CHECK; do
@@ -236,8 +271,10 @@ if [ $PREV_BRANCH != "PACKAGE" ]; then
                 echo "$MAYBE_DUPES" > maybe_dupes.txt
             fi
             echo ""
-            read -p "Please manually check the upgrade file."
-            ${EDITOR:-vi} $UPGRADE_FILE
+            if [ "$UPGRADE_PREVIEW" = "YES" ]; then
+                read -p "Please manually check the upgrade file."
+                ${EDITOR:-vi} $UPGRADE_FILE
+            fi;
             git add $UPGRADE_FILE
         fi
     fi
@@ -245,7 +282,7 @@ if [ $PREV_BRANCH != "PACKAGE" ]; then
     grep -i -m 1 Signed-off-by ChangeLog &> /dev/null
     if [ $? -ne 0 ]; then
         echo "Building ChangeLog"
-        git log --cherry-pick --right-only --no-merges --pretty --summary --numstat $PREV_BRANCH..HEAD > $GIT_ABS/ChangeLog
+        git log --cherry-pick --right-only --no-merges --pretty --summary --numstat $PREV_BRANCH...HEAD > $GIT_ABS/ChangeLog
     else
         echo "Not overwriting existing ChangeLog!"
     fi
@@ -270,48 +307,78 @@ else
     echo "Running autoreconf"
     autoreconf -i
 fi
-cd build/i18n
-echo "Building i18n"
-make install_all_locales
-echo "i18n Cleanup"
-cd ..
-rm -rf i18n
+
+if [ "$SKIP_I18N" == "NO" ]; then
+    cd build/i18n
+    echo "Building i18n"
+    make install_all_locales
+    echo "i18n Cleanup"
+    cd ..
+    rm -rf i18n
+    cd ..
+fi;
+
 echo "Installing Dojo"
-cd ..
 if [ ! -f "../dojo.tgz" ]; then
     wget http://evergreen-ils.org/downloads/dojo.tgz -O ../dojo.tgz
 fi
 tar xzf ../dojo.tgz -C Open-ILS/web/js/dojo/
-echo "Grabbing XULRunner (to avoid issues with version changes)"
+
+# set version for later
 cd Open-ILS/xul/staff_client
 XULRUNNER_VERSION=`grep '^XULRUNNER_VERSION' Makefile.am`
 XULRUNNER_VERSION=${XULRUNNER_VERSION##XULRUNNER_VERSION=}
-wget http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/xulrunner-$XULRUNNER_VERSION.en-US.win32.zip
-wget http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/xulrunner-$XULRUNNER_VERSION.en-US.linux-i686.tar.bz2
 
 echo "Prepping server download files"
-cd ../../../../
+
+if [ "$BUILD_BROWSER_CLIENT" == "YES" ]; then
+    cd ../../../
+    echo "Building browser staff client"
+    cd Open-ILS/web/js/ui/default/staff/
+    npm install   # fetch build dependencies
+    grunt build # copy to build dir and minify JS files
+    # npm cache is big and unnecessary in the final build. remove it.
+    rm -r node_modules 
+    cd ../../../../../../../ # release dir
+else
+    echo "Skipping browser client build"
+    cd ../../../../
+fi
+
 tar czf Evergreen-ILS-$VERSION.tar.gz Evergreen-ILS-$VERSION/
 md5sum Evergreen-ILS-$VERSION.tar.gz > Evergreen-ILS-$VERSION.tar.gz.md5
 if [ $PREV_BRANCH != "PACKAGE" ]; then # We need to have tagged to do this ;)
     cp Evergreen-ILS-$VERSION/ChangeLog ChangeLog-$PREV_VERSION-$VERSION
 fi
 
-echo "Running enough of configure to build staff client"
-cd Evergreen-ILS-$VERSION/
-./configure --disable-core --disable-web --disable-updates --disable-apache-modules --disable-reporter
-
-echo "Building Release Staff Clients"
-cd Open-ILS/xul/staff_client
-make rigrelease
-make STAFF_CLIENT_STAMP_ID=rel_$UNDER_VERSION build
-make win-client
-mv evergreen_staff_client_setup.exe ../../../../evergreen-setup-$VERSION.exe
-make linux-client
-mv evergreen_staff_client.tar.bz2 ../../../../evergreen-client-$VERSION.tar.bz2
-cd ../../../../
-md5sum evergreen-setup-$VERSION.exe > evergreen-setup-$VERSION.exe.md5
-md5sum evergreen-client-$VERSION.tar.bz2 > evergreen-client-$VERSION.tar.bz2.md5
+if [ "$SKIP_XUL" = "NO" ]; then
+    echo "Running enough of configure to build staff client"
+    cd Evergreen-ILS-$VERSION/
+    ./configure --disable-core --disable-web --disable-updates --disable-apache-modules --disable-reporter
+
+    echo "Building Release Staff Clients"
+    cd Open-ILS/xul/staff_client
+
+    echo "Grabbing XULRunner (to avoid issues with version changes)"
+    wget http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/xulrunner-$XULRUNNER_VERSION.en-US.win32.zip
+    wget http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/xulrunner-$XULRUNNER_VERSION.en-US.linux-i686.tar.bz2
+    wget http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/xulrunner-$XULRUNNER_VERSION.en-US.linux-x86_64.tar.bz2
+
+    make rigrelease
+    make STAFF_CLIENT_STAMP_ID=rel_$UNDER_VERSION OPENSRF_JSLIBS="$OSRF_JS_PATH" build
+    make win-client
+    mv evergreen_staff_client_setup.exe ../../../../evergreen-setup-$VERSION.exe
+    make linux32-client
+    mv evergreen_staff_client_i686.tar.bz2 ../../../../evergreen-client-${VERSION}_i686.tar.bz2
+    make linux64-client
+    mv evergreen_staff_client_x86_64.tar.bz2 ../../../../evergreen-client-${VERSION}_x86_64.tar.bz2
+    cd ../../../../
+    md5sum evergreen-setup-$VERSION.exe > evergreen-setup-$VERSION.exe.md5
+    md5sum evergreen-client-${VERSION}_i686.tar.bz2 > evergreen-client-${VERSION}_i686.tar.bz2.md5
+    md5sum evergreen-client-${VERSION}_x86_64.tar.bz2 > evergreen-client-${VERSION}_x86_64.tar.bz2.md5
+else
+    echo "Skipping XULRunner staff client build"
+fi
 
 echo "Removing build directory"
 rm -rf Evergreen-ILS-$VERSION/
@@ -319,7 +386,7 @@ rm -rf Evergreen-ILS-$VERSION/
 echo ""
 echo "FOR YOU TODO:"
 echo "* TEST the release"
-if [ $PREV_BRANCH != "PACKAGE" ]; then
+if [ "$PREV_BRANCH" != "PACKAGE" ]; then
     echo "* Push release branch"
 fi
 echo "* Upload files"