@@ -59,6 +59,45 @@ def suffix(self):
59
59
else :
60
60
return "-enterprise" if int (self .ver .split ("." )[1 ]) % 2 == 0 else "-enterprise-unstable"
61
61
62
+ def move_required_contents (self ):
63
+ """Move the required contents to the current working directory.
64
+
65
+ Below in the for loop it's the required list of files that needs
66
+ to be moved from the extracted tarball to the current working
67
+ directory. The root path of the tarball content starts with
68
+ mongodb-linux-<suffix> so we glob since the suffix of the root path
69
+ is not a fixed text.
70
+ """
71
+ release_dir = glob ("mongodb-linux-*" )[0 ]
72
+ for release_file in (
73
+ "bin" ,
74
+ "LICENSE-Enterprise.txt" ,
75
+ "README" ,
76
+ "THIRD-PARTY-NOTICES" ,
77
+ "MPL-2" ,
78
+ ):
79
+ os .rename ("%s/%s" % (release_dir , release_file ), release_file )
80
+ os .rmdir (release_dir )
81
+
82
+
83
+ class EnterpriseCryptSpec (EnterpriseSpec ):
84
+ """EnterpriseCryptSpec class."""
85
+
86
+ def suffix (self ):
87
+ """Suffix."""
88
+ if int (self .ver .split ("." )[1 ]) == 0 :
89
+ return "-enterprise-crypt-v1"
90
+ return "-enterprise-unstable-crypt-v1"
91
+
92
+ def move_required_contents (self ):
93
+ """Move the required contents to the current working directory
94
+
95
+ The files that were extracted from the tarball file are already
96
+ in the current working directory. It does not have a mongodb-linux-...
97
+ as the root content of the tarball file is flat.
98
+ """
99
+ pass
100
+
62
101
63
102
class EnterpriseDistro (packager .Distro ):
64
103
"""EnterpriseDistro class."""
@@ -174,7 +213,7 @@ def main():
174
213
175
214
args = packager .get_args (distros , ARCH_CHOICES )
176
215
177
- spec = EnterpriseSpec (args . server_version , args . metadata_gitspec , args . release_number )
216
+ spec = get_enterprise_spec (args )
178
217
179
218
oldcwd = os .getcwd ()
180
219
srcdir = oldcwd + "/../"
@@ -211,6 +250,13 @@ def main():
211
250
os .chdir (oldcwd )
212
251
213
252
253
+ def get_enterprise_spec (args ):
254
+ """Get the EnterpriseSpec."""
255
+ if args .crypt_spec :
256
+ return EnterpriseCryptSpec (args .server_version , args .metadata_gitspec , args .release_number )
257
+ return EnterpriseSpec (args .server_version , args .metadata_gitspec , args .release_number )
258
+
259
+
214
260
def tarfile (build_os , arch , spec ):
215
261
"""Return the location where we store the downloaded tarball for this package."""
216
262
return "dl/mongodb-linux-%s-enterprise-%s-%s.tar.gz" % (spec .version (), build_os , arch )
@@ -236,30 +282,21 @@ def setupdir(distro, build_os, arch, spec):
236
282
237
283
def unpack_binaries_into (build_os , arch , spec , where ):
238
284
"""Unpack the tarfile for (build_os, arch, spec) into directory where."""
239
- rootdir = os .getcwd ()
285
+ root_dir = os .getcwd ()
240
286
packager .ensure_dir (where )
241
287
# Note: POSIX tar doesn't require support for gtar's "-C" option,
242
288
# and Python's tarfile module prior to Python 2.7 doesn't have the
243
289
# features to make this detail easy. So we'll just do the dumb
244
290
# thing and chdir into where and run tar there.
245
291
os .chdir (where )
246
292
try :
247
- packager .sysassert (["tar" , "xvzf" , rootdir + "/" + tarfile (build_os , arch , spec )])
248
- release_dir = glob ("mongodb-linux-*" )[0 ]
249
- for releasefile in (
250
- "bin" ,
251
- "LICENSE-Enterprise.txt" ,
252
- "README" ,
253
- "THIRD-PARTY-NOTICES" ,
254
- "MPL-2" ,
255
- ):
256
- os .rename ("%s/%s" % (release_dir , releasefile ), releasefile )
257
- os .rmdir (release_dir )
293
+ packager .sysassert (["tar" , "xvzf" , root_dir + "/" + tarfile (build_os , arch , spec )])
294
+ spec .move_required_contents ()
258
295
except Exception :
259
296
exc = sys .exc_info ()[1 ]
260
- os .chdir (rootdir )
297
+ os .chdir (root_dir )
261
298
raise exc
262
- os .chdir (rootdir )
299
+ os .chdir (root_dir )
263
300
264
301
265
302
def make_package (distro , build_os , arch , spec , srcdir ):
0 commit comments