chiark / gitweb /
Some more work on the importer
authorCiaran Gultnieks <ciaran@ciarang.com>
Thu, 9 Feb 2012 09:06:51 +0000 (09:06 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Thu, 9 Feb 2012 09:06:51 +0000 (09:06 +0000)
common.py
import.py

index 4d873b09f82469af04e049bd18ebf14cbc4c76c3..2e115d1c69281c38480a725a78c27bd913eda6a7 100644 (file)
--- 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")
index eb4fe04cd5dbcb874d9c4572bda12cbfa72e84bf..98abb861e027972634518a71a6b068fe5a44d3d2 100755 (executable)
--- 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)