Bug 531275 - add the platform parameter to generate l10n nightly snippets r=coop,nthomas
authorArmen Zambrano Gasparnian <armenzg@mozilla.com>
Wed, 16 Dec 2009 18:34:28 -0500
changeset 36300 d64839cc1cc4e5894ec2b0aa57c4a47aa414a8e0
parent 36299 5066a8acb1b3e6fae0041f6da015dddb9d4ecd83
child 36306 69d5959d95cca3eb616cf0c7fc300f2b2efca1d5
push idunknown
push userunknown
push dateunknown
reviewerscoop, nthomas
bugs531275
milestone1.9.3a1pre
Bug 531275 - add the platform parameter to generate l10n nightly snippets r=coop,nthomas
toolkit/locales/l10n.mk
tools/update-packaging/generatesnippet.py
--- a/toolkit/locales/l10n.mk
+++ b/toolkit/locales/l10n.mk
@@ -206,10 +206,11 @@ endif
 endif
 
 generate-snippet-%:
 	$(PYTHON) $(topsrcdir)/tools/update-packaging/generatesnippet.py \
           --mar-path=$(_ABS_DIST)/update \
           --application-ini-file=$(STAGEDIST)/application.ini \
           --locale=$* \
           --product=$(MOZ_PKG_APPNAME) \
+          --platform=$(MOZ_PKG_PLATFORM) \
           --download-base-URL=$(DOWNLOAD_BASE_URL) \
           --verbose
--- a/tools/update-packaging/generatesnippet.py
+++ b/tools/update-packaging/generatesnippet.py
@@ -61,67 +61,73 @@ def main():
                       action="store",
                       dest="locale",
                       help="[Required] Specify which locale we are generating the snippet for.")
     parser.add_option("-p",
                       "--product",
                       action="store",
                       dest="product",
                       help="[Required] This option is used to generate the URL to download the MAR file.")
+    parser.add_option("--platform",
+                      action="store",
+                      dest="platform",
+                      help="[Required] This option is used to indicate which target platform.")
     parser.add_option("--download-base-URL",
                       action="store",
                       dest="downloadBaseURL",
                       help="This option indicates under which.")
     parser.add_option("-v",
                       "--verbose",
                       action="store_true",
                       dest="verbose",
                       default=False,
                       help="This option increases the output of the script.")
     (options, args) = parser.parse_args()
     for req, msg in (('marPath', "the absolute path to the where the MAR file is"),
                      ('applicationIniFile', "the absolute path to the application.ini file."),
                      ('locale', "a locale."),
-                     ('product', "specify a product.")):
+                     ('product', "specify a product."),
+                     ('platform', "specify the platform.")):
         if not hasattr(options, req):
             parser.error('You must specify %s' % msg)
 
     if not options.downloadBaseURL or options.downloadBaseURL == '':
         options.downloadBaseURL = 'http://ftp.mozilla.org/pub/mozilla.org/%s/nightly' % options.product
 
     snippet = generateSnippet(options.marPath,
                               options.applicationIniFile,
                               options.locale,
                               options.downloadBaseURL,
-                              options.product)
+                              options.product,
+                              options.platform)
     f = open(os.path.join(options.marPath, 'complete.update.snippet'), 'wb')
     f.write(snippet)
     f.close()
 
     if options.verbose:
         # Show in our logs what the contents of the snippet are
         print snippet
 
 def generateSnippet(abstDistDir, applicationIniFile, locale,
-                    downloadBaseURL, product):
+                    downloadBaseURL, product, platform):
     # Let's extract information from application.ini
     c = ConfigParser()
     try:
         c.readfp(open(applicationIniFile))
     except IOError, (stderror):
        sys.exit(stderror) 
     buildid = c.get("App", "BuildID")
     appVersion = c.get("App", "Version")
     branchName = c.get("App", "SourceRepository").split('/')[-1]
 
     marFileName = '%s-%s.%s.%s.complete.mar' % (
         product,
         appVersion,
         locale,
-        getPlatform())
+        platform)
     # Let's determine the hash and the size of the MAR file
     # This function exits the script if the file does not exist
     (completeMarHash, completeMarSize) = getFileHashAndSize(
         os.path.join(abstDistDir, marFileName))
     # Construct the URL to where the MAR file will exist
     interfix = ''
     if locale == 'en-US':
         interfix = ''
@@ -143,24 +149,16 @@ sha1
 """ % dict( marDownloadURL=marDownloadURL, 
             completeMarHash=completeMarHash,
             completeMarSize=completeMarSize,
             buildid=buildid,
             appVersion=appVersion)
 
     return snippet
 
-def getPlatform():
-    if platform.system() == "Linux":
-        return "linux-i686"
-    elif platform.system() in ("Windows", "Microsoft"):
-        return "win32"
-    elif platform.system() == "Darwin":
-        return "mac"
-
 def getFileHashAndSize(filepath):
     sha1Hash = 'UNKNOWN'
     size = 'UNKNOWN'
 
     try:
         # open in binary mode to make sure we get consistent results
         # across all platforms
         f = open(filepath, "rb")