1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
import os, sys, shutil, fnmatch, re
#
# Show usage information.
#
def usage():
print "Usage: " + sys.argv[0] + " [options] [tag]"
print
print "Options:"
print "-h Show this message."
print "-d Skip SGML documentation conversion."
print "-t Skip building translators and use the ones in PATH."
print "-f Keep going if precondition checks fail."
print "-v Be verbose."
print
print "If no tag is specified, HEAD is used."
#
# Taken from ice/config/TestUtil.py
#
# If having this duplicated is really a problem we should split these
# methods out into their own module.
#
def isHpUx():
if sys.platform == "hp-ux11":
return 1
else:
return 0
def isDarwin():
if sys.platform == "darwin":
return 1
else:
return 0
def isAIX():
if sys.platform in ['aix4', 'aix5']:
return 1
else:
return 0
#
# Find files matching a pattern.
#
def find(path, patt):
result = [ ]
files = os.listdir(path)
for x in files:
fullpath = os.path.join(path, x);
if fnmatch.fnmatch(x, patt):
result.append(fullpath)
if os.path.isdir(fullpath) and not os.path.islink(fullpath):
result.extend(find(fullpath, patt))
return result
#
# Fix version in README, INSTALL files
#
def fixVersion(files, version):
for file in files:
origfile = file + ".orig"
os.rename(file, origfile)
oldFile = open(origfile, "r")
newFile = open(file, "w")
newFile.write(re.sub("@ver@", version, oldFile.read()))
newFile.close()
oldFile.close()
os.remove(origfile)
#
# Are we on Windows?
#
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
print sys.argv[0] + ": this script must be run on a Unix platform."
sys.exit(1)
#
# Check arguments
#
tag = "-rHEAD"
skipDocs = False
skipTranslators = False
verbose = False
keepGoing = False
for x in sys.argv[1:]:
if x == "-h":
usage()
sys.exit(0)
elif x == "-d":
print "skipping docs"
skipDocs = True
elif x == "-t":
print "skipping translators"
skipTranslators = True
elif x == "-v":
verbose = True
elif x == "-f":
keepGoing = True
elif x.startswith("-"):
print sys.argv[0] + ": unknown option `" + x + "'"
print
usage()
sys.exit(1)
else:
tag = "-r" + x
#
# Remove any existing "dist" directory and create a new one.
#
distdir = "dist"
if os.path.exists(distdir):
shutil.rmtree(distdir)
os.mkdir(distdir)
os.chdir(distdir)
#
# Export Java and C++ sources from CVS.
#
# NOTE: Assumes that the C++ and Java trees will use the same tag.
#
print "Checking out CVS tag " + tag + "..."
if verbose:
quiet = ""
else:
quiet = "-Q"
os.system("cvs " + quiet + " -d cvs.zeroc.com:/home/cvsroot export " + tag +
" icej ice/bin ice/config ice/doc ice/include ice/lib ice/slice ice/src")
#
# Check known preconditions for proper distribution building. Failed
# checks do not result in immediate failure. Error messages are
# displayed and the precondition checks continue to aide in identifying
# other problems. If any of the precondition checks fail, the script
# terminates.
#
f = file(os.path.join("icej", "config", "build.properties"))
buildProperties = f.readlines();
f.close()
errorOut = False
for p in buildProperties:
checkFilename = None
d = p.split("=")
if d[0].strip() in ["jgoodies.looks", "jgoodies.forms", "berkeleydb.jar"]:
if not os.path.exists(d[1].strip()):
print "ERROR: %s is not in configured location. IceGridGUI.jar will not build correctly!" % d[1].strip()
errorOut = True
if not os.environ.has_key("CLASSPATH"):
print "ERROR: No CLASSPATH, unable to find ProGuard jar file."
errorOut = True
else:
classpath = os.environ["CLASSPATH"]
found = False
for e in classpath.split(os.pathsep):
if e.find("proguard.jar") != -1:
if os.path.exists(e):
found = True
break
if not found:
print "ERROR: Unable to find ProGuard in CLASSPATH"
errorOut = True
if errorOut:
print "Failed precondition checks! See above messages."
if not keepGoing:
sys.exit(1)
#
# Copy Slice directories.
#
print "Copying Slice directories..."
slicedirs = [
"Freeze",
"Glacier2",
"Ice",
"IceBox",
"IcePatch2",
"IceStorm",
"IceGrid"
]
os.mkdir(os.path.join("icej", "slice"))
for x in slicedirs:
shutil.copytree(os.path.join("ice", "slice", x), os.path.join("icej", "slice", x), 1)
#
# Build slice2java and slice2freezej.
#
if not skipTranslators:
print "Building translators..."
cwd = os.getcwd()
os.chdir(os.path.join("ice", "src", "icecpp"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "IceUtil"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "Slice"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "slice2java"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "slice2freezej"))
os.system("gmake")
os.chdir(cwd)
os.environ["PATH"] = os.path.join(cwd, "ice", "bin") + ":" + os.getenv("PATH", "")
if isHpUx():
os.environ["SHLIB_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("SHLIB_PATH", "")
elif isDarwin():
os.environ["DYLD_LIBRARY_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("DYLD_LIBRARY_PATH", "")
elif isAIX():
os.environ["LIBPATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("LIBPATH", "")
else:
os.environ["LD_LIBRARY_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("LD_LIBRARY_PATH", "")
if os.environ.has_key("ICE_HOME"):
del os.environ["ICE_HOME"]
#
# Generate HTML documentation. We need to build icecpp
# and slice2html first.
#
if not skipDocs:
print "Generating documentation..."
cwd = os.getcwd()
os.chdir(os.path.join("ice", "src", "icecpp"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "IceUtil"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "Slice"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "src", "slice2html"))
os.system("gmake")
os.chdir(cwd)
os.chdir(os.path.join("ice", "doc"))
os.system("gmake")
os.chdir(cwd)
os.mkdir(os.path.join("icej", "doc"))
os.rename(os.path.join("ice", "doc", "reference"), os.path.join("icej", "doc", "reference"))
os.rename(os.path.join("ice", "doc", "README.html"), os.path.join("icej", "doc", "README.html"))
os.rename(os.path.join("ice", "doc", "images"), os.path.join("icej", "doc", "images"))
#
# Remove files.
#
print "Removing unnecessary files..."
filesToRemove = [ \
os.path.join("icej", "makedist.py"), \
]
filesToRemove.extend(find("icej", ".dummy"))
for x in filesToRemove:
os.remove(x)
cwd = os.getcwd()
os.chdir("icej")
#
# Build sources.
#
print "Compiling Java sources..."
if verbose:
quiet = ""
else:
quiet = " -q"
os.system("ant" + quiet)
distroSuffix = "java2"
#
# Clean out the lib directory but save the jar files.
#
os.rename(os.path.join("lib", "Ice.jar"), "Ice.jar")
if os.path.exists(os.path.join("lib", "IceGridGUI.jar")):
print "Found IceGridGUI, is this the Java 2 targeted source distro?"
os.rename(os.path.join("lib", "IceGridGUI.jar"), "IceGridGUI.jar")
else:
print "No IceGridGUI, is this the Java 5 targeted source distro?"
distroSuffix = "java5"
shutil.rmtree("lib")
os.mkdir("lib")
os.rename("Ice.jar", os.path.join("lib", "Ice.jar"))
if os.path.exists(os.path.join("IceGridGUI.jar")):
os.rename("IceGridGUI.jar", os.path.join("lib", "IceGridGUI.jar"))
else:
os.remove("THIRD_PARTY_LICENSE")
os.remove("THIRD_PARTY_SOURCES")
#
# Remove "generated" subdirectories.
#
filesToRemove = find(".", "*generated") # generated, cgenerated, sgenerated
for x in filesToRemove:
shutil.rmtree(x)
#
# Remove other unnecessary subdirectories.
#
#shutil.rmtree("admin")
shutil.rmtree("depcache")
os.chdir(cwd)
#
# Get Ice version.
#
config = open(os.path.join("icej", "src", "IceUtil", "Version.java"), "r")
version = re.search("ICE_STRING_VERSION = \"([0-9\.]*)\"", config.read()).group(1)
print "Fixing version in README and INSTALL files..."
fixVersion(find("icej", "README*"), version)
fixVersion(find("icej", "INSTALL*"), version)
#
# Create source archives.
#
print "Creating distribution archives..."
icever = "IceJ-" + version + "-" + distroSuffix
os.rename("icej", icever)
if verbose:
quiet = "v"
else:
quiet = ""
os.system("chmod -R u+rw,go+r-w . " + icever)
os.system("find " + icever + " \\( -name \"*.java\" -or -name \"*.ice\" \\) -exec chmod a-x {} \\;")
os.system("find " + icever + " \\( -name \"README*\" -or -name \"INSTALL*\" \\) -exec chmod a-x {} \\;")
os.system("find " + icever + " \\( -name \"*.xml\" -or -name \"*.html\" \\) -exec chmod a-x {} \\;")
os.system("find " + icever + " -type d -exec chmod a+x {} \\;")
os.system("find " + icever + " -perm +111 -exec chmod a+x {} \\;")
os.system("tar c" + quiet + "zf " + icever + ".tar.gz " + icever)
if verbose:
quiet = ""
else:
quiet = "-q"
os.system("zip -9 -r " + quiet + " " + icever + ".zip " + icever)
#
# Copy files (README, etc.).
#
shutil.copyfile(os.path.join(icever, "CHANGES"), "IceJ-" + version + "-CHANGES")
#
# Done.
#
print "Cleaning up..."
shutil.rmtree(icever)
shutil.rmtree("ice")
print "Done."
|