From 006cd46725a3d4baaeb90497ae312d0dab5e563e Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Thu, 9 Feb 2012 09:06:51 +0000 Subject: [PATCH] Some more work on the importer --- common.py | 1 + import.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/common.py b/common.py index 4d873b09..2e115d1c 100644 --- a/common.py +++ b/common.py @@ -685,6 +685,7 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j # the original behaviour... buildxml = os.path.join(root_dir, 'build.xml') if os.path.exists(buildxml): + print 'Force-removing old build.xml' os.remove(buildxml) if subprocess.call(parms, cwd=root_dir) != 0: raise BuildException("Failed to update project") diff --git a/import.py b/import.py index eb4fe04c..98abb861 100755 --- a/import.py +++ b/import.py @@ -22,6 +22,7 @@ import os import shutil import subprocess import re +import urllib from optparse import OptionParser #Read configuration... @@ -61,12 +62,36 @@ if url.startswith('https://github.com'): repo = url + '.git' repotype = 'git' sourcecode = url +elif url.startswith('http://code.google.com/p/'): + if not url.endswith('/'): + print "Expected format for googlecode url is http://code.google.com/p/PROJECT/" + sys.exit(1) + projecttype = 'googlecode' + sourcecode = url + 'source/checkout' + req = urllib.urlopen(sourcecode) + if req.getcode() != 200: + print 'Unable to find source at ' + sourcecode + ' - return code ' + str(req.getcode()) + sys.exit(1) + page = req.read() + index = page.find('hg clone') + if index != -1: + repotype = 'hg' + repo = page[index + 9:] + index = repo.find('<') + if index == -1: + print "Error while getting repo address" + sys.exit(1) + repo = repo[:index] + else: + print "Unable to determine vcs type" + sys.exit(1) if not projecttype: print "Unable to determine the project type." sys.exit(1) # Get a copy of the source so we can extract some info... +print 'Getting source from ' + repotype + ' repo at ' + repo src_dir = os.path.join(tmp_dir, 'importer') if os.path.exists(tmp_dir): shutil.rmtree(tmp_dir)