diff options
author | 2010-11-18 11:04:54 +0100 | |
---|---|---|
committer | 2010-11-18 11:04:54 +0100 | |
commit | 3e14688ce3abca5ee9445e35336e5f42603520ad (patch) | |
tree | 666e19cebf0df41c5e24692a69ac18e456237499 | |
parent | Initial commit (v8-create-tarball). (diff) | |
download | chromium-tools-3e14688ce3abca5ee9445e35336e5f42603520ad.tar.gz chromium-tools-3e14688ce3abca5ee9445e35336e5f42603520ad.tar.bz2 chromium-tools-3e14688ce3abca5ee9445e35336e5f42603520ad.zip |
Add chromium-depot-tool.
-rwxr-xr-x | chromium-depot-tool | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/chromium-depot-tool b/chromium-depot-tool new file mode 100755 index 0000000..7974529 --- /dev/null +++ b/chromium-depot-tool @@ -0,0 +1,93 @@ +#!/usr/bin/python2 +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +"""Transparent wrapper for chromium depot_tools.""" + +import httplib +import os.path +import pysvn +import re +import sys + +sys.path.insert(0, "/usr/lib/portage/pym") +import portage.output + +DAV_QUERY = '<propfind xmlns="DAV:"><allprop/></propfind>' + +CHECKOUT_DIR = os.path.expanduser('~/.chromium-depot-tools') +CHECKOUT_URL = 'http://src.chromium.org/svn/trunk/tools/depot_tools' + +eoutput = portage.output.EOutput() + +if not os.path.exists(CHECKOUT_DIR): + os.makedirs(CHECKOUT_DIR) + +svn_client = pysvn.Client() + +def IsCheckoutUpToDate(current_revision): + """ + Performs a quick version check. + + Returns true if the local depot_tools checkout is up to date. + """ + try: + conn = httplib.HTTPConnection('src.chromium.org') + conn.putrequest('PROPFIND', '/svn/!svn/vcc/default') + conn.endheaders() + conn.send(DAV_QUERY) + + response = conn.getresponse() + if response.status != 207: + eoutput.ewarn('Fast update check failed.') + return False + data = response.read() + match = re.match('.*/svn/!svn/bln/(\d+).*', data, re.DOTALL) + rev = match.group(1) + + conn = httplib.HTTPConnection('src.chromium.org') + conn.putrequest('PROPFIND', '/svn/!svn/bc/%s/trunk/tools/depot_tools' % rev) + conn.putheader('Depth', '0') + conn.endheaders() + conn.send(DAV_QUERY) + + response = conn.getresponse() + if response.status != 207: + eoutput.ewarn('Fast update check failed.') + return False + data = response.read() + match = re.match('.*/svn/!svn/ver/(\d+).*', data, re.DOTALL) + rev = int(match.group(1)) + + return rev == current_revision + except: + eoutput.ewarn('Fast update check failed.') + return False + +try: + entry = svn_client.info(CHECKOUT_DIR) +except pysvn.ClientError: + eoutput.einfo('Checking out depot_tools...') + svn_client.checkout(CHECKOUT_URL, CHECKOUT_DIR) +else: + if not IsCheckoutUpToDate(entry.commit_revision.number): + eoutput.einfo('Updating depot_tools...') + svn_client.cleanup(CHECKOUT_DIR) + svn_client.update(CHECKOUT_DIR) + +tools = { + 'drover': 'drover.py', + 'gcl': 'gcl.py', + 'gclient': 'gclient.py', +} + +argv = sys.argv[:] +if argv[0] in tools: + tool = argv[0] + argv = argv[1:] +elif len(sys.argv) >= 1: + tool = argv[1] + argv = argv[2:] + +os.execvp('python2', + ['python2', os.path.join(CHECKOUT_DIR, tools[tool])] + argv) |