Staff Client Build/Update Enhancements patch from Thomas Berezansky
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Aug 2010 19:04:20 +0000 (19:04 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Aug 2010 19:04:20 +0000 (19:04 +0000)
Among other things, allows cross-compilation of Windows installers from Unix environments via NSIS, and enables Mozilla's upgrade mechanism for performing upgrades without needing to download and execute external files.

See https://bugs.launchpad.net/evergreen/+bug/616452/ for more details.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17330 dcc99617-32d9-48b4-a31d-7c20da2025e4

20 files changed:
Makefile.am
Open-ILS/examples/apache/eg.conf
Open-ILS/src/Makefile.am
Open-ILS/updates/Makefile.am [new file with mode: 0644]
Open-ILS/updates/check [new file with mode: 0755]
Open-ILS/updates/download [new file with mode: 0755]
Open-ILS/updates/manualupdate.html [new file with mode: 0755]
Open-ILS/updates/update.rdf [new file with mode: 0755]
Open-ILS/updates/updatedetails.html [new file with mode: 0644]
Open-ILS/xul/staff_client/Makefile.am
Open-ILS/xul/staff_client/chrome/content/auth/controller.js
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/main/main.js
Open-ILS/xul/staff_client/chrome/content/main/main.xul
Open-ILS/xul/staff_client/defaults/preferences/autoupdate.js [new file with mode: 0644]
Open-ILS/xul/staff_client/external/make_updates.sh [new file with mode: 0755]
Open-ILS/xul/staff_client/install.rdf
Open-ILS/xul/staff_client/update.rdf [new file with mode: 0644]
Open-ILS/xul/staff_client/windowssetup.nsi [new file with mode: 0644]
configure.ac

index e669bc6..35a79cd 100644 (file)
@@ -15,6 +15,7 @@ export ETCDIR=@sysconfdir@
 export WEBDIR=@localstatedir@/web
 export CGIDIR=@localstatedir@/cgi-bin
 export TEMPLATEDIR=@localstatedir@/templates
+export UPDATESDIR=@localstatedir@/updates
 
 export datadir=@localstatedir@/data
 export circrulesdir=@localstatedir@/circ
@@ -38,5 +39,5 @@ export DBI_LIBS = @DBI_LIBS@
 export OPENSRF_HEADERS = @OPENSRF_HEADERS@
 export OPENSRF_LIBS = @OPENSRF_LIBS@
 
-SUBDIRS = Open-ILS/src Open-ILS/web Open-ILS/xul/staff_client
+SUBDIRS = Open-ILS/src Open-ILS/web Open-ILS/updates Open-ILS/xul/staff_client
 
index 17eb787..b1de058 100644 (file)
@@ -65,6 +65,29 @@ Alias /cgi-bin/ "/openils/var/cgi-bin/"
 </Directory>
 
 
+# ----------------------------------------------------------------------------------
+# Updates folder
+# ----------------------------------------------------------------------------------
+Alias /updates/ "/openils/var/updates/pub/"
+<Directory "/openils/var/updates/pub">
+       <Files check>
+               ForceType cgi-script
+       </Files>
+       <Files update.rdf>
+               ForceType cgi-script
+       </Files>
+       <Files manualupdate.html>
+               ForceType cgi-script
+       </Files>
+       <Files download>
+               ForceType cgi-script
+       </Files>
+       AllowOverride None
+       Options None
+       Allow from all
+       Options ExecCGI
+</Directory>
+
 
 # ----------------------------------------------------------------------------------
 # OPTIONAL: Set how long the client will cache our content.  Change to suit
index 690bd4f..e957845 100644 (file)
@@ -153,7 +153,7 @@ oilsinclude_HEADERS = $(headsdir)/idl_fieldmapper.h $(headsdir)/oils_constants.h
 
 # Install everything that did not get installed by autotools
 
-install-data-hook: $(OILSCORE_INST) $(OILSWEB_INST) $(OILSREP_INST)
+install-data-hook: $(OILSCORE_INST) $(OILSWEB_INST) $(OILSUPDATES_INST) $(OILSREP_INST)
 
 uninstall-hook:
        rm -R $(perldir)
diff --git a/Open-ILS/updates/Makefile.am b/Open-ILS/updates/Makefile.am
new file mode 100644 (file)
index 0000000..1b9fe85
--- /dev/null
@@ -0,0 +1,25 @@
+#---------------------------------------------------------
+# Makefile.am for updates
+## Process this file with automake to generate Makefile.in
+#---------------------------------------------------------
+
+if BUILDILSUPDATES
+OILSUPDATES_INST = updates-install
+
+endif
+
+install-exec-local: updates-install
+
+uninstall-hook:
+       rm -R $(UPDATESDIR)
+
+updates-install:
+       $(MKDIR_P) $(DESTDIR)$(UPDATESDIR)
+       $(MKDIR_P) $(DESTDIR)$(UPDATESDIR)/patch
+       $(MKDIR_P) $(DESTDIR)$(UPDATESDIR)/pub
+       $(MKDIR_P) $(DESTDIR)$(UPDATESDIR)/archives
+       cp @top_srcdir@/Open-ILS/updates/check $(DESTDIR)$(UPDATESDIR)/pub
+       cp @top_srcdir@/Open-ILS/updates/download $(DESTDIR)$(UPDATESDIR)/pub
+       cp @top_srcdir@/Open-ILS/updates/manualupdate.html $(DESTDIR)$(UPDATESDIR)/pub
+       cp @top_srcdir@/Open-ILS/updates/update.rdf $(DESTDIR)$(UPDATESDIR)/pub
+       cp @top_srcdir@/Open-ILS/updates/updatedetails.html $(DESTDIR)$(UPDATESDIR)/pub
diff --git a/Open-ILS/updates/check b/Open-ILS/updates/check
new file mode 100755 (executable)
index 0000000..86038bc
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+echo "Content-Type: text/xml"
+cat <<HEAD
+
+<?xml version="1.0"?>
+<updates>
+HEAD
+UPDATE_LOC=$(dirname $PWD)
+PATH_INFO=${PATH_INFO#/}
+CHANNEL=${PATH_INFO%%/*}
+PATH_INFO=${PATH_INFO#*/}
+VERSION=${PATH_INFO%%/*}
+if [ ! -f "$UPDATE_LOC/patch/$CHANNEL/VERSION" ]; then
+       CHANNEL=""
+else
+       CHANNEL="$CHANNEL/"
+fi
+if [ -f "$UPDATE_LOC/patch/${CHANNEL}VERSION" ]; then
+       URLBASE="http://$HTTP_HOST$(dirname $SCRIPT_NAME)/${CHANNEL}"
+       CURVERSION=$(cat $UPDATE_LOC/patch/${CHANNEL}VERSION)
+       [ -f "$UPDATE_LOC/patch/${CHANNEL}DETAILS" ] && DETAILSURL=$(cat $UPDATE_LOC/${CHANNEL}DETAILS)
+       [ -n "$DETAILSURL" ] && DETAILSURL=" detailsURL=\"$DETAILSURL\""
+       if [ -n "$CURVERSION" -a "$VERSION" != "$CURVERSION" ]; then
+               if [ -f "$UPDATE_LOC/pub/${CHANNEL}$CURVERSION.mar" -a -f "$UPDATE_LOC/patch/${CHANNEL}$CURVERSION.patchline" ]; then
+                       echo "<update type=\"minor\" version=\"$CURVERSION\"$DETAILSURL>"
+                       sed -e "s|URL=\"|URL=\"$URLBASE|" "$UPDATE_LOC/patch/${CHANNEL}$CURVERSION.patchline"
+                       if [ -f "$UPDATE_LOC/pub/${CHANNEL}$VERSION-$CURVERSION.mar" -a -f "$UPDATE_LOC/patch/${CHANNEL}$VERSION-$CURVERSION.patchline" ]; then
+                               sed -e "s|URL=\"|URL=\"$URLBASE|" "$UPDATE_LOC/patch/${CHANNEL}$VERSION-$CURVERSION.patchline"
+                       fi
+                       echo "</update>"
+               fi
+       fi
+fi
+cat <<FOOTER
+</updates>
+FOOTER
diff --git a/Open-ILS/updates/download b/Open-ILS/updates/download
new file mode 100755 (executable)
index 0000000..51abc44
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+FILENAME=$(basename "$PATH_INFO")
+FILENAME=${FILENAME%.xpi}
+if [ -n "$FILENAME" -a -f "./clients/$FILENAME.xpi" ]; then
+echo "Content-Disposition: attachment"
+echo ""
+cat "./clients/$FILENAME.xpi"
+else
+echo ""
+echo "?"
+fi
diff --git a/Open-ILS/updates/manualupdate.html b/Open-ILS/updates/manualupdate.html
new file mode 100755 (executable)
index 0000000..09de1b6
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+echo "Content-Type: text/html"
+echo ""
+if [ -f ../patch/manual.html ]; then
+       cat ../patch/manual.html
+       exit
+fi
+cat <<ENDHEADER
+<html>
+<head>
+<title>Evergreen Staff Client</title>
+</head>
+<body>
+<h1>Evergreen Staff Client</h1>
+ENDHEADER
+if [ -f ../patch/win/VERSION ]; then
+       echo "<h2>Windows</h2>"
+       VERSION=$(cat ../patch/win/VERSION)
+       if [ -f clients/${VERSION}_setup.exe ]; then
+               echo "<p>An installer for Windows is available.</p>"
+               echo "<p><a href=\"clients/${VERSION}_setup.exe\">Click here to download the installer (version $VERSION)</a></p>"
+       else
+               echo "<p>No installer is currently available for Windows.</p>"
+       fi
+fi
+if [ -f ../patch/lin/VERSION ]; then
+       echo "<h2>Linux</h2>"
+       VERSION=$(cat ../patch/lin/VERSION)
+       if [ -f clients/${VERSION}.tar.bz2 ]; then
+               echo "<p>A bundle for Linux is available.</p>"
+               echo "<p><a href=\"clients/${VERSION}.tar.bz2\">Click here to download the bundle (version $VERSION)</a></p>"
+       else
+               echo "<p>No bundle is currently available for Linux.</p>"
+       fi
+fi
+if [ -f ../patch/VERSION ]; then
+       echo "<h2>XULRunner App Bundle</h2>"
+       VERSION=$(cat ../patch/VERSION)
+       if [ -f clients/${VERSION}_client.xpi ]; then
+               echo "<p>A XULRunner app bundle is available.</p>"
+               echo "<p><a href=\"download/${VERSION}_client.xpi\">Click here to download the XULRunner app bundle (version $VERSION)</a></p>"
+               echo "<p>This bundle can be installed via the --install-app command on xulrunner itself and should be compatible with all platforms XULRunner runs on.</p>"
+       else
+               echo "<p>No XULRunner app bundle is currently available.</p>"
+       fi
+       echo "<h2>Firefox Extension</h2>"
+       if [ -f ${VERSION}_extension.xpi ]; then
+               echo "<p>A Firefox Extension is available.</p>"
+               echo "<p><a href=\"${VERSION}_extension.xpi\">Click here to install the extension (version $VERSION)</a>"
+       else
+               echo "<p>No Firefox Extension is currently available.</p>"
+       fi
+fi
+cat <<ENDFOOTER
+</body>
+</html>
+ENDFOOTER
diff --git a/Open-ILS/updates/update.rdf b/Open-ILS/updates/update.rdf
new file mode 100755 (executable)
index 0000000..1479e78
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+if [ ! -f ../patch/update.rdf ]; then
+       echo "Status: 404 Not Found"
+else
+       echo "Content-Type: text/xml"
+       echo ""
+       sed "s|::HOSTNAME::|$HTTP_HOST|" ../patch/update.rdf
+fi
diff --git a/Open-ILS/updates/updatedetails.html b/Open-ILS/updates/updatedetails.html
new file mode 100644 (file)
index 0000000..1fe0ca2
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+<title>Evergreen Staff Client Update Details</title>
+</head>
+<body>
+<h1>Evergreen Staff Client Update Details</h1>
+<p>In general, one can assume bug fixes and possibly new functionality from any given update.</p>
+<p>In practice, no update specific page has been placed here yet.</p>
+</body>
+</html>
index ec726ee..a92d495 100644 (file)
@@ -4,13 +4,27 @@
 #---------------------------------------------------------
 
 export STAFF_CLIENT_BUILD_ID = $$(/bin/cat build/BUILD_ID)
+export STAFF_CLIENT_VERSION = $$(/bin/cat build/VERSION)
+export STAFF_CLIENT_STAMP_ID = $$(/bin/cat build/STAMP_ID)
 
 # from http://closure-compiler.googlecode.com/files/compiler-latest.zip  FIXME: Autotools this?
 export CLOSURE_COMPILER_JAR = ~/closure-compiler/compiler.jar
+XULRUNNER_VERSION=1.9.2.8
+XULRUNNER_WINFILE=xulrunner-$(XULRUNNER_VERSION).en-US.win32.zip
+XULRUNNER_LINUXFILE=xulrunner-$(XULRUNNER_VERSION).en-US.linux-i686.tar.bz2
+XULRUNNER_URL=http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/$(XULRUNNER_VERSION)/runtimes/
 
 OPENSRF_JSLIBS = "$(OPENSRF_LIBS)/javascript"
 CHROME_LOCALES = $$(ls -1 chrome/locale)
 SKIN_CSS = $$(ls -1 server/skin/*css | sed -e "s/.css/_custom.css/")
+UPDATESDIR=@localstatedir@/updates
+
+SVN=svn # Because some people might need to override this to 'git svn' or something
+
+export NSIS_EXTRAOPTS
+export NSIS_WICON=$$(if [ -f client/evergreen.ico ]; then echo '-DWICON'; fi)
+export NSIS_AUTOUPDATE=$$([ -f client/defaults/preferences/autoupdate.js ] && echo '-DAUTOUPDATE')
+export NSIS_DEV=$$([ -f client/defaults/preferences/developers.js ] && echo '-DDEVELOPER')
 
 #------------------------------
 # Build ILS XUL CLIENT/SERVER
@@ -26,12 +40,6 @@ devbuild: build
        @echo ' * Copying in developer preferences'
        @cp external/developers.js build/defaults/preferences/
 
-extension: build
-       @echo ' * Packaging as an XPI'
-       @perl -ne '@f = split /\s+/; if (/open_ils_staff_client/) { if (! /chrome:\/\/open_ils_staff_client/) { $$f[ scalar(@f) - 1 ] = "chrome/" . $$f[ scalar(@f) - 1 ]; }; print join(" ",@f) . "\n"; }' build/chrome/chrome.manifest > build/chrome.manifest
-       @(cd build/ && zip -q -r evergreen.xpi * -x server/\* -x defaults/preferences/standalone_xul_app.js)
-       @md5sum build/evergreen.xpi > build/evergreen.xpi.md5
-
 build: build_dir chrome2remote localize_manifest generated custom_skins open-ils stamp 
        @echo To test the staff client:
        @echo "  cd build/"
@@ -46,13 +54,14 @@ build_dir:
        @cp -fR defaults build/
        @cp -fR components build/
        @cp application.ini build/
-       @cp install.rdf build/
+       @if [ -f "install.mccoy.rdf" ]; then cp install.mccoy.rdf build/install.rdf; else cp install.rdf build/; fi
        @cp -fR build/chrome/content/util/ build/server/
        @cp -fR build/chrome/content/auth/ build/server/
        @cp build/chrome/content/main/constants.js build/server/main/constants.js
        @cp build/chrome/content/main/bindings.xml build/server/main/bindings.xml
        @cp build/chrome/content/OpenILS/data.js build/server/OpenILS/data.js
        @cp build/chrome/content/OpenILS/global_util.js build/server/OpenILS/global_util.js
+       @if [ -d branding ]; then copy -fR branding/* build/; fi
        @external/prune_dirs.sh build/
 
 # Convert chrome to remote for server localization
@@ -67,18 +76,48 @@ localize_manifest:
                if [ "$$loc" != "en-US" ]; then ( echo "locale open_ils_staff_client $$loc locale/$$loc/" >> build/chrome/chrome.manifest ) ; fi; \
        done;
 
+# On this page:
+# https://developer.mozilla.org/en/xul_application_packaging
+# The Documentation states:
+# BUILD ID should be a unique build identifier, usually date based, and should be different for each released version
+# VERSION should be in a format as described here:
+# https://developer.mozilla.org/en/Toolkit_version_format
+
+# The default "automatic" BUILD ID is acceptable.
+
+# The version from the README usually conforms to that documentation, unless it is trunk.
+# If we are in trunk, we probably have svn kicking around, ask it for the revision and build an appropriate version string.
+
+# Neither really applies to the STAMP, though.
+# The method below gives the same format STAMPS as previous instructions provided. If README has version 1.2.3.4 then STAMP_ID will become rel_1_2_3_4.
+# Trunk VERSION will end up with 0trunk.release, trunk STAMP ID will be 0trunk_release.
 stamp:
        @/bin/date +"%Y%m%d.%H%M%S" > build/BUILD_ID
        @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "Stamping with Build ID: ${STAFF_CLIENT_BUILD_ID}" ; echo ${STAFF_CLIENT_BUILD_ID} > build/BUILD_ID ) ; fi
        @if [ -z "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "No Build ID for versioning" ; echo "none" > build/BUILD_ID ) ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i s/^Version=.\*/Version=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then find build/ -name '*.css' -exec sed -i s/xul\\\/server/xul\\\/${STAFF_CLIENT_BUILD_ID}\\\/server/g {} \; ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then find build/ -name '*.xul' -exec sed -i s/xul\\\/server/xul\\\/${STAFF_CLIENT_BUILD_ID}\\\/server/g {} \; ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then find build/ -name '*.html' -exec sed -i s/xul\\\/server/xul\\\/${STAFF_CLIENT_BUILD_ID}\\\/server/g {} \; ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then find build/ -name '*.xhtml' -exec sed -i s/xul\\\/server/xul\\\/${STAFF_CLIENT_BUILD_ID}\\\/server/g {} \; ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then find build/ -name '*.js' -exec sed -i s/xul\\\/server/xul\\\/${STAFF_CLIENT_BUILD_ID}\\\/server/g {} \; ; fi
-       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then find build/ -name '*.xml' -exec sed -i s/xul\\\/server/xul\\\/${STAFF_CLIENT_BUILD_ID}\\\/server/g {} \; ; fi
+       @sed -n -e '1 s/^.* \([^ ]*\)$$/\1/p' @top_srcdir@/README > build/VERSION
+       @if [ "${STAFF_CLIENT_VERSION}" == "trunk" ]; then echo "0trunk.$$(${SVN} info | sed -n -e 's/Last Changed Rev: \([0-9][0-9]*\)/\1/p')" > build/VERSION; fi 
+       @if [ -n "${STAFF_CLIENT_VERSION}" ]; then ( echo "Stamping with Version: ${STAFF_CLIENT_VERSION}" ; echo ${STAFF_CLIENT_VERSION} > build/VERSION ) ; fi
+       @if [ -z "${STAFF_CLIENT_VERSION}" ]; then ( echo "No Version" ; echo "none" > build/VERSION ) ; fi
+       @sed -e 's/\./_/g' -e 's/^\([0-9_]*\)$$/rel_&/' build/VERSION > build/STAMP_ID
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "Stamping with Stamp ID: ${STAFF_CLIENT_STAMP_ID}" ; echo ${STAFF_CLIENT_STAMP_ID} > build/STAMP_ID ) ; fi
+       @if [ -z "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "No Stamp ID for versioning" ; echo "none" > build/STAMP_ID ) ; fi
+       @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e s/^Version=.\*/Version=${STAFF_CLIENT_VERSION}/ build/application.ini ; fi
+       @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e "s|<em:version>.*</em:version>|<em:version>${STAFF_CLIENT_VERSION}</em:version>|" build/install.rdf ; fi
+       @if [ -n "${STAFF_CLIENT_VERSION}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_VERSION *= '\)'/\1${STAFF_CLIENT_VERSION}'/" {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i -e s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.css' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.xul' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.html' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.xhtml' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.js' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.xml' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
+       @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_STAMP *= '\)'/\1${STAFF_CLIENT_STAMP_ID}'/" {} \; ; fi
+       @if [ -z "${AUTOUPDATE_HOST}" ]; then rm -f build/defaults/preferences/autoupdate.js; fi
+       @if [ -z "${AUTOUPDATE_HOST}" ]; then sed -i -e /updateURL/d build/install.rdf; fi
+       @if [ -n "${AUTOUPDATE_HOST}" ]; then echo "Applying automatic update host ${AUTOUPDATE_HOST}"; fi
+       @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/defaults/preferences/autoupdate.js; fi
+       @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/install.rdf; fi
 
 bell:
        @perl -e 'print "Ringing bell..." . chr(7) . "\n";'
@@ -108,10 +147,10 @@ server-xul: build
        @echo $@
        mkdir -p $(WEBDIR)
        mkdir -p $(WEBDIR)/xul/
-       @echo "BUILD_ID = $(STAFF_CLIENT_BUILD_ID)"
-       @echo "Copying xul into $(WEBDIR)/xul/$(STAFF_CLIENT_BUILD_ID)"
-       mkdir -p "$(WEBDIR)/xul/$(STAFF_CLIENT_BUILD_ID)"
-       cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "${WEBDIR}/xul/${STAFF_CLIENT_BUILD_ID}/"
+       @echo "STAMP_ID = $(STAFF_CLIENT_STAMP_ID)"
+       @echo "Copying xul into $(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
+       mkdir -p "$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
+       cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "${WEBDIR}/xul/${STAFF_CLIENT_STAMP_ID}/"
 
 compress-javascript: build
        @echo "Size of build/ before compression = " `du -sh build/`
@@ -123,3 +162,102 @@ compress-javascript: build
        @find build/ -name '*.js~' -exec perl -e '$$a = "{}"; chop $$a; `mv $$a~ $$a`;' \;
        @echo "Size of build/ (minus compression.err) after compression = " `du -sh --exclude compression.err build/`
 
+# Easy way to make all three kinds of clients
+
+clients:
+       @make win-client
+       @make linux-client
+       @make generic-client
+
+# By doing this we don't change the original build in the build folder
+# Great for adding/changing things without a full rebuild
+
+client_dir:
+       @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
+       @echo 'Prepping Client Set'
+       @rm -rf client/
+       @mkdir -p client
+       @cp -fR build/* client/
+       @rm -rf client/server/
+       @rm -f client/build.tar*
+
+# When building as a standalone client install.rdf is a bad thing
+# as we haven't "sanitized" the client for extension use
+
+client_app: client_dir
+       @echo 'Cleaning Extension Information'
+       @rm -f client/install.rdf
+
+# If automatic updates are enabled, or the standalone_xul_app.js is present,
+# the extension can break Firefox.
+# Remove those, and we need a chrome.manifest
+
+client_ext: client_dir
+       @echo 'Cleaning App Information'
+       @rm -f client/application.ini
+       @rm -f client/defaults/preferences/autoupdate.js
+       @rm -f client/defaults/preferences/autochannel.js
+       @rm -f client/defaults/preferences/standalone_xul_app.js
+       @echo 'Prepping chrome.manifest'
+       @perl -ne 'if(/open_ils_staff_client/) { s/ (?!chrome:\/\/open_ils_staff_client)([^ ]*)$$/ chrome\/\1/; print; }' client/chrome/chrome.manifest > client/chrome.manifest
+
+# Would merge client_ext into this one, but this way an installer that doesn't
+# use an xpi can be made for extension later, if desired
+
+extension: client_ext
+       @echo ' * Packaging as an XPI'
+       @(cd client/ && zip -q -r ../evergreen.xpi * -x defaults/preferences/standalone_xul_app.js)
+       @md5sum evergreen.xpi > evergreen.xpi.md5
+
+# Generic client, as an xpi, theoretically suitable for --install-app usage
+
+generic-client: client_app
+       @echo 'Packing Generic Client via zip (as xpi file)'
+       @rm -f evergreen_staff_client.xpi
+       @cd client && zip -q -r ../evergreen_staff_client.xpi *
+       @echo done
+
+# These two targets complete the layout defined on
+# https://developer.mozilla.org/en/XULRunner/Deploying_XULRunner_1.8
+# for their respective platforms in regards to XULRunner deployment
+
+# Note that I decided to use win/lin channels for ease of coding platform specific updates
+
+win-xulrunner: client_app
+       @echo 'Preparing Windows xulrunner'
+       @if [ ! -f ${XULRUNNER_WINFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_WINFILE}; fi
+       @unzip -q ${XULRUNNER_WINFILE} -dclient
+       @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","win");' >> client/defaults/preferences/autochannel.js; fi;
+       @echo 'Preparing stub'
+       @if [ -f xulrunner-stub.exe ]; then cp xulrunner-stub.exe client/evergreen.exe; rm client/xulrunner/xulrunner-stub.exe; else mv client/xulrunner/xulrunner-stub.exe client/evergreen.exe; fi
+
+linux-xulrunner: client_app
+       @echo 'Preparing Linux xulrunner'
+       @if [ ! -f ${XULRUNNER_LINUXFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_LINUXFILE}; fi
+       @cd client; tar xjf ../${XULRUNNER_LINUXFILE}; cd ..
+       @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","lin");' >> client/defaults/preferences/autochannel.js; fi;
+       @echo 'Preparing stub'
+       @mv client/xulrunner/xulrunner-stub client/evergreen
+
+# Build a windows installer.
+
+win-client: win-xulrunner
+       @echo 'Building installer'
+       @makensis -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_EXTRAOPTS} windowssetup.nsi
+       @echo 'Done'
+
+# For linux, just build a tar.bz2 archive
+
+linux-client: linux-xulrunner
+       @echo 'Packing as evergreen_staff_client.tar.bz2'
+       @rm -f evergreen_staff_client.tar.bz2
+       @cd client; tar cjf ../evergreen_staff_client.tar.bz2 *; cd ..
+       @echo 'Done'
+
+# For running the updates script with the correct updates directory, optionally building clients as well
+
+updates updates-client win-updates win-updates-client linux-updates linux-updates-client generic-updates generic-updates-client extension-updates:
+       @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
+       @if [ ! -x external/make_updates.sh ]; then chmod u+x external/make_updates.sh; fi
+       @if [ ! -x external/make_updates.sh ]; then echo 'ERROR! external/make_updates.sh is not executable!'; exit 1; fi
+       @external/make_updates.sh ${UPDATESDIR} $@
index 3552016..2e41ef5 100644 (file)
@@ -388,7 +388,13 @@ auth.controller.prototype = {
                     if (x.status == 200) {
                         window.open('data:text/html,'+window.escape(x.responseText),'upgrade','chrome,resizable,modal,centered');
                     } else {
-                        alert(document.getElementById('authStrings').getString('staff.auth.controller.version_mismatch'));
+                        if(typeof(G.upgradeCheck) == "function")
+                        {
+                            if (confirm("This server does not support your version of the staff client, an upgrade may be required. If you wish to check for an upgrade please press Ok. Otherwise please press cancel."))
+                                G.upgradeCheck();
+                        } else {
+                            alert(document.getElementById('authStrings').getString('staff.auth.controller.version_mismatch'));
+                        }
                     }
                     obj.controller.view.server_prompt.disabled = false;
                 } catch(E) {
index 38d096c..8707310 100644 (file)
@@ -36,6 +36,9 @@ const MODE_EXCL     = 0x80;
 const PERMS_FILE      = 0644;
 const PERMS_DIR      = 0755;
 
+const CLIENT_VERSION = '';
+const CLIENT_STAMP   = '';
+
 var my_constants = {
     'magical_statuses' : {
         '1' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Checked out    | t */
@@ -390,6 +393,7 @@ var urls = {
     'XUL_IN_HOUSE_USE' : '/xul/server/circ/in_house_use.xul',
     'XUL_LIST_CLIPBOARD' : '/xul/server/util/list_clipboard.xul',
     'XUL_LOCAL_ADMIN' : '/xul/server/admin/index.xhtml',
+    'XUL_LOGIN_DATA' : '/xul/server/main/data.xul', 
     'XUL_MARC_NEW' : '/xul/server/cat/marc_new.xul',
     'XUL_MARC_EDIT' : '/xul/server/cat/marcedit.xul',
     'XUL_MARC_VIEW' : '/xul/server/cat/marc_view.xul',
@@ -451,6 +455,7 @@ var urls = {
     'XUL_VOLUME_COPY_CREATOR' : '/xul/server/cat/volume_copy_creator.xul',
     'XUL_VOLUME_EDITOR' : '/xul/server/cat/volume_editor.xul',
     'XUL_WORK_LOG' : '/xul/server/admin/work_log.xul',
+    'XUL_WORKSTATION_INFO' : '/xul/server/main/ws_info.xul',
     'XUL_Z3950_IMPORT' : '/xul/server/cat/z3950.xul',
     'TEST_HTML' : '/xul/server/main/test.html',
     'TEST_XUL' : '/xul/server/main/test.xul',
index 61b8f4c..455b122 100644 (file)
@@ -162,7 +162,7 @@ function main_init() {
                 var deck = document.getElementById('progress_space');
                 util.widgets.remove_children( deck );
                 var iframe = document.createElement('iframe'); deck.appendChild(iframe);
-                iframe.setAttribute( 'src', url + '/xul/server/main/data.xul' );
+                iframe.setAttribute( 'src', url + urls.XUL_LOGIN_DATA );
                 iframe.contentWindow.xulG = xulG;
                 G.data_xul = iframe.contentWindow;
             } else {
@@ -170,7 +170,7 @@ function main_init() {
                 var deck = G.auth.controller.view.ws_deck;
                 JSAN.use('util.widgets'); util.widgets.remove_children('ws_deck');
                 var iframe = document.createElement('iframe'); deck.appendChild(iframe);
-                iframe.setAttribute( 'src', url + '/xul/server/main/ws_info.xul' );
+                iframe.setAttribute( 'src', url + urls.XUL_WORKSTATION_INFO );
                 iframe.contentWindow.xulG = xulG;
                 deck.selectedIndex = deck.childNodes.length - 1;
             }
@@ -291,8 +291,8 @@ function main_init() {
 
         /////////////////////////////////////////////////////////////////////////////
 
-        var version = '/xul/server/'.split(/\//)[2];
-        if (version == 'server') {
+        var version = CLIENT_VERSION;
+        if (CLIENT_STAMP.length == 0) {
             version = 'versionless debug build';
             document.getElementById('debug_gb').hidden = false;
         }
@@ -304,6 +304,37 @@ function main_init() {
         } catch(E) {
         }
 
+        var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] 
+            .getService(Components.interfaces.nsIXULAppInfo); 
+
+        if (appInfo.ID == "staff-client@open-ils.org")
+        {
+            try {
+                if (G.pref && G.pref.getBoolPref('app.update.enabled')) {
+                    document.getElementById('check_upgrade_sep').hidden = false;
+                    var upgrademenu = document.getElementById('check_upgrade');
+                    upgrademenu.hidden = false;
+                    G.upgradeCheck = function () {
+                        var um = Components.classes["@mozilla.org/updates/update-manager;1"]
+                            .getService(Components.interfaces.nsIUpdateManager);
+                        var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
+                            .createInstance(Components.interfaces.nsIUpdatePrompt);
+
+                        if (um.activeUpdate && um.activeUpdate.state == "pending")
+                            prompter.showUpdateDownloaded(um.activeUpdate);
+                        else
+                            prompter.checkForUpdates();
+                    }
+                    upgrademenu.addEventListener(
+                        'command',
+                        G.upgradeCheck,
+                        false
+                    );
+                }
+            } catch(E) {
+            }
+        }
+
         window.title = authStrings.getFormattedString('staff.auth.titlebar.label', version);
         var x = document.getElementById('about_btn');
         x.addEventListener(
index 60df710..2ee5c2c 100644 (file)
     <groupbox id="main_groupbox" flex="1" style="overflow: auto;">
         <caption id="main_caption" label="&staff.main.auth.caption;"/>
         <hbox>
-            <button id="about_btn" label="&staff.auth.about_btn.label;" accesskey="&staff.auth.about_btn.accesskey;" />
+            <button type="menu" label="Help" accesskey="l">
+                <menupopup>
+                    <menuitem id="about_btn" label="&staff.auth.about_btn.label;" accesskey="&staff.auth.about_btn.accesskey;" />
+                    <menuitem id="contents_menu" label="Contents" accesskey="c" disabled="true" />
+                    <menuseparator id="check_upgrade_sep" hidden="true" />
+                    <menuitem id="check_upgrade" label="Check for upgrades" accesskey="" hidden="true" />
+                </menupopup>
+            </button>
+
 
             <button id="new_window_btn" label="&staff.auth.new_window_btn.label;" accesskey="&staff.auth.new_window_btn.accesskey;" />
 
diff --git a/Open-ILS/xul/staff_client/defaults/preferences/autoupdate.js b/Open-ILS/xul/staff_client/defaults/preferences/autoupdate.js
new file mode 100644 (file)
index 0000000..daa6d9f
--- /dev/null
@@ -0,0 +1,29 @@
+// Enable Updater
+pref("app.update.enabled", true);
+// Change to "false" to not automatically update
+pref("app.update.auto", true);
+// 0 downloads without prompt always
+pref("app.update.mode", 0);
+
+// These settings are in seconds
+// Interval for checking
+pref("app.update.interval", 86400);
+// Time before prompting to download - If auto is off, mainly
+pref("app.update.nagTimer.download", 86400);
+// Time before prompting to restart to apply update that has downloaded
+pref("app.update.nagTimer.restart", 1800);
+
+// How often to check timers (above) - in MILLIseconds
+pref("app.update.timer", 600000);
+
+
+// URL for downloading. For Thomas Berezansky's script the update.xml part isn't needed.
+// NOTE: Certs that default to invalid, even those overridden with cert_override.txt, won't work with this!
+pref("app.update.url", "https://::HOSTNAME::/updates/check/%CHANNEL%/%VERSION%/update.xml");
+
+// URL for manual update information
+pref("app.update.url.manual", "http://::HOSTNAME::/updates/manualupdate.html");
+
+// Default details URL for updates
+pref("app.update.url.details", "http://::HOSTNAME::/updates/updatedetails.html");
+
diff --git a/Open-ILS/xul/staff_client/external/make_updates.sh b/Open-ILS/xul/staff_client/external/make_updates.sh
new file mode 100755 (executable)
index 0000000..73f4c64
--- /dev/null
@@ -0,0 +1,327 @@
+#!/bin/bash
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla Update Packaging.
+#
+# The Initial Developer of the Original Code is
+# Merrimack Valley Library Consortium.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Thomas Berezansky <tsbere@mvlc.org>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# Portions of this code were based on code by Darin Fisher found here:
+# http://mxr.mozilla.org/mozilla/source/tools/update-packaging/
+
+prefix=${1:-/openils/var/updates}
+BZIP2=${BZIP2:-bzip2}
+
+GEN_UPDATES=0
+WIN_UPDATES=0
+LINUX_UPDATES=0
+EXT_UPDATES=0
+CLIENTS=0
+case "$2" in
+       generic-updates*)
+       echo "Building Generic Updates only"
+       GEN_UPDATES=1
+       ;;
+       win-updates*)
+       echo "Building Windows Updates only"
+       WIN_UPDATES=1
+       ;;
+       linux-updates*)
+       echo "Building Linux Updates only"
+       LINUX_UPDATES=1
+       ;;
+       extension-updates*)
+       echo "Building Extension Updates only"
+       EXT_UPDATES=1
+       ;;
+       *)
+       echo "Building All Updates"
+       GEN_UPDATES=1
+       WIN_UPDATES=1
+       LINUX_UPDATES=1
+       EXT_UPDATES=1
+       ;;
+esac
+case "$2" in
+       extension-updates*)
+       echo "Extension only - No client"
+       ;;
+       *-client)
+       echo "Building Client(s)"
+       CLIENTS=1
+       ;;
+       *)
+       echo "Not Building Client(s)"
+       ;;
+esac
+
+function unwrap_update
+{
+       SOURCE="$1"
+       DEST="$2"
+       $MAR -C "$2" -x "$1"
+       find "$2" -type f -exec mv {} {}.bz2 \;
+       find "$2" -type f -name '*.bz2' -exec $BZIP2 -d {} \;
+}
+
+function prep_update
+{
+       NEW="$1"
+       OLD="$2"
+       WORK="$3"
+       MANIFEST="$WORK/update.manifest"
+       ARCHIVEFILES="update.manifest"
+       rm -rf "$WORK"
+       mkdir -p "$WORK"
+       rm -f "$MANIFEST"
+       for FILE in `find "$NEW" -type f`; do
+               check_file $FILE
+       done
+       for FILE in `find "$OLD" -type f`; do
+               remove_file $FILE
+       done
+       $BZIP2 -z9 "$MANIFEST"
+       mv "$MANIFEST.bz2" "$MANIFEST"
+       rm -rf "$OLD"
+}
+
+function check_file
+{
+       CHECK_FILE="${1#$NEW/}"
+       if [ $CHECK_FILE == "update.manifest" ]; then
+               return;
+       fi
+       DIR=$(dirname "$WORK/$CHECK_FILE")
+       if [ ! -f "$OLD/$CHECK_FILE" ]; then
+               echo "add \"$CHECK_FILE\"" >> "$MANIFEST"
+               mkdir -p "$DIR"
+               $BZIP2 -cz9 "$NEW/$CHECK_FILE" > "$WORK/$CHECK_FILE"
+               if [ -x "$NEW/$CHECK_FILE" ]; then
+                       chmod 0755 "$WORK/$CHECK_FILE"
+               else
+                       chmod 0644 "$WORK/$CHECK_FILE"
+               fi
+               ARCHIVEFILES="$ARCHIVEFILES \"$CHECK_FILE\""
+               return
+       elif ! diff "$OLD/$CHECK_FILE" "$NEW/$CHECK_FILE" > /dev/null; then
+               mkdir -p "$DIR"
+               $MBSDIFF "$OLD/$CHECK_FILE" "$NEW/$CHECK_FILE" "$WORK/$CHECK_FILE.patch"
+               $BZIP2 -z9 "$WORK/$CHECK_FILE.patch"
+               $BZIP2 -cz9 "$NEW/$CHECK_FILE" > "$WORK/$CHECK_FILE"
+               PATCHSIZE=`du -b "$WORK/$CHECK_FILE.patch.bz2"`
+               FULLSIZE=`du -b "$WORK/$CHECK_FILE"`
+               PATCHSIZE="${PATCHSIZE%%        *}"
+               FULLSIZE="${FULLSIZE%%  *}"
+               if [ $PATCHSIZE -lt $FULLSIZE ]; then
+                       rm -f "$WORK/$CHECK_FILE"
+                       mv "$WORK/$CHECK_FILE.patch.bz2" "$WORK/$CHECK_FILE.patch"
+                       echo "patch \"$CHECK_FILE.patch\" \"$CHECK_FILE\"" >> "$MANIFEST"
+                       ARCHIVEFILES="$ARCHIVEFILES \"$CHECK_FILE.patch\""
+               else
+                       rm -f "$WORK/$CHECK_FILE.patch.bz2"
+                       if [ -x "$NEW/$CHECK_FILE" ]; then
+                               chmod 0755 "$WORK/$CHECK_FILE"
+                       else
+                               chmod 0644 "$WORK/$CHECK_FILE"
+                       fi
+                       echo "add \"$CHECK_FILE\"" >> "$MANIFEST"
+                       ARCHIVEFILES="$ARCHIVEFILES \"$CHECK_FILE\""
+               fi
+       fi
+       rm -f "$OLD/$CHECK_FILE"
+}
+
+function remove_file
+{
+       RM_FILE="${1#$OLD/}"
+       if [ $RM_FILE != "update.manifest" ]; then
+               echo "remove \"$RM_FILE\"" >> "$MANIFEST"
+       fi
+}
+
+function build_update
+{
+       eval "$MAR -C \"$WORK\" -c output.mar $ARCHIVEFILES"
+       mv "$WORK/output.mar" "$1"
+       rm -rf "$WORK"
+}
+
+function check_mar
+{
+       if which mar; then
+               MAR=${MAR:-mar}
+       fi
+       if which mbsdiff; then
+               MBSDIFF=${MBSDIFF:-mbsdiff}
+       fi
+       if [ ! -x "$MAR" -o ! -x "$MBSDIFF" ]; then
+               if [ ! -f "external/mar" -o ! -f "external/mbsdiff" ]; then
+                       wget ftp://ftp.mozilla.org/pub/mozilla.org/xulrunner/mar-generation-tools/mar-generation-tools-linux.zip
+                       unzip mar-generation-tools-linux.zip -d external
+               fi
+               MAR="$PWD/external/mar"
+               MBSDIFF="$PWD/external/mbsdiff"
+       fi
+}
+
+function make_full_update
+{
+       echo "Making full update"
+       rm -rf "oldclient"
+       mkdir -p "oldclient"
+       prep_update client oldclient client.working
+       build_update "full_update.mar"
+       mkdir -p "$PUBPATH"
+       mv full_update.mar "$PUBPATH/$VERSION.mar"
+       echo "Making full update patch def"
+       mkdir -p "$PATCHPATH"
+       HASH=$(sha512sum "$PUBPATH/$VERSION.mar")
+       SIZE=$(du -b "$PUBPATH/$VERSION.mar")
+       echo "<patch type=\"complete\" URL=\"$VERSION.mar\" hashFunction=\"sha512\" hashValue=\"${HASH%% *}\" size=\"${SIZE%%   *}\"/>" > "$PATCHPATH/$VERSION.patchline"
+}
+
+function make_partial_update
+{
+       PREV_VERSION="${1%.mar}"
+       if [ "$VERSION" == "$PREV_VERSION" ]; then
+               echo "Skipping partial update for same version"
+               return
+       fi
+       echo "Making partial update from $PREV_VERSION"
+       rm -rf "oldclient"
+       mkdir -p "oldclient"
+       unwrap_update "$ARCHIVEPATH/$1" oldclient
+       prep_update client oldclient client.working
+       build_update "partial_update.mar"
+       mv partial_update.mar "$PUBPATH/$PREV_VERSION-$VERSION.mar"
+       echo "Making partial update patch def"
+       mkdir -p "$PATCHPATH"
+       HASH=$(sha512sum "$PUBPATH/$PREV_VERSION-$VERSION.mar")
+       SIZE=$(du -b "$PUBPATH/$PREV_VERSION-$VERSION.mar")
+       echo "<patch type=\"partial\" URL=\"$PREV_VERSION-$VERSION.mar\" hashFunction=\"sha512\" hashValue=\"${HASH%% *}\" size=\"${SIZE%%      *}\"/>" > "$PATCHPATH/$PREV_VERSION-$VERSION.patchline"
+}
+
+function make_partial_updates
+{
+       echo "Checking for partial update source files"
+       if [ -d "$ARCHIVEPATH" ]; then
+               for OLDVER in `find "$ARCHIVEPATH" -maxdepth 1 -name '*.mar'`; do
+                       make_partial_update "${OLDVER##*/}"
+               done
+       fi
+       mkdir -p "$ARCHIVEPATH"
+       echo "Copying full update to archive"
+       cp "$PUBPATH/$VERSION.mar" "$ARCHIVEPATH"
+       echo "Updating current version file"
+       echo "$VERSION" > "$PATCHPATH/VERSION"
+}
+
+function cleanup_files
+{
+       echo "Cleaning up previous update mar files and update patch files"
+       find "$PUBPATH" -maxdepth 1 -name "*.mar" ! -name "*$VERSION.mar" -delete -print
+       find "$PATCHPATH" -maxdepth 1 -name "*.patch" ! -name "*$VERSION.patch" -delete -print
+}
+
+# First, do we have the mar and mbsdiff tools?
+check_mar
+VERSION=`cat build/VERSION`
+
+# Generic Updates - No XULRunner packaged, channel of "release"
+# NOTE: Generic updates CAN update Windows/Linux builds, and will do so if you don't build platform specific ones
+if [ $GEN_UPDATES -eq 1 ]; then
+       PATCHPATH="$prefix/patch"
+       PUBPATH="$prefix/pub"
+       ARCHIVEPATH="$prefix/archives"
+       if [ $CLIENTS -eq 1 ]; then
+               make generic-client
+               mkdir -p "$prefix/pub/clients/"
+               find "$prefix/pub/clients/" -name '*_client.xpi' -delete
+               mv evergreen_staff_client.xpi "$prefix/pub/clients/${VERSION}_client.xpi"
+       else
+               make client_app
+       fi
+       make_full_update
+       make_partial_updates
+       cleanup_files
+fi
+
+# Windows Updates - Windows XULRunner, update channel of "win"
+if [ $WIN_UPDATES -eq 1 ]; then
+       PATCHPATH="$prefix/patch/win"
+       PUBPATH="$prefix/pub/win"
+       ARCHIVEPATH="$prefix/archives/win"
+       if [ $CLIENTS -eq 1 ]; then
+               make win-client
+               mkdir -p "$prefix/pub/clients/"
+               find "$prefix/pub/clients/" -name '*_setup.exe' -delete
+               mv evergreen_staff_client_setup.exe "$prefix/pub/clients/${VERSION}_setup.exe"
+       else
+               make win-xulrunner
+       fi
+       make_full_update
+       make_partial_updates
+       cleanup_files
+fi
+
+# Linux Updates - Linux XULRunner, update channel of "lin'
+if [ $LINUX_UPDATES -eq 1 ]; then
+       PATCHPATH="$prefix/patch/lin"
+       PUBPATH="$prefix/pub/lin"
+       ARCHIVEPATH="$prefix/archives/lin"
+       if [ $CLIENTS -eq 1 ]; then
+               make linux-client
+               mkdir -p "$prefix/pub/clients/"
+               find "$prefix/pub/clients/" -name '*.tar.bz2' -delete
+               mv evergreen_staff_client.tar.bz2 "$prefix/pub/clients/${VERSION}.tar.bz2"
+       else
+               make linux-xulrunner
+       fi
+       make_full_update
+       make_partial_updates
+       cleanup_files
+fi
+
+# Extension Updates
+# Not really "Updates" so much as "Update", plural for consistency in command.
+# Extensions don't do partial updates. Or at least not that I found docs for.
+if [ $EXT_UPDATES -eq 1 ]; then
+       make extension
+       mkdir -p "$prefix/pub/"
+       find "$prefix/pub/" -maxdepth 1 -name '*_extension.xpi' -delete
+       mv evergreen.xpi "$prefix/pub/${VERSION}_extension.xpi" 
+       SHA512=$(sha512sum "$prefix/pub/${VERSION}_extension.xpi")
+       SHA512=${SHA512%% *}
+       sed -e "s|<em:version>.*</em:version>|<em:version>$VERSION</em:version>|" -e "s|<em:updateLink>.*</em:updateLink>|<em:updateLink>https://::HOSTNAME::/updates/${VERSION}_extension.xpi</em:updateLink>|" -e "s|<em:updateHash>.*</em:updateHash>|<em:updateHash>sha512:$SHA512</em:updateHash>|" update.rdf > "$prefix/patch/update.rdf"
+fi
index 76d41c6..6d9150e 100755 (executable)
@@ -14,7 +14,7 @@
                        <Description>
                                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
                                <em:minVersion>3.5</em:minVersion>
-                               <em:maxVersion>3.5.*</em:maxVersion>
+                               <em:maxVersion>3.6.*</em:maxVersion>
                        </Description>
                </em:targetApplication>
     
@@ -23,6 +23,7 @@
                <em:description>Evergreen Staff Client</em:description>
         
                <em:homepageURL>http://evergreen-ils.org/</em:homepageURL>
+               <em:updateURL>https://::HOSTNAME::/updates/update.rdf</updateURL>
     
        </Description>      
 </RDF>
diff --git a/Open-ILS/xul/staff_client/update.rdf b/Open-ILS/xul/staff_client/update.rdf
new file mode 100644 (file)
index 0000000..d67acfc
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+         xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <RDF:Description about="urn:mozilla:extension:staff-client@open-ils.org">
+    <em:updates>
+      <RDF:Seq>
+        <RDF:li>
+          <RDF:Description>
+            <em:version>1.6</em:version>
+            <em:targetApplication>
+              <RDF:Description>
+                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+                <em:minVersion>3.5</em:minVersion>
+                <em:maxVersion>3.6.*</em:maxVersion>
+                <em:updateLink>https://::HOSTNAME::/updates/extension.xpi</em:updateLink>
+                <em:updateInfoURL>http://::HOSTNAME::/updates/updatedetails.html</em:updateInfoURL>
+                <em:updateHash></em:updateHash>
+              </RDF:Description>
+            </em:targetApplication>
+          </RDF:Description>
+        </RDF:li>
+      </RDF:Seq>
+    </em:updates>
+  </RDF:Description>
+</RDF:RDF>
diff --git a/Open-ILS/xul/staff_client/windowssetup.nsi b/Open-ILS/xul/staff_client/windowssetup.nsi
new file mode 100644 (file)
index 0000000..4e7dfff
--- /dev/null
@@ -0,0 +1,212 @@
+; Script generated by the HM NIS Edit Script Wizard.
+
+; HM NIS Edit Wizard helper defines
+!define PRODUCT_NAME "Evergreen Staff Client"
+; Old versions of makensis don't like this, moved to Makefile
+;!define /file PRODUCT_VERSION "client/VERSION"
+!define PRODUCT_PUBLISHER "Evergreen Community"
+!define PRODUCT_WEB_SITE "http://evergreen-ils.org/"
+!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\evergreen.exe"
+!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
+!define PRODUCT_UNINST_ROOT_KEY "HKLM"
+!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
+
+; MUI 1.67 compatible ------
+!include "MUI.nsh"
+
+; File Functions
+!include "FileFunc.nsh"
+
+; MUI Settings
+!define MUI_ABORTWARNING
+!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
+!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
+
+; Language Selection Dialog Settings
+!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
+!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
+!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
+
+; Welcome page
+!insertmacro MUI_PAGE_WELCOME
+; License page
+!insertmacro MUI_PAGE_LICENSE "..\..\..\LICENSE.txt"
+; Components page
+!ifdef AUTOUPDATE | DEVELOPER
+!insertmacro MUI_PAGE_COMPONENTS
+!endif
+; Directory page
+!insertmacro MUI_PAGE_DIRECTORY
+; Start menu page
+var ICONS_GROUP
+!define MUI_STARTMENUPAGE_NODISABLE
+!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Evergreen Staff Client"
+!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
+!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
+!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
+!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
+; Instfiles page
+!insertmacro MUI_PAGE_INSTFILES
+; Finish page
+!define MUI_FINISHPAGE_RUN "$INSTDIR\evergreen.exe"
+!insertmacro MUI_PAGE_FINISH
+
+; Uninstaller pages
+!insertmacro MUI_UNPAGE_INSTFILES
+
+; Language files
+!insertmacro MUI_LANGUAGE "Czech"
+!insertmacro MUI_LANGUAGE "English"
+!insertmacro MUI_LANGUAGE "French"
+
+; MUI end ------
+
+Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
+OutFile "evergreen_staff_client_setup.exe"
+InstallDir "$PROGRAMFILES\Evergreen Staff Client"
+InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
+ShowInstDetails show
+ShowUnInstDetails show
+RequestExecutionLevel admin
+
+Section "Staff Client" SECMAIN
+  SetOutPath "$INSTDIR"
+  File /r /x "autoupdate.js" /x "autochannel.js" /x "developers.js" "client\*"
+
+; Shortcuts
+  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
+  !ifdef WICON
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe" "" "$INSTDIR\evergreen.ico"
+  !ifdef PROFILES
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTRDIR\evergreen.exe -profilemanager" "" "$INSTDIR\evergreen.ico"
+  !endif
+  !else
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe"
+  !ifdef PROFILES
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTRDIR\evergreen.exe -profilemanager"
+  !endif
+  !endif
+  CreateShortCut "$DESKTOP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe"
+  !insertmacro MUI_STARTMENU_WRITE_END
+SectionEnd
+
+!ifdef AUTOUPDATE
+Section /o "Automatic Update" SECAUTO
+  SetOutPath "$INSTDIR\defaults\preferences"
+  File "client\defaults\preferences\autoupdate.js"
+  File "client\defaults\preferences\autochannel.js"
+  SetOutPath "$INSTDIR"
+SectionEnd
+!endif
+
+!ifdef DEVELOPER
+Section /o "Developer Options" SECDEV
+  SetOutPath "$INSTDIR\defaults\preferences"
+  File "client\defaults\preferences\developers.js"
+  SetOutPath "$INSTDIR"
+SectionEnd
+!endif
+
+
+Function .onInit
+  !insertmacro MUI_LANGDLL_DISPLAY
+  SectionSetFlags ${SECMAIN} 17
+  ; This is mainly for silent installs
+  !ifdef AUTOUPDATE | DEVELOPER
+    Var /GLOBAL CMD_ARGS
+    StrCpy $CMD_ARGS ""
+    ${GetParameters} $CMD_ARGS
+    !ifdef AUTOUPDATE
+      !ifdef AUTOUPDATE_NODEFAULT
+        ${GetOptions} $CMD_ARGS "/autoupdate" $0
+        IfErrors +2 0
+      !else
+        ${GetOptions} $CMD_ARGS "/noautoupdate" $0
+        IfErrors 0 +2
+      !endif
+      SectionSetFlags ${SECAUTO} 1
+    !endif
+    !ifdef DEVELOPER
+      ${GetOptions} $CMD_ARGS "/developer" $0
+      IfErrors +2 0
+      SectionSetFlags ${SECDEV} 1
+    !endif
+  !endif
+FunctionEnd
+
+Section -AdditionalIcons
+  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
+  !insertmacro MUI_STARTMENU_WRITE_END
+SectionEnd
+
+Section -Post
+  WriteUninstaller "$INSTDIR\uninst.exe"
+  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\evergreen.exe"
+  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
+  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
+  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\evergreen.exe"
+  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
+  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
+  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
+SectionEnd
+
+; Section descriptions
+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+  !insertmacro MUI_DESCRIPTION_TEXT ${SECMAIN} "The Evergreen Staff Client with XULRunner, Required"
+  !ifdef AUTOUPDATE
+  !insertmacro MUI_DESCRIPTION_TEXT ${SECAUTO} "Automatic Update Functionality"
+  !endif
+  !ifdef DEVELOPER
+  !insertmacro MUI_DESCRIPTION_TEXT ${SECDEV}  "Developer Options"
+  !endif
+!insertmacro MUI_FUNCTION_DESCRIPTION_END
+
+
+Function un.onUninstSuccess
+  HideWindow
+  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
+FunctionEnd
+
+Function un.onInit
+!insertmacro MUI_UNGETLANGUAGE
+  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
+  Abort
+FunctionEnd
+
+Section Uninstall
+  !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
+  Delete "$INSTDIR\${PRODUCT_NAME}.url"
+  Delete "$INSTDIR\uninst.exe"
+  Delete "$INSTDIR\evergreen.exe"
+  Delete "$INSTDIR\application.ini"
+  Delete "$INSTDIR\BUILD_ID"
+  Delete "$INSTDIR\STAMP_ID"
+  Delete "$INSTDIR\VERSION"
+  Delete "$INSTDIR\install.rdf"
+  Delete "$INSTDIR\active-update.xml"
+  Delete "$INSTDIR\chrome.manifest"
+  Delete "$INSTDIR\updates.xml"
+  Delete "$INSTDIR\log.txt"
+
+  Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
+  Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
+  Delete "$DESKTOP\Evergreen Staff Client.lnk"
+  Delete "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk"
+
+  RMDir "$SMPROGRAMS\$ICONS_GROUP"
+  RMDir /r "$INSTDIR\updates"
+  RMDir /r "$INSTDIR\xulrunner"
+  RMDir /r "$INSTDIR\extensions"
+  RMDir /r "$INSTDIR\chrome"
+  RMDir /r "$INSTDIR\components"
+  RMDir /r "$INSTDIR\defaults"
+  RMDir "$INSTDIR"
+
+  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
+  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
+  SetAutoClose true
+SectionEnd
index e1e1552..3d70cb3 100644 (file)
@@ -52,6 +52,7 @@ AM_PROG_CC_C_O
 #    yes) openils_all=true;
 #       openils_core=true;
 #       openils_web=true;
+#       openils_updates=true;
 #       openils_reporter=true;
 #       openils_client_xul=true;
 #       openils_server_xul=true ;;
@@ -85,6 +86,26 @@ esac],
 
 AM_CONDITIONAL([BUILDILSWEB], [test x$openils_web = xtrue])
 
+# install evergreen-updates?
+
+AC_ARG_ENABLE([updates],
+[  --disable-updates    disables installation of the Evergreen updates folder ],
+[case "${enableval}" in
+    yes) openils_updates=true ;;
+    no)  openils_updates=false ;;
+  *) AC_MSG_ERROR([please choose another value for --disable-updates (supported values are yes or no])
+esac],
+[openils_updates=true])
+
+AM_CONDITIONAL([BUILDILSUPDATES], [test x$openils_updates = xtrue])
+
+# Default updates host?
+AC_ARG_WITH([updateshost],
+[  --with-updateshost=hostname    default hostname for automatic updates (default is blank)],
+[AUTOUPDATE_HOST=${withval}],
+[AUTOUPDATE_HOST=])
+AC_SUBST([AUTOUPDATE_HOST])
+
 # install Evergreen Apache modules?
 AC_ARG_ENABLE([apache-modules],
 [  --disable-apache-modules    disables installation of the Evergreen Apache modules ],
@@ -350,6 +371,7 @@ fi
 AC_CONFIG_FILES([Makefile
                 Open-ILS/src/Makefile
                 Open-ILS/web/Makefile
+                Open-ILS/updates/Makefile
                 Open-ILS/xul/staff_client/Makefile
                 Open-ILS/src/extras/eg_config
                 Open-ILS/src/extras/fast-extract],
@@ -383,6 +405,11 @@ if test "$openils_web" = "true" ; then
 else
         AC_MSG_RESULT([Evergreen Web:                  no])
 fi
+if test "$openils_updates" = "true" ; then
+        AC_MSG_RESULT([Evergreen Updates:              yes])
+else
+        AC_MSG_RESULT([Evergreen Updates:              no])
+fi
 if test "$openils_reporter" = "true" ; then
         AC_MSG_RESULT([Evergreen Reporter:             yes])
 else