1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
14 # The Original Code is Mozilla Corporation Code.
16 # The Initial Developer of the Original Code is
18 # Portions created by the Initial Developer are Copyright (C) 2007
19 # the Initial Developer. All Rights Reserved.
22 # Clint Talbert <ctalbert@mozilla.com>
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisions above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
36 # ***** END LICENSE BLOCK *****
38 from optparse
import OptionParser
44 from mozDownload
import MozDownloader
45 from mozInstall
import MozInstaller
, MozUninstaller
54 generalerr
= re
.compile(".*error.*")
56 def getPlatformDirName():
57 os
= platform
.system()
65 def getPlatformFirefoxName(version
):
66 os
= platform
.system()
68 return "Firefox%20" + version
+ ".dmg"
70 return "firefox-" + version
+ ".tar.gz"
72 return "Firefox%20Setup%20" + version
+ ".exe"
74 def getDownloadLocation(partner
, loc
):
75 os
= platform
.system()
77 return "~/minotaur-download/" + partner
+ "/" + loc
+ "/firefoxInst.dmg"
79 return "~/minotaur-download/" + partner
+ "/" + loc
+ "/firefoxInst.tar.gz"
81 return "c:/minotaur-download/" + partner
+ "/" + loc
+ "/firefoxInst.exe"
83 def getInstallLocation(partner
, loc
, isInst
):
84 os
= platform
.system()
87 return "~/minotaur-build/" + partner
+ "/" + loc
89 return "~/minotaur-build/" + partner
+ "/" + loc
+ "/Firefox.app/Contents/MacOS"
92 return "~/minotaur-build/" + partner
+ "/" + loc
94 return "~/minotaur-build/" + partner
+ "/" + loc
+ "/firefox"
96 return "c:/minotaur-build/" + partner
+ "/" + loc
98 def doDownload(partner
, loc
, url
, minDir
, creds
):
100 dwnlddir
= getDownloadLocation(partner
, loc
)
104 user
, passwd
= creds
.split(":")
106 mozDwnld
= MozDownloader(url
=url
, dest
=dwnlddir
, user
=user
,
110 print "Downloading locale: " + loc
112 print "Result: DOWNLOADED"
114 print "Result: NOT FOUND"
115 print "==========================="
118 def doInstall(branch
, partner
, loc
):
119 # Installs the build using the installbuild.sh script
120 #installs into <os>/minotaur-builds/partner/locale
121 print " DEBUG: doInstall"
123 installdir
= getInstallLocation(partner
, loc
, True)
124 dwnlddir
= getDownloadLocation(partner
, loc
)
127 installer
= MozInstaller(src
= dwnlddir
, dest
= installdir
, branch
= branch
,
128 productName
= "firefox")
130 print "DEBUG: mozinstaller threw"
133 print "========================="
134 print "Installing locale: " + loc
136 print "Result: Installed"
138 print "Result: ERROR!!"
141 def checkEULA(partner
, loc
, minDir
, extName
):
142 # Checks for the existance of the EULA pref and writes out its pre-install
143 # value. Minotuar will pick this up and report the initial value in its diff.
145 installDir
= getInstallLocation(partner
, loc
, False)
146 args
= "sh " + minDir
+ "/grabEULA.sh -f " + installDir
+ " -m " + minDir
+ " -p " + extName
147 print "EULA args: " + args
148 proc
= subprocess
.Popen(args
, stdout
=subprocess
.PIPE
, shell
=True)
152 def doMinotaur(partner
, loc
, minDir
, vFiles
, ausparam
, version
):
153 # If vFiles exist, then run full comparison run comparing against those files
154 # otherwise, create those files put the created files into partner/locale
155 # directories within the minotaur area
157 installDir
= getInstallLocation(partner
, loc
, False)
158 args
= "sh minotaur.sh -n " + partner
+ " -m " + minDir
+ " -f " + installDir
159 args
+= " -l " + loc
+ " -v " + version
160 debug("Minotaur args: " + args
)
162 # Then we do a full run, with comparisons
163 writeReleaseChannel(vFiles
, loc
, ausparam
)
164 outputFile
= vFiles
+ "/" + loc
+ "/" + "test-output.xml"
165 bkmkFile
= vFiles
+ "/" + loc
+ "/" + "test-bookmarks.html"
166 releaseFile
= vFiles
+ "/" + loc
+ "/" + "release-channel.txt"
167 args
+= " -o " + outputFile
+ " -b " + bkmkFile
+ " -c " + releaseFile
168 proc
= subprocess
.Popen(args
, shell
=True)
171 # Then we generate files for future reference
172 proc
= subprocess
.Popen(args
, shell
=True)
176 def doUninstall(branch
, partner
, loc
):
177 # Uninstalls the build installed to <os>/minotuar-builds/partner/locale
179 installDir
= getInstallLocation(partner
, loc
, True)
180 debug("Calling uninstall")
181 uninstaller
= MozUninstaller(dest
= installDir
, branch
= branch
,
182 productName
= "firefox")
185 def writeReleaseChannel(vFiles
, loc
, aus
):
186 filepath
= vFiles
+ "/" + loc
+ "/release-channel.txt"
187 file = open(filepath
, "w")
190 def main(branch
, version
, url
, partner
, vFiles
, minDir
, extName
, creds
, aus
,
192 # First we craft the URL, assuming that the next directory down is the OS so
194 plat
= getPlatformDirName()
195 url
+= "/" + getPlatformDirName()
197 fxname
= getPlatformFirefoxName(version
)
200 l10nList
= open(l10nFile
, "r")
202 print "Unable to find L10N File!"
206 # Attempt to download every locale.
207 debug("BEGINNING DOWNLOAD")
208 found
= doDownload(partner
, loc
, url
+ "/" + loc
+ "/" + fxname
, minDir
, creds
)
211 debug("BEGINNING INSTALL")
212 isInstalled
= doInstall(branch
, partner
, loc
)
214 debug("CHECKING EULA")
215 checkEULA(partner
, loc
, minDir
, extName
)
216 debug("RUNNING MINOTAUR")
217 doMinotaur(partner
, loc
, minDir
, vFiles
, aus
, version
)
218 debug("RUNNING UNINSTALL")
219 doUninstall(branch
, partner
, loc
)
221 if __name__
== "__main__":
222 parser
= OptionParser()
223 parser
.add_option("-p", "--Partner", dest
="partner", help="Partner Name",
224 metavar
="PARTNER_NAME")
225 parser
.add_option("-b", "--Branch", dest
="branch",
226 help="Gecko Branch: 1.8.0|1.8.1|1.9", metavar
="BRANCH")
227 parser
.add_option("-v", "--Version ", dest
="version",
228 help="version of firefox to be tested",
229 metavar
="FIREFOX_VERSION")
230 parser
.add_option("-u", "--UrlToBuild", dest
="url",
231 help="URL to top level build location, above the OS directories",
233 parser
.add_option("-f", "--VerificationFileLocation", dest
="verificationFiles",
234 help="location of verification files, leave blank to create verification files",
236 parser
.add_option("-m", "--MinotaurDirectory", dest
="minDir",
237 help="Directory of the Minotuar code",
238 metavar
="MINOTAUR_DIR")
239 parser
.add_option("-e", "--ExtensionName", dest
="extName",
240 help="Name of the partner extension. Only needed if Partner has EULA",
242 parser
.add_option("-c", "--Credentials", dest
="creds",
243 help="Credentials to download the build in this form: <user>:<password>",
244 metavar
="CREDENTIALS")
245 parser
.add_option("-a", "--AusParameter", dest
="aus",
246 help="The AUS parameter for the AUS URI (-cck param)",
248 # Can't wrap the next line or else it looks wierd in parser.print_help() output
249 parser
.add_option("-l", "--L10NFile", dest
="l10nFile", help="A text file containing the language codes for this build, separated by LF",
251 (options
, args
) = parser
.parse_args()
253 # Print Help if no args passed
254 if not options
.branch
or not options
.version
or not options
.url
or \
255 not options
.l10nFile
or not options
.partner
or not options
.minDir
:
256 print "Required Items Not Specified. Must specify partner name, minotaur dir,",
257 print "locale file, branch, url, and version"
262 main(options
.branch
, options
.version
, options
.url
, options
.partner
,
263 options
.verificationFiles
, options
.minDir
, options
.extName
,
264 options
.creds
, options
.aus
, options
.l10nFile
)