@@ -59,6 +59,45 @@ def suffix(self):
5959 else :
6060 return "-enterprise" if int (self .ver .split ("." )[1 ]) % 2 == 0 else "-enterprise-unstable"
6161
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+
62101
63102class EnterpriseDistro (packager .Distro ):
64103 """EnterpriseDistro class."""
@@ -174,7 +213,7 @@ def main():
174213
175214 args = packager .get_args (distros , ARCH_CHOICES )
176215
177- spec = EnterpriseSpec (args . server_version , args . metadata_gitspec , args . release_number )
216+ spec = get_enterprise_spec (args )
178217
179218 oldcwd = os .getcwd ()
180219 srcdir = oldcwd + "/../"
@@ -211,6 +250,13 @@ def main():
211250 os .chdir (oldcwd )
212251
213252
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+
214260def tarfile (build_os , arch , spec ):
215261 """Return the location where we store the downloaded tarball for this package."""
216262 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):
236282
237283def unpack_binaries_into (build_os , arch , spec , where ):
238284 """Unpack the tarfile for (build_os, arch, spec) into directory where."""
239- rootdir = os .getcwd ()
285+ root_dir = os .getcwd ()
240286 packager .ensure_dir (where )
241287 # Note: POSIX tar doesn't require support for gtar's "-C" option,
242288 # and Python's tarfile module prior to Python 2.7 doesn't have the
243289 # features to make this detail easy. So we'll just do the dumb
244290 # thing and chdir into where and run tar there.
245291 os .chdir (where )
246292 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 ()
258295 except Exception :
259296 exc = sys .exc_info ()[1 ]
260- os .chdir (rootdir )
297+ os .chdir (root_dir )
261298 raise exc
262- os .chdir (rootdir )
299+ os .chdir (root_dir )
263300
264301
265302def make_package (distro , build_os , arch , spec , srcdir ):
0 commit comments