Bug 1360525 - Separate repackage out into subcommands; r?chmanchester
With multiple types of repackaging, it will be simpler to manage the
various commands if they are organized as sub-commands. This way the
different repackage types can take varying arguments, and we don't have
to guess on the repackage type based on the output filename.
MozReview-Commit-ID: BknRPAwFG5H
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -1937,29 +1937,29 @@ class Repackage(MachCommandBase):
'''Repackages artifacts into different formats.
This is generally used after packages are signed by the signing
scriptworkers in order to bundle things up into shippable formats, such as a
.dmg on OSX or an installer exe on Windows.
'''
@Command('repackage', category='misc',
description='Repackage artifacts into different formats.')
+ def repackage(self):
+ print("Usage: ./mach repackage [dmg|installer|mar] [args...]")
+
+ @SubCommand('repackage', 'dmg',
+ description='Repackage a tar file into a .dmg for OSX')
@CommandArgument('--input', '-i', type=str, required=True,
help='Input filename')
@CommandArgument('--output', '-o', type=str, required=True,
help='Output filename')
- def repackage(self, input, output):
+ def repackage_dmg(self, input, output):
if not os.path.exists(input):
print('Input file does not exist: %s' % input)
return 1
if not os.path.exists(os.path.join(self.topobjdir, 'config.status')):
print('config.status not found. Please run |mach configure| '
'prior to |mach repackage|.')
return 1
- if output.endswith('.dmg'):
- from mozbuild.repackaging.dmg import repackage_dmg
- repackage_dmg(input, output)
- else:
- print("Repackaging into output '%s' is not yet supported." % output)
- return 1
- return 0
+ from mozbuild.repackaging.dmg import repackage_dmg
+ repackage_dmg(input, output)
--- a/testing/mozharness/scripts/repackage.py
+++ b/testing/mozharness/scripts/repackage.py
@@ -76,16 +76,17 @@ class Repackage(BaseScript):
return self.abs_dirs
def repackage(self):
config = self.config
dirs = self.query_abs_dirs()
infile = os.path.join(config['input_home'], config['input_filename'])
outfile = os.path.join(dirs['abs_upload_dir'], config['output_filename'])
command = [sys.executable, 'mach', '--log-no-times', 'repackage',
+ 'dmg',
'--input', infile,
'--output', outfile]
return self.run_command(
command=command,
cwd=dirs['abs_mozilla_dir'],
halt_on_failure=True,
)