Make build-bisect script work on win.
Unzip using python rather than using the unzip command which might not be available on windows. TEST=NONE BUG=NONE Review URL: http://codereview.chromium.org/1549006 git-svn-id: http://src.chromium.org/svn/trunk/src/build@43160 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
5a96799c46
Коммит
6807184542
|
@ -13,7 +13,7 @@ it will ask you whether it is good or bad before continuing the search.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Base URL to download snapshots from.
|
# Base URL to download snapshots from.
|
||||||
BUILD_BASE_URL = "http://build.chromium.org/buildbot/snapshots/"
|
BUILD_BASE_URL = 'http://build.chromium.org/buildbot/snapshots/'
|
||||||
|
|
||||||
# The type (platform) of the build archive. This is what's passed in to the
|
# The type (platform) of the build archive. This is what's passed in to the
|
||||||
# '-a/--archive' option.
|
# '-a/--archive' option.
|
||||||
|
@ -23,7 +23,7 @@ BUILD_ARCHIVE_TYPE = ''
|
||||||
BUILD_ARCHIVE_DIR = ''
|
BUILD_ARCHIVE_DIR = ''
|
||||||
|
|
||||||
# The location of the builds.
|
# The location of the builds.
|
||||||
BUILD_ARCHIVE_URL = "/%d/"
|
BUILD_ARCHIVE_URL = '/%d/'
|
||||||
|
|
||||||
# Name of the build archive.
|
# Name of the build archive.
|
||||||
BUILD_ZIP_NAME = ''
|
BUILD_ZIP_NAME = ''
|
||||||
|
@ -35,11 +35,11 @@ BUILD_DIR_NAME = ''
|
||||||
BUILD_EXE_NAME = ''
|
BUILD_EXE_NAME = ''
|
||||||
|
|
||||||
# URL to the ViewVC commit page.
|
# URL to the ViewVC commit page.
|
||||||
BUILD_VIEWVC_URL = "http://src.chromium.org/viewvc/chrome?view=rev&revision=%d"
|
BUILD_VIEWVC_URL = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%d'
|
||||||
|
|
||||||
# Changelogs URL
|
# Changelogs URL
|
||||||
CHANGELOG_URL = "http://build.chromium.org/buildbot/" \
|
CHANGELOG_URL = 'http://build.chromium.org/buildbot/' \
|
||||||
"perf/dashboard/ui/changelog.html?url=/trunk/src&range=%d:%d"
|
'perf/dashboard/ui/changelog.html?url=/trunk/src&range=%d:%d'
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -52,6 +52,38 @@ import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import urllib
|
import urllib
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
|
||||||
|
def UnzipFilenameToDir(filename, dir):
|
||||||
|
"""Unzip |filename| to directory |dir|."""
|
||||||
|
zf = zipfile.ZipFile(filename)
|
||||||
|
# Make base.
|
||||||
|
pushd = os.getcwd()
|
||||||
|
try:
|
||||||
|
if not os.path.isdir(dir):
|
||||||
|
os.mkdir(dir)
|
||||||
|
os.chdir(dir)
|
||||||
|
# Extract files.
|
||||||
|
for info in zf.infolist():
|
||||||
|
name = info.filename
|
||||||
|
if name.endswith('/'): # dir
|
||||||
|
if not os.path.isdir(name):
|
||||||
|
os.makedirs(name)
|
||||||
|
else: # file
|
||||||
|
dir = os.path.dirname(name)
|
||||||
|
if not os.path.isdir(dir):
|
||||||
|
os.makedirs(dir)
|
||||||
|
out = open(name, 'wb')
|
||||||
|
out.write(zf.read(name))
|
||||||
|
out.close()
|
||||||
|
# Set permissions. Permission info in external_attr is shifted 16 bits.
|
||||||
|
os.chmod(name, info.external_attr >> 16L)
|
||||||
|
os.chdir(pushd)
|
||||||
|
except Exception, e:
|
||||||
|
print >>sys.stderr, e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def SetArchiveVars(archive):
|
def SetArchiveVars(archive):
|
||||||
"""Set a bunch of global variables appropriate for the specified archive."""
|
"""Set a bunch of global variables appropriate for the specified archive."""
|
||||||
|
@ -68,15 +100,15 @@ def SetArchiveVars(archive):
|
||||||
if BUILD_ARCHIVE_TYPE in ('linux', 'linux-64'):
|
if BUILD_ARCHIVE_TYPE in ('linux', 'linux-64'):
|
||||||
BUILD_ZIP_NAME = 'chrome-linux.zip'
|
BUILD_ZIP_NAME = 'chrome-linux.zip'
|
||||||
BUILD_DIR_NAME = 'chrome-linux'
|
BUILD_DIR_NAME = 'chrome-linux'
|
||||||
BUILD_EXE_NAME = "chrome"
|
BUILD_EXE_NAME = 'chrome'
|
||||||
elif BUILD_ARCHIVE_TYPE in ('mac'):
|
elif BUILD_ARCHIVE_TYPE in ('mac'):
|
||||||
BUILD_ZIP_NAME = 'chrome-mac.zip'
|
BUILD_ZIP_NAME = 'chrome-mac.zip'
|
||||||
BUILD_DIR_NAME = 'chrome-mac'
|
BUILD_DIR_NAME = 'chrome-mac'
|
||||||
BUILD_EXE_NAME = "Chromium.app/Contents/MacOS/Chromium"
|
BUILD_EXE_NAME = 'Chromium.app/Contents/MacOS/Chromium'
|
||||||
elif BUILD_ARCHIVE_TYPE in ('xp'):
|
elif BUILD_ARCHIVE_TYPE in ('xp'):
|
||||||
BUILD_ZIP_NAME = 'chrome-win32.zip'
|
BUILD_ZIP_NAME = 'chrome-win32.zip'
|
||||||
BUILD_DIR_NAME = 'chrome-win32'
|
BUILD_DIR_NAME = 'chrome-win32'
|
||||||
BUILD_EXE_NAME = "chrome.exe"
|
BUILD_EXE_NAME = 'chrome.exe'
|
||||||
|
|
||||||
BUILD_BASE_URL += BUILD_ARCHIVE_DIR
|
BUILD_BASE_URL += BUILD_ARCHIVE_DIR
|
||||||
|
|
||||||
|
@ -110,23 +142,20 @@ def TryRevision(rev, profile, args):
|
||||||
print 'Fetching ' + download_url
|
print 'Fetching ' + download_url
|
||||||
urllib.urlretrieve(download_url, BUILD_ZIP_NAME)
|
urllib.urlretrieve(download_url, BUILD_ZIP_NAME)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print("Could not retrieve the download. Sorry.")
|
print('Could not retrieve the download. Sorry.')
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# Unzip the file.
|
# Unzip the file.
|
||||||
print 'Unzipping ...'
|
print 'Unziping ...'
|
||||||
os.system("unzip -q %s" % BUILD_ZIP_NAME)
|
UnzipFilenameToDir(BUILD_ZIP_NAME, os.curdir)
|
||||||
|
|
||||||
# Tell the system to open the app.
|
# Tell the system to open the app.
|
||||||
args = ['--user-data-dir=%s' % profile] + args
|
args = ['--user-data-dir=%s' % profile] + args
|
||||||
flags = ' '.join(map(pipes.quote, args))
|
flags = ' '.join(map(pipes.quote, args))
|
||||||
print 'Running %s/%s/%s %s' % (os.getcwd(), BUILD_DIR_NAME, BUILD_EXE_NAME,
|
exe = os.path.join(os.getcwd(), BUILD_DIR_NAME, BUILD_EXE_NAME)
|
||||||
flags)
|
cmd = '%s %s' % (exe, flags)
|
||||||
if BUILD_ARCHIVE_TYPE in ('linux', 'linux-64', 'mac'):
|
print 'Running %s' % cmd
|
||||||
os.system("%s/%s %s" % (BUILD_DIR_NAME, BUILD_EXE_NAME, flags))
|
os.system(cmd)
|
||||||
elif BUILD_ARCHIVE_TYPE in ('xp'):
|
|
||||||
# TODO(mmoss) Does Windows need 'start' or something?
|
|
||||||
os.system("%s/%s %s" % (BUILD_DIR_NAME, BUILD_EXE_NAME, flags))
|
|
||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
print 'Cleaning temp dir ...'
|
print 'Cleaning temp dir ...'
|
||||||
|
@ -140,9 +169,9 @@ def AskIsGoodBuild(rev):
|
||||||
"""Ask the user whether build |rev| is good or bad."""
|
"""Ask the user whether build |rev| is good or bad."""
|
||||||
# Loop until we get a response that we can parse.
|
# Loop until we get a response that we can parse.
|
||||||
while True:
|
while True:
|
||||||
response = raw_input("\nBuild %d is [(g)ood/(b)ad]: " % int(rev))
|
response = raw_input('\nBuild %d is [(g)ood/(b)ad]: ' % int(rev))
|
||||||
if response and response in ("g", "b"):
|
if response and response in ('g', 'b'):
|
||||||
return response == "g"
|
return response == 'g'
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = ('%prog [options] [-- chromium-options]\n'
|
usage = ('%prog [options] [-- chromium-options]\n'
|
||||||
|
@ -182,17 +211,17 @@ def main():
|
||||||
bad_rev = 0
|
bad_rev = 0
|
||||||
try:
|
try:
|
||||||
# Location of the latest build revision number
|
# Location of the latest build revision number
|
||||||
BUILD_LATEST_URL = "%s/LATEST" % (BUILD_BASE_URL)
|
BUILD_LATEST_URL = '%s/LATEST' % (BUILD_BASE_URL)
|
||||||
nh = urllib.urlopen(BUILD_LATEST_URL)
|
nh = urllib.urlopen(BUILD_LATEST_URL)
|
||||||
latest = int(nh.read())
|
latest = int(nh.read())
|
||||||
nh.close()
|
nh.close()
|
||||||
bad_rev = raw_input("Bad revision [HEAD:%d]: " % latest)
|
bad_rev = raw_input('Bad revision [HEAD:%d]: ' % latest)
|
||||||
if (bad_rev == ""):
|
if (bad_rev == ''):
|
||||||
bad_rev = latest
|
bad_rev = latest
|
||||||
bad_rev = int(bad_rev)
|
bad_rev = int(bad_rev)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print("Could not determine latest revision. This could be bad...")
|
print('Could not determine latest revision. This could be bad...')
|
||||||
bad_rev = int(raw_input("Bad revision: "))
|
bad_rev = int(raw_input('Bad revision: '))
|
||||||
|
|
||||||
# Find out when we were good.
|
# Find out when we were good.
|
||||||
if opts.good:
|
if opts.good:
|
||||||
|
@ -200,14 +229,14 @@ def main():
|
||||||
else:
|
else:
|
||||||
good_rev = 0
|
good_rev = 0
|
||||||
try:
|
try:
|
||||||
good_rev = int(raw_input("Last known good [0]: "))
|
good_rev = int(raw_input('Last known good [0]: '))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Get a list of revisions to bisect across.
|
# Get a list of revisions to bisect across.
|
||||||
revlist = GetRevList(good_rev, bad_rev)
|
revlist = GetRevList(good_rev, bad_rev)
|
||||||
if len(revlist) < 2: # Don't have enough builds to bisect
|
if len(revlist) < 2: # Don't have enough builds to bisect
|
||||||
print "We don't have enough builds to bisect. revlist: %s" % revlist
|
print 'We don\'t have enough builds to bisect. revlist: %s' % revlist
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# If we don't have a |good_rev|, set it to be the first revision possible.
|
# If we don't have a |good_rev|, set it to be the first revision possible.
|
||||||
|
@ -224,10 +253,10 @@ def main():
|
||||||
candidates = revlist[good:bad]
|
candidates = revlist[good:bad]
|
||||||
num_poss = len(candidates)
|
num_poss = len(candidates)
|
||||||
if num_poss > 10:
|
if num_poss > 10:
|
||||||
print("%d candidates. %d tries left." %
|
print('%d candidates. %d tries left.' %
|
||||||
(num_poss, round(math.log(num_poss, 2))))
|
(num_poss, round(math.log(num_poss, 2))))
|
||||||
else:
|
else:
|
||||||
print("Candidates: %s" % revlist[good:bad])
|
print('Candidates: %s' % revlist[good:bad])
|
||||||
|
|
||||||
# Cut the problem in half...
|
# Cut the problem in half...
|
||||||
test = int((bad - good) / 2) + good
|
test = int((bad - good) / 2) + good
|
||||||
|
@ -245,10 +274,10 @@ def main():
|
||||||
bad = test
|
bad = test
|
||||||
|
|
||||||
# We're done. Let the user know the results in an official manner.
|
# We're done. Let the user know the results in an official manner.
|
||||||
print("You are probably looking for build %d." % revlist[bad])
|
print('You are probably looking for build %d.' % revlist[bad])
|
||||||
print("CHANGELOG URL:")
|
print('CHANGELOG URL:')
|
||||||
print(CHANGELOG_URL % (last_known_good_rev, revlist[bad]))
|
print(CHANGELOG_URL % (last_known_good_rev, revlist[bad]))
|
||||||
print("Built at revision:")
|
print('Built at revision:')
|
||||||
print(BUILD_VIEWVC_URL % revlist[bad])
|
print(BUILD_VIEWVC_URL % revlist[bad])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Загрузка…
Ссылка в новой задаче