Bug 1360525 - Separate repackage out into subcommands; r?chmanchester draft
authorMike Shal <mshal@mozilla.com>
Wed, 03 May 2017 15:06:44 -0400
changeset 593488 b6e8ff1947926492c5160f66aee7cdc5d8dcfdeb
parent 590317 a49112c7a5765802096b3fc298069b9495436107
child 593489 eb8f1bc347aca08e2820fa8c64f66e063b68bc2b
push id63715
push userbmo:mshal@mozilla.com
push dateTue, 13 Jun 2017 18:44:17 +0000
reviewerschmanchester
bugs1360525
milestone55.0a1
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
python/mozbuild/mozbuild/mach_commands.py
testing/mozharness/scripts/repackage.py
--- 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,
         )