~evergreen-bugs/evergreen/rel_3_11

« back to all changes in this revision

Viewing changes to Open-ILS/xul/staff_client/Makefile.am

  • Committer: phasefx
  • Date: 2010-08-24 19:04:20 UTC
  • Revision ID: git-v1:53a0bd89fe11176c309b6bcf7f812e3bb60b1283
Staff Client Build/Update Enhancements patch from Thomas Berezansky

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#---------------------------------------------------------
5
5
 
6
6
export STAFF_CLIENT_BUILD_ID = $$(/bin/cat build/BUILD_ID)
 
7
export STAFF_CLIENT_VERSION = $$(/bin/cat build/VERSION)
 
8
export STAFF_CLIENT_STAMP_ID = $$(/bin/cat build/STAMP_ID)
7
9
 
8
10
# from http://closure-compiler.googlecode.com/files/compiler-latest.zip  FIXME: Autotools this?
9
11
export CLOSURE_COMPILER_JAR = ~/closure-compiler/compiler.jar
 
12
XULRUNNER_VERSION=1.9.2.8
 
13
XULRUNNER_WINFILE=xulrunner-$(XULRUNNER_VERSION).en-US.win32.zip
 
14
XULRUNNER_LINUXFILE=xulrunner-$(XULRUNNER_VERSION).en-US.linux-i686.tar.bz2
 
15
XULRUNNER_URL=http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/$(XULRUNNER_VERSION)/runtimes/
10
16
 
11
17
OPENSRF_JSLIBS = "$(OPENSRF_LIBS)/javascript"
12
18
CHROME_LOCALES = $$(ls -1 chrome/locale)
13
19
SKIN_CSS = $$(ls -1 server/skin/*css | sed -e "s/.css/_custom.css/")
 
20
UPDATESDIR=@localstatedir@/updates
 
21
 
 
22
SVN=svn # Because some people might need to override this to 'git svn' or something
 
23
 
 
24
export NSIS_EXTRAOPTS
 
25
export NSIS_WICON=$$(if [ -f client/evergreen.ico ]; then echo '-DWICON'; fi)
 
26
export NSIS_AUTOUPDATE=$$([ -f client/defaults/preferences/autoupdate.js ] && echo '-DAUTOUPDATE')
 
27
export NSIS_DEV=$$([ -f client/defaults/preferences/developers.js ] && echo '-DDEVELOPER')
14
28
 
15
29
#------------------------------
16
30
# Build ILS XUL CLIENT/SERVER
26
40
        @echo ' * Copying in developer preferences'
27
41
        @cp external/developers.js build/defaults/preferences/
28
42
 
29
 
extension: build
30
 
        @echo ' * Packaging as an XPI'
31
 
        @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
32
 
        @(cd build/ && zip -q -r evergreen.xpi * -x server/\* -x defaults/preferences/standalone_xul_app.js)
33
 
        @md5sum build/evergreen.xpi > build/evergreen.xpi.md5
34
 
 
35
43
build: build_dir chrome2remote localize_manifest generated custom_skins open-ils stamp 
36
44
        @echo To test the staff client:
37
45
        @echo "  cd build/"
46
54
        @cp -fR defaults build/
47
55
        @cp -fR components build/
48
56
        @cp application.ini build/
49
 
        @cp install.rdf build/
 
57
        @if [ -f "install.mccoy.rdf" ]; then cp install.mccoy.rdf build/install.rdf; else cp install.rdf build/; fi
50
58
        @cp -fR build/chrome/content/util/ build/server/
51
59
        @cp -fR build/chrome/content/auth/ build/server/
52
60
        @cp build/chrome/content/main/constants.js build/server/main/constants.js
53
61
        @cp build/chrome/content/main/bindings.xml build/server/main/bindings.xml
54
62
        @cp build/chrome/content/OpenILS/data.js build/server/OpenILS/data.js
55
63
        @cp build/chrome/content/OpenILS/global_util.js build/server/OpenILS/global_util.js
 
64
        @if [ -d branding ]; then copy -fR branding/* build/; fi
56
65
        @external/prune_dirs.sh build/
57
66
 
58
67
# Convert chrome to remote for server localization
67
76
                if [ "$$loc" != "en-US" ]; then ( echo "locale open_ils_staff_client $$loc locale/$$loc/" >> build/chrome/chrome.manifest ) ; fi; \
68
77
        done;
69
78
 
 
79
# On this page:
 
80
# https://developer.mozilla.org/en/xul_application_packaging
 
81
# The Documentation states:
 
82
# BUILD ID should be a unique build identifier, usually date based, and should be different for each released version
 
83
# VERSION should be in a format as described here:
 
84
# https://developer.mozilla.org/en/Toolkit_version_format
 
85
 
 
86
# The default "automatic" BUILD ID is acceptable.
 
87
 
 
88
# The version from the README usually conforms to that documentation, unless it is trunk.
 
89
# If we are in trunk, we probably have svn kicking around, ask it for the revision and build an appropriate version string.
 
90
 
 
91
# Neither really applies to the STAMP, though.
 
92
# 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.
 
93
# Trunk VERSION will end up with 0trunk.release, trunk STAMP ID will be 0trunk_release.
70
94
stamp:
71
95
        @/bin/date +"%Y%m%d.%H%M%S" > build/BUILD_ID
72
96
        @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
73
97
        @if [ -z "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "No Build ID for versioning" ; echo "none" > build/BUILD_ID ) ; fi
74
 
        @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i s/^Version=.\*/Version=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
75
 
        @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
76
 
        @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
77
 
        @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
78
 
        @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
79
 
        @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
80
 
        @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
81
 
        @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
 
98
        @sed -n -e '1 s/^.* \([^ ]*\)$$/\1/p' @top_srcdir@/README > build/VERSION
 
99
        @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 
 
100
        @if [ -n "${STAFF_CLIENT_VERSION}" ]; then ( echo "Stamping with Version: ${STAFF_CLIENT_VERSION}" ; echo ${STAFF_CLIENT_VERSION} > build/VERSION ) ; fi
 
101
        @if [ -z "${STAFF_CLIENT_VERSION}" ]; then ( echo "No Version" ; echo "none" > build/VERSION ) ; fi
 
102
        @sed -e 's/\./_/g' -e 's/^\([0-9_]*\)$$/rel_&/' build/VERSION > build/STAMP_ID
 
103
        @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
 
104
        @if [ -z "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "No Stamp ID for versioning" ; echo "none" > build/STAMP_ID ) ; fi
 
105
        @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e s/^Version=.\*/Version=${STAFF_CLIENT_VERSION}/ build/application.ini ; fi
 
106
        @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
 
107
        @if [ -n "${STAFF_CLIENT_VERSION}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_VERSION *= '\)'/\1${STAFF_CLIENT_VERSION}'/" {} \; ; fi
 
108
        @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i -e s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
 
109
        @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
 
110
        @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
 
111
        @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
 
112
        @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
 
113
        @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
 
114
        @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
 
115
        @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
 
116
        @if [ -z "${AUTOUPDATE_HOST}" ]; then rm -f build/defaults/preferences/autoupdate.js; fi
 
117
        @if [ -z "${AUTOUPDATE_HOST}" ]; then sed -i -e /updateURL/d build/install.rdf; fi
 
118
        @if [ -n "${AUTOUPDATE_HOST}" ]; then echo "Applying automatic update host ${AUTOUPDATE_HOST}"; fi
 
119
        @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/defaults/preferences/autoupdate.js; fi
 
120
        @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/install.rdf; fi
82
121
 
83
122
bell:
84
123
        @perl -e 'print "Ringing bell..." . chr(7) . "\n";'
108
147
        @echo $@
109
148
        mkdir -p $(WEBDIR)
110
149
        mkdir -p $(WEBDIR)/xul/
111
 
        @echo "BUILD_ID = $(STAFF_CLIENT_BUILD_ID)"
112
 
        @echo "Copying xul into $(WEBDIR)/xul/$(STAFF_CLIENT_BUILD_ID)"
113
 
        mkdir -p "$(WEBDIR)/xul/$(STAFF_CLIENT_BUILD_ID)"
114
 
        cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "${WEBDIR}/xul/${STAFF_CLIENT_BUILD_ID}/"
 
150
        @echo "STAMP_ID = $(STAFF_CLIENT_STAMP_ID)"
 
151
        @echo "Copying xul into $(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
 
152
        mkdir -p "$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
 
153
        cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "${WEBDIR}/xul/${STAFF_CLIENT_STAMP_ID}/"
115
154
 
116
155
compress-javascript: build
117
156
        @echo "Size of build/ before compression = " `du -sh build/`
123
162
        @find build/ -name '*.js~' -exec perl -e '$$a = "{}"; chop $$a; `mv $$a~ $$a`;' \;
124
163
        @echo "Size of build/ (minus compression.err) after compression = " `du -sh --exclude compression.err build/`
125
164
 
 
165
# Easy way to make all three kinds of clients
 
166
 
 
167
clients:
 
168
        @make win-client
 
169
        @make linux-client
 
170
        @make generic-client
 
171
 
 
172
# By doing this we don't change the original build in the build folder
 
173
# Great for adding/changing things without a full rebuild
 
174
 
 
175
client_dir:
 
176
        @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
 
177
        @echo 'Prepping Client Set'
 
178
        @rm -rf client/
 
179
        @mkdir -p client
 
180
        @cp -fR build/* client/
 
181
        @rm -rf client/server/
 
182
        @rm -f client/build.tar*
 
183
 
 
184
# When building as a standalone client install.rdf is a bad thing
 
185
# as we haven't "sanitized" the client for extension use
 
186
 
 
187
client_app: client_dir
 
188
        @echo 'Cleaning Extension Information'
 
189
        @rm -f client/install.rdf
 
190
 
 
191
# If automatic updates are enabled, or the standalone_xul_app.js is present,
 
192
# the extension can break Firefox.
 
193
# Remove those, and we need a chrome.manifest
 
194
 
 
195
client_ext: client_dir
 
196
        @echo 'Cleaning App Information'
 
197
        @rm -f client/application.ini
 
198
        @rm -f client/defaults/preferences/autoupdate.js
 
199
        @rm -f client/defaults/preferences/autochannel.js
 
200
        @rm -f client/defaults/preferences/standalone_xul_app.js
 
201
        @echo 'Prepping chrome.manifest'
 
202
        @perl -ne 'if(/open_ils_staff_client/) { s/ (?!chrome:\/\/open_ils_staff_client)([^ ]*)$$/ chrome\/\1/; print; }' client/chrome/chrome.manifest > client/chrome.manifest
 
203
 
 
204
# Would merge client_ext into this one, but this way an installer that doesn't
 
205
# use an xpi can be made for extension later, if desired
 
206
 
 
207
extension: client_ext
 
208
        @echo ' * Packaging as an XPI'
 
209
        @(cd client/ && zip -q -r ../evergreen.xpi * -x defaults/preferences/standalone_xul_app.js)
 
210
        @md5sum evergreen.xpi > evergreen.xpi.md5
 
211
 
 
212
# Generic client, as an xpi, theoretically suitable for --install-app usage
 
213
 
 
214
generic-client: client_app
 
215
        @echo 'Packing Generic Client via zip (as xpi file)'
 
216
        @rm -f evergreen_staff_client.xpi
 
217
        @cd client && zip -q -r ../evergreen_staff_client.xpi *
 
218
        @echo done
 
219
 
 
220
# These two targets complete the layout defined on
 
221
# https://developer.mozilla.org/en/XULRunner/Deploying_XULRunner_1.8
 
222
# for their respective platforms in regards to XULRunner deployment
 
223
 
 
224
# Note that I decided to use win/lin channels for ease of coding platform specific updates
 
225
 
 
226
win-xulrunner: client_app
 
227
        @echo 'Preparing Windows xulrunner'
 
228
        @if [ ! -f ${XULRUNNER_WINFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_WINFILE}; fi
 
229
        @unzip -q ${XULRUNNER_WINFILE} -dclient
 
230
        @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","win");' >> client/defaults/preferences/autochannel.js; fi;
 
231
        @echo 'Preparing stub'
 
232
        @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
 
233
 
 
234
linux-xulrunner: client_app
 
235
        @echo 'Preparing Linux xulrunner'
 
236
        @if [ ! -f ${XULRUNNER_LINUXFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_LINUXFILE}; fi
 
237
        @cd client; tar xjf ../${XULRUNNER_LINUXFILE}; cd ..
 
238
        @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","lin");' >> client/defaults/preferences/autochannel.js; fi;
 
239
        @echo 'Preparing stub'
 
240
        @mv client/xulrunner/xulrunner-stub client/evergreen
 
241
 
 
242
# Build a windows installer.
 
243
 
 
244
win-client: win-xulrunner
 
245
        @echo 'Building installer'
 
246
        @makensis -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_EXTRAOPTS} windowssetup.nsi
 
247
        @echo 'Done'
 
248
 
 
249
# For linux, just build a tar.bz2 archive
 
250
 
 
251
linux-client: linux-xulrunner
 
252
        @echo 'Packing as evergreen_staff_client.tar.bz2'
 
253
        @rm -f evergreen_staff_client.tar.bz2
 
254
        @cd client; tar cjf ../evergreen_staff_client.tar.bz2 *; cd ..
 
255
        @echo 'Done'
 
256
 
 
257
# For running the updates script with the correct updates directory, optionally building clients as well
 
258
 
 
259
updates updates-client win-updates win-updates-client linux-updates linux-updates-client generic-updates generic-updates-client extension-updates:
 
260
        @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
 
261
        @if [ ! -x external/make_updates.sh ]; then chmod u+x external/make_updates.sh; fi
 
262
        @if [ ! -x external/make_updates.sh ]; then echo 'ERROR! external/make_updates.sh is not executable!'; exit 1; fi
 
263
        @external/make_updates.sh ${UPDATESDIR} $@