changeset 219:b73ccb5bf337

lots of work to get dmg on macs to give me something i care about on mac; thank you mr jobs
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 21 Mar 2011 17:52:14 -0700
parents c82a46673ce9
children 6fd14e710650
files autobot/process/factory.py
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/autobot/process/factory.py	Mon Mar 21 15:08:04 2011 -0700
+++ b/autobot/process/factory.py	Mon Mar 21 17:52:14 2011 -0700
@@ -80,19 +80,41 @@
       # See:
       # http://mxr.mozilla.org/mozilla-central/source/build/package/mac_osx/unpack-diskimage
       # http://hg.mozilla.org/qa/mozmill-automation/file/default/libs/install.py
+      # ideally, the duplication of intent should be disappeared
       self.addStep(ShellCommand(command=['rm', '-rf', 'firefox-tmp']))
       self.addStep(ShellCommand(command=['mkdir', 'firefox-tmp'],
                                 haltOnFailure=True))
       self.addStep(ShellCommand(command=['hdiutil', 'attach',
+                                         '-verbose', '-noautoopen',
                                          WithProperties('%(firefox_bundle)s'),
                                          '-mountpoint', 'firefox-tmp'],
                                 haltOnFailure=True))
+      self.addStep(ShellCommand(command=['rm', '-rf', 'firefox']))
+      def app_name(returncode, stdout, stderr):
+        """
+        extract the name of the app
+        """
+        return {'app_name': stdout.rsplit('/', 1)[-1]}
+      self.addStep(SetProperty(command=['echo', 'firefox-tmp', '*.app'],
+                               extract_fn=app_name))
+      self.addStep(ShellCommand(command=['cp', '-r', 'firefox-tmp', 'firefox']))
+
+      # it would be nice to reuse the logic from
+      # https://github.com/mozautomation/mozmill/blob/master/mozrunner/mozrunner/runner.py
+      # however, I can't think of a clever way of doing this right now.
+      # When refactoring Mozilla, things like this should be kept in
+      # mind wrt consolidating towards best practices instead of
+      # copy+pasting and creating (dysfunctional, difficult to maintain)
+      # code islands
+      self.addStep(SetProperty(property='firefox',
+                               command=self.abspath(WithProperties('firefox/%(app_name)s/Contents/MacOS/firefox-bin'))))
+                   
     else:
       raise NotImplementedError("FirefoxDownloader doesn't know how to work with your os: %s" % platform['os'])
 
   def abspath(self, path):
     """returns a command that will print the absolute path"""
-    # TODO: could use WirthProperties if needed
+    # TODO: could use WithProperties if needed
     # could also go not in a class, again if needed
     return ['python', '-c',
             'import os; print os.path.abspath("%s")' % path]