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
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2014 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, fnmatch, re, getopt, atexit, shutil, subprocess, threading
i386Packages = [
"libjs-zeroc-ice_@debver@-1_i386.deb",
"libzeroc-freeze@debmmver@_@debver@-1_i386.deb",
"libzeroc-ice@debmmver@_@debver@-1_i386.deb",
"libzeroc-ice-dev_@debver@-1_i386.deb",
"libzeroc-ice-java_@debver@-1_i386.deb",
"libzeroc-icestorm@debmmver@_@debver@-1_i386.deb",
"php5-zeroc-ice_@debver@-1_i386.deb",
"php5-zeroc-ice-dev_@debver@-1_i386.deb",
"python-zeroc-ice_@debver@-1_i386.deb",
"python-zeroc-ice-dev_@debver@-1_i386.deb",
"ruby-zeroc-ice_@debver@-1_i386.deb",
"ruby-zeroc-ice-dev_@debver@-1_i386.deb",
"zeroc-glacier2_@debver@-1_i386.deb",
"zeroc-ice@debmmver@_@debver@-1_i386.changes",
"zeroc-icebox_@debver@-1_i386.deb",
"zeroc-icegrid_@debver@-1_i386.deb",
"zeroc-icepatch2_@debver@-1_i386.deb",
"zeroc-ice-utils_@debver@-1_i386.deb"]
amd64Packages = [
"libjs-zeroc-ice_@debver@-1_amd64.deb",
"libzeroc-freeze@debmmver@_@debver@-1_amd64.deb",
"libzeroc-ice@debmmver@_@debver@-1_amd64.deb",
"libzeroc-ice-dev_@debver@-1_amd64.deb",
"libzeroc-ice-java_@debver@-1_amd64.deb",
"libzeroc-icestorm@debmmver@_@debver@-1_amd64.deb",
"php5-zeroc-ice_@debver@-1_amd64.deb",
"php5-zeroc-ice-dev_@debver@-1_amd64.deb",
"python-zeroc-ice_@debver@-1_amd64.deb",
"python-zeroc-ice-dev_@debver@-1_amd64.deb",
"ruby-zeroc-ice_@debver@-1_amd64.deb",
"ruby-zeroc-ice-dev_@debver@-1_amd64.deb",
"zeroc-glacier2_@debver@-1_amd64.deb",
"zeroc-ice@debmmver@_@debver@-1_amd64.changes",
"zeroc-icebox_@debver@-1_amd64.deb",
"zeroc-icegrid_@debver@-1_amd64.deb",
"zeroc-icepatch2_@debver@-1_amd64.deb",
"zeroc-ice-utils_@debver@-1_amd64.deb"]
noarchPackages = [
"node-zeroc-ice_@debver@-1_all.deb",
"node-zeroc-ice-dev_@debver@-1_all.deb",
"zeroc-ice@debmmver@_@debver@-1.debian.tar.gz",
"zeroc-ice@debmmver@_@debver@-1.dsc",
"zeroc-ice@debmmver@_@debver@.orig.tar.gz",
"zeroc-ice-utils-java_@debver@-1_all.deb",
"zeroc-ice-slice_@debver@-1_all.deb",
"zeroc-ice-all-runtime_@debver@-1_all.deb",
"zeroc-ice-all-dev_@debver@-1_all.deb"]
def runCommand(cmd):
print(cmd)
if os.system(cmd) != 0:
sys.exit(1)
aptftpConf = """
APT::FTPArchive::Release {
Origin "ZeroC Ice";
Label "ZeroC Ice";
Suite "unstable";
Codename "%(codename)s";
Architectures "all amd64 i386";
Components "main";
Description "Apt repository for ZeroC Ice";
};
"""
aptgenerateConf = """
Dir::ArchiveDir ".";
Dir::CacheDir ".";
TreeDefault::Directory "pool/%(codename)s/main/";
TreeDefault::SrcDirectory "pool/%(codename)s/main/";
Default::Packages::Extensions ".deb";
Default::Packages::Compress ". gzip bzip2";
Default::Sources::Compress ". gzip bzip2";
Default::Contents::Compress ". gzip bzip2";
BinDirectory "dists/%(codename)s/main" {
Packages "dists/%(codename)s/main/binary-i386/Packages";
Packages "dists/%(codename)s/main/binary-amd64/Packages";
Contents "dists/%(codename)s/main/Contents-i386";
Contents "dists/%(codename)s/main/Contents-amd64";
SrcPackages "dists/%(codename)s/main/source/Sources";
};
Tree "dists/%(codename)s" {
Sections "main";
Architectures "amd64 i386 source";
};
"""
repoLayout = [
"dists/%(codename)s/main/binary-i386",
"dists/%(codename)s/main/source",
"dists/%(codename)s/main/binary-amd64",
"pool/%(codename)s/main/i/ice@debmmver@"]
buildCommand = """
%(sshCommand)s %(sshUser)s@%(sshBuildHost)s 'rm -rf %(buildDir)s && mkdir %(buildDir)s' && \\
%(scpCommand)s %(distFiles)s %(sshUser)s@%(sshBuildHost)s:/home/%(sshUser)s/%(buildDir)s && \\
%(scpCommand)s %(sourceDist)s %(sshUser)s@%(sshBuildHost)s:/home/%(sshUser)s/%(buildDir)s && \\
%(sshCommand)s %(sshUser)s@%(sshBuildHost)s \\
'cd %(buildDir)s && tar zxf %(distFiles)s && python distfiles-@ver@/bin/makeubuntupackages.py -b %(codename)s -d . > build-log.txt 2>&1'
"""
class Builder(threading.Thread):
def __init__(self, command):
self._status = 0
self._command = command
threading.Thread.__init__(self)
def run(self):
_status = runCommand(self._command)
def status():
return _status
#
# Default values
#
codename = "trusty"
sourceDist = "zeroc-ice@debmmver@_@debver@.orig.tar.gz"
distFiles = "distfiles-@ver@.tar.gz"
signKey = "A62B38F8" if "@ver@".endswith("b") else "53A473EE"
sshKey = None
sshUser = os.environ.get('USER')
i386BuildHost = None
amd64BuildHost = None
buildDir = "dist-HEAD"
skipBuild = False
#
# Program usage.
#
def usage():
print("")
print(r"Options:")
print("")
print(r" --help Show this message.")
print("")
print(r" --ssh-key SSH key used to sign into build host.")
print("")
print(r" --ssh-user SSH user used to sign into build host.")
print("")
print(r" --i386-build-host ip address or hostname for the i386 package builder.")
print("")
print(r" --amd64-build-host ip address or hostname for the amd64 package builder.")
print("")
print(r" --build-dir directory to build the packages, it is relative to the user home.")
print("")
print(r" --codename Ubuntu release codename we are building (trusty, utopic, ...).")
print("")
print(r" --skip-build Don't build packages, just recreate the repository.")
print("")
try:
opts, args = getopt.getopt(sys.argv[1:], "", ["help", "ssh-key=", "ssh-user=", "i386-build-host=",
"amd64-build-host=", "build-dir=", "codename=", "skip-build"])
except getopt.GetoptError as e:
print("Error %s " % e)
usage()
sys.exit(1)
if args:
usage()
sys.exit(1)
for o, a in opts:
if o == "--help":
usage()
sys.exit(0)
elif o == "--ssh-key":
sshKey = a
elif o == "--ssh-user":
sshUser = a
elif o == "--i386-build-host":
i386BuildHost = a
elif o == "--amd64-build-host":
amd64BuildHost = a
elif o == "--build-dir":
buildDir = a
elif o == "--codename":
codename = a
elif o == "--skip-build":
skipBuild = True
sshCommand = "ssh" if sshKey == None else "ssh -i %s" % sshKey
scpCommand = "scp" if sshKey == None else "scp -i %s" % sshKey
buildHosts = []
if i386BuildHost != None:
buildHosts.append(i386BuildHost)
if amd64BuildHost != None:
buildHosts.append(amd64BuildHost)
if not skipBuild:
if not buildHosts:
usage()
print("You must set the builder host(s) using --i386-build-host and/or --amd64-build-host options")
exit(1)
buildThreads = []
for host in buildHosts:
thread = Builder(buildCommand % {"sshCommand": sshCommand,
"scpCommand": scpCommand,
"sshUser": sshUser,
"sshBuildHost": host,
"buildDir": buildDir,
"signKey": signKey,
"codename": codename,
"distFiles": distFiles,
"sourceDist": sourceDist})
thread.start()
buildThreads.append(thread)
for thread in buildThreads:
thread.join()
runCommand("mkdir -p ubuntu")
for d in repoLayout:
runCommand("cd ubuntu && mkdir -p %s" % (d % {"codename": codename}))
for host in [i386BuildHost, amd64BuildHost]:
packages = i386Packages + noarchPackages if host == i386BuildHost else amd64Packages
for package in packages:
runCommand("cd ubuntu && %(scpCommand)s %(sshUser)s@%(sshBuildHost)s:/home/%(sshUser)s/%(buildDir)s/%(codename)s/%(package)s pool/%(codename)s/main/i/ice@debmmver@/" %
{"scpCommand": scpCommand,
"sshUser": sshUser,
"sshBuildHost": host,
"buildDir": buildDir,
"codename": codename,
"package": package})
#
# Sign the source package
#
for command in ["cd ubuntu && echo \"y\" | debsign -k %(signKey)s pool/%(codename)s/main/i/ice@debmmver@/zeroc-ice@debmmver@_@debver@-1.dsc"]:
runCommand(command % {"signKey": signKey, "codename": codename})
f = open('ubuntu/aptftp.conf', 'w')
f.write(aptftpConf % {"codename": codename})
f.close()
f = open('ubuntu/aptgenerate.conf', 'w')
f.write(aptgenerateConf % {"codename": codename})
f.close()
runCommand("cd ubuntu && apt-ftparchive generate aptgenerate.conf")
runCommand("cd ubuntu && apt-ftparchive release -c=aptftp.conf dists/%(codename)s > dists/%(codename)s/Release" % {"codename": codename})
#
# Sign changes and release files
#
for command in ["cd ubuntu && echo \"y\" | debsign -k %(signKey)s pool/%(codename)s/main/i/ice@debmmver@/zeroc-ice@debmmver@_@debver@-1_i386.changes",
"cd ubuntu && echo \"y\" | debsign -k %(signKey)s pool/%(codename)s/main/i/ice@debmmver@/zeroc-ice@debmmver@_@debver@-1_amd64.changes",
"cd ubuntu && gpg --yes -u %(signKey)s -bao dists/%(codename)s/Release.gpg dists/%(codename)s/Release"]:
runCommand(command % {"signKey": signKey, "codename": codename})
runCommand("rm -f ubuntu/aptftp.conf ubuntu/aptgenerate.conf")
runCommand("tar cjf ubuntu.tar.bz2 ubuntu")
|