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
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003
# ZeroC, Inc.
# Billerica, MA, USA
#
# All Rights Reserved.
#
# Ice is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# **********************************************************************
import os, sys, shutil, fnmatch, re, string
#
# Show usage information.
#
def usage():
print "Usage: " + sys.argv[0] + " [options] [tag]"
print
print "Options:"
print "-h Show this message."
print
print "If no tag is specified, HEAD is used."
def getIceVersion(file):
config = open(file, "r")
return re.search("ICE_STRING_VERSION \"([0-9\.]*)\"", config.read()).group(1)
def getIceSoVersion(file):
config = open(file, "r")
intVersion = int(re.search("ICE_INT_VERSION ([0-9]*)", config.read()).group(1))
majorVersion = intVersion / 10000
minorVersion = intVersion / 100 - 100 * majorVersion
return '%d' % (majorVersion * 10 + minorVersion)
#
# Check arguments
#
tag = "-rHEAD"
for x in sys.argv[1:]:
if x == "-h":
usage()
sys.exit(0)
elif x.startswith("-"):
print sys.argv[0] + ": unknown option `" + x + "'"
print
usage()
sys.exit(1)
else:
tag = "-r" + x
if not os.environ.has_key("ICE_HOME"):
print "The ICE_HOME environment variable is not set."
sys.exit(1)
#
# Remove any existing distribution directory and create a new one.
#
distdir = "bindist"
if os.path.exists(distdir):
shutil.rmtree(distdir)
os.mkdir(distdir)
os.chdir(distdir)
cwd = os.getcwd()
#
# Export Config.h from CVS.
#
os.system("cvs -d cvs.mutablerealms.com:/home/cvsroot export " + tag + " ice/include/IceUtil/Config.h")
#
# Get Ice version.
#
version = getIceVersion("ice/include/IceUtil/Config.h")
intVer = getIceSoVersion("ice/include/IceUtil/Config.h")
#
# Verify Ice version in CVS export matches the one in ICE_HOME.
#
version2 = getIceVersion(os.environ["ICE_HOME"] + "/include/IceUtil/Config.h")
shutil.rmtree("ice")
if version != version2:
print sys.argv[0] + ": the CVS version (" + version + ") does not match ICE_HOME (" + version2 + ")"
sys.exit(1)
icever = "Ice-" + version
os.mkdir(icever)
#
# Get platform.
#
platform = ""
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
platform = "win32"
elif sys.platform.startswith("linux"):
platform = "linux"
elif sys.platform.startswith("sunos"):
platform = "solaris"
else:
print "unknown platform (" + sys.platform + ")!"
sys.exit(1)
#
# Copy executables and libraries.
#
icehome = os.environ["ICE_HOME"]
executables = [ ]
libraries = [ ]
symlinks = 0
debug = ""
strip = 0
if platform == "win32":
winver = version.replace(".", "")
if not os.path.exists(icehome + "/bin/iceutil" + winver + ".dll"):
debug = "d"
executables = [ \
"icecpp.exe",\
"slice2freezej.exe",\
"slice2java.exe",\
"slice2docbook.exe",\
"iceutil" + winver + debug + ".dll",\
"slice" + winver + debug + ".dll",\
]
libraries = [ \
]
else:
executables = [ \
"icecpp",\
"slice2freezej",\
"slice2java",\
"slice2docbook",\
]
libraries = [ \
"libIceUtil.so",\
"libSlice.so",\
]
symlinks = 1
strip = 1
bindir = icever + "/bin"
libdir = icever + "/lib"
os.mkdir(bindir)
os.mkdir(libdir)
for x in executables:
shutil.copyfile(icehome + "/bin/" + x, bindir + "/" + x)
if symlinks:
for so in libraries:
soVer = so + '.' + version
soInt = so + '.' + intVer
shutil.copyfile(icehome + "/lib/" + soVer, libdir + "/" + soVer)
os.chdir(libdir)
os.symlink(soVer, soInt)
os.symlink(soInt, so)
os.chdir(cwd)
else:
for x in libraries:
shutil.copyfile(icehome + "/lib/" + x, libdir + "/" + x)
if platform == "win32":
if not os.environ["WINDIR"]:
print "WINDIR environment variable not set"
sys.exit(1)
dlls = [ \
"msvcp70" + debug + ".dll",\
"msvcr70" + debug + ".dll",\
]
for dll in dlls:
dllpath = os.environ["WINDIR"] + "/system32/" + dll
if not os.path.exists(dllpath):
print "VC++.NET runtime DLL " + dllpath + " not found"
sys.exit(1)
shutil.copyfile(dllpath, bindir + "/" + dll)
if strip:
for x in executables:
os.system("strip " + bindir + "/" + x)
os.chmod(bindir + "/" + x, 0755)
for x in libraries:
os.system("strip " + libdir + "/" + x)
#
# Create binary archives.
#
os.system("tar cvzf " + icever + "-bin-" + platform + ".tar.gz " + icever)
os.system("zip -9ry " + icever + "-bin-" + platform + ".zip " + icever)
#
# Copy files (README, etc.).
#
#
# Done.
#
shutil.rmtree(icever)
|