38 This script generates the complete snippet for a given locale or en-US
39 Most of the parameters received are to generate the MAR's download URL
40 and determine the MAR's filename
42 import sys, os, platform, sha
43 from optparse
import OptionParser
44 from ConfigParser
import ConfigParser
45 from stat
import ST_SIZE
49 parser = OptionParser(
50 usage=
"%prog [options]")
51 parser.add_option(
"--mar-path",
54 help=
"[Required] Specify the absolute path where the MAR file is found.")
55 parser.add_option(
"--application-ini-file",
57 dest=
"applicationIniFile",
58 help=
"[Required] Specify the absolute path to the application.ini file.")
59 parser.add_option(
"-l",
63 help=
"[Required] Specify which locale we are generating the snippet for.")
64 parser.add_option(
"-p",
68 help=
"[Required] This option is used to generate the URL to download the MAR file.")
69 parser.add_option(
"--platform",
72 help=
"[Required] This option is used to indicate which target platform.")
73 parser.add_option(
"--branch",
76 help=
"This option is used to indicate which branch name to use for FTP file names.")
77 parser.add_option(
"--download-base-URL",
79 dest=
"downloadBaseURL",
80 help=
"This option indicates under which.")
81 parser.add_option(
"-v",
86 help=
"This option increases the output of the script.")
87 (options, args) = parser.parse_args()
88 for req, msg
in ((
'marPath',
"the absolute path to the where the MAR file is"),
89 (
'applicationIniFile',
"the absolute path to the application.ini file."),
90 (
'locale',
"a locale."),
91 (
'product',
"specify a product."),
92 (
'platform',
"specify the platform.")):
93 if not hasattr(options, req):
94 parser.error(
'You must specify %s' % msg)
96 if not options.downloadBaseURL
or options.downloadBaseURL ==
'':
97 options.downloadBaseURL =
'http://ftp.mozilla.org/pub/mozilla.org/%s/nightly' % options.product
99 if not options.branch
or options.branch ==
'':
100 options.branch =
None
103 options.applicationIniFile,
105 options.downloadBaseURL,
109 f = open(os.path.join(options.marPath,
'complete.update.snippet'),
'wb')
118 downloadBaseURL, product, platform, branch):
122 c.readfp(open(applicationIniFile))
123 except IOError, (stderror):
125 buildid = c.get(
"App",
"BuildID")
126 appVersion = c.get(
"App",
"Version")
127 branchName = branch
or c.get(
"App",
"SourceRepository").split(
'/')[-1]
129 marFileName =
'%s-%s.%s.%s.complete.mar' % (
137 os.path.join(abstDistDir, marFileName))
140 if locale ==
'en-US':
144 marDownloadURL =
"%s/%s%s/%s" % (downloadBaseURL,
149 snippet =
"""complete
157 """ % dict( marDownloadURL=marDownloadURL,
158 completeMarHash=completeMarHash,
159 completeMarSize=completeMarSize,
161 appVersion=appVersion)
172 f = open(filepath,
"rb")
173 shaObj = sha.new(f.read())
174 sha1Hash = shaObj.hexdigest()
175 size = os.stat(filepath)[ST_SIZE]
176 except IOError, (stderror):
179 return (sha1Hash, size)
183 Returns a string that will look like:
184 2009/12/2009-12-31-09-mozilla-central
190 datedDir =
"%s-%s-%s-%s-%s" % (year,
195 return "%s/%s/%s" % (year, month, datedDir)
197 if __name__ ==
'__main__':