b=450088 backing out (new reftest failed)
[wine-gecko.git] / testing / release / minotaur / partner.py
bloba6b4a27fabbf1bf7f97276145d87a210faf280cc
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
12 # License.
14 # The Original Code is Mozilla Corporation Code.
16 # The Initial Developer of the Original Code is
17 # Clint Talbert.
18 # Portions created by the Initial Developer are Copyright (C) 2007
19 # the Initial Developer. All Rights Reserved.
21 # Contributor(s):
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
39 import platform
40 import subprocess
41 import re
42 import sys
44 from mozDownload import MozDownloader
45 from mozInstall import MozInstaller, MozUninstaller
47 isDebug = True
49 def debug(s):
50 if isDebug:
51 print "DEBUG: ",
52 print s
54 generalerr = re.compile(".*error.*")
56 def getPlatformDirName():
57 os = platform.system()
58 if (os == "Darwin"):
59 return "mac"
60 elif (os == "Linux"):
61 return "linux-i686"
62 else:
63 return "win32"
65 def getPlatformFirefoxName(version):
66 os = platform.system()
67 if (os == "Darwin"):
68 return "Firefox%20" + version + ".dmg"
69 elif (os == "Linux"):
70 return "firefox-" + version + ".tar.gz"
71 else:
72 return "Firefox%20Setup%20" + version + ".exe"
74 def getDownloadLocation(partner, loc):
75 os = platform.system()
76 if (os == "Darwin"):
77 return "~/minotaur-download/" + partner + "/" + loc + "/firefoxInst.dmg"
78 elif (os == "Linux"):
79 return "~/minotaur-download/" + partner + "/" + loc + "/firefoxInst.tar.gz"
80 else:
81 return "c:/minotaur-download/" + partner + "/" + loc + "/firefoxInst.exe"
83 def getInstallLocation(partner, loc, isInst):
84 os = platform.system()
85 if (os == "Darwin"):
86 if isInst:
87 return "~/minotaur-build/" + partner + "/" + loc
88 else:
89 return "~/minotaur-build/" + partner + "/" + loc + "/Firefox.app/Contents/MacOS"
90 elif (os == "Linux"):
91 if isInst:
92 return "~/minotaur-build/" + partner + "/" + loc
93 else:
94 return "~/minotaur-build/" + partner + "/" + loc + "/firefox"
95 else:
96 return "c:/minotaur-build/" + partner + "/" + loc
98 def doDownload(partner, loc, url, minDir, creds):
99 result = True
100 dwnlddir = getDownloadLocation(partner, loc)
101 user = None
102 passwd = None
103 if creds:
104 user, passwd = creds.split(":")
106 mozDwnld = MozDownloader(url=url, dest=dwnlddir, user=user,
107 password=passwd)
108 mozDwnld.download()
110 print "Downloading locale: " + loc
111 if result:
112 print "Result: DOWNLOADED"
113 else:
114 print "Result: NOT FOUND"
115 print "==========================="
116 return result
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"
122 result = True
123 installdir = getInstallLocation(partner, loc, True)
124 dwnlddir = getDownloadLocation(partner, loc)
126 try:
127 installer = MozInstaller(src = dwnlddir, dest = installdir, branch = branch,
128 productName = "firefox")
129 except:
130 print "DEBUG: mozinstaller threw"
131 result = False
133 print "========================="
134 print "Installing locale: " + loc
135 if result:
136 print "Result: Installed"
137 else:
138 print "Result: ERROR!!"
139 return result
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.
144 if (extName):
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)
149 proc.wait()
150 print proc.stdout
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
156 result = True
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)
161 if vFiles:
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)
169 proc.wait()
170 else:
171 # Then we generate files for future reference
172 proc = subprocess.Popen(args, shell=True)
173 proc.wait()
174 return result
176 def doUninstall(branch, partner, loc):
177 # Uninstalls the build installed to <os>/minotuar-builds/partner/locale
178 result = True
179 installDir = getInstallLocation(partner, loc, True)
180 debug("Calling uninstall")
181 uninstaller = MozUninstaller(dest = installDir, branch = branch,
182 productName = "firefox")
183 return result
185 def writeReleaseChannel(vFiles, loc, aus):
186 filepath = vFiles + "/" + loc + "/release-channel.txt"
187 file = open(filepath, "w")
188 file.write(aus)
190 def main(branch, version, url, partner, vFiles, minDir, extName, creds, aus,
191 l10nFile):
192 # First we craft the URL, assuming that the next directory down is the OS so
193 # we append that.
194 plat = getPlatformDirName()
195 url += "/" + getPlatformDirName()
197 fxname = getPlatformFirefoxName(version)
199 try:
200 l10nList = open(l10nFile, "r")
201 except IOError:
202 print "Unable to find L10N File!"
204 for loc in l10nList:
205 loc = loc.strip()
206 # Attempt to download every locale.
207 debug("BEGINNING DOWNLOAD")
208 found = doDownload(partner, loc, url + "/" + loc + "/" + fxname, minDir, creds)
209 found = True
210 if found:
211 debug("BEGINNING INSTALL")
212 isInstalled = doInstall(branch, partner, loc)
213 if isInstalled:
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",
232 metavar="URL")
233 parser.add_option("-f", "--VerificationFileLocation", dest="verificationFiles",
234 help="location of verification files, leave blank to create verification files",
235 metavar="VER_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",
241 metavar="EXT_NAME")
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)",
247 metavar="AUS_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",
250 metavar="L10N_FILE")
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"
258 parser.print_help()
259 sys.exit(1)
261 # Call Main
262 main(options.branch, options.version, options.url, options.partner,
263 options.verificationFiles, options.minDir, options.extName,
264 options.creds, options.aus, options.l10nFile)