chiark / gitweb /
More import tool improvements
authorCiaran Gultnieks <ciaran@ciarang.com>
Sat, 11 Feb 2012 15:27:09 +0000 (15:27 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Sat, 11 Feb 2012 15:27:09 +0000 (15:27 +0000)
checkupdates.py
common.py
import.py

index 6eb890c5cef71bef8cf44f33bdea04266bc3ce5f..2c083044dd7a0888c48bb74570aefab61ee02fb9 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# checkmarket2.py - part of the FDroid server tools
+# checkupdates.py - part of the FDroid server tools
 # Copyright (C) 2010-12, Ciaran Gultnieks, ciaran@ciarang.com
 #
 # This program is free software: you can redistribute it and/or modify
index d007ef476a530b7b6933d1c2adfea426e7d3138e..b020df0a649b1a450b414d1a4761f94de2238826 100644 (file)
--- a/common.py
+++ b/common.py
@@ -517,7 +517,16 @@ def write_metadata(dest, app):
     for build in app['builds']:
         writecomments('build:' + build['version'])
         mf.write('Build Version:')
-        mf.write('\\\n'.join(build['origlines']) + '\n')
+        if build.has_key('origlines'):
+            # Keeping the original formatting if we loaded it from a file...
+            mf.write('\\\n'.join(build['origlines']) + '\n')
+        else:
+            mf.write(build['version'] + ',' + build['vercode'] + ',' + 
+                    build['commit'])
+            for key,value in build.iteritems():
+                if key not in ['version', 'vercode', 'commit']:
+                    mf.write(',' + key + '=' + value)
+            mf.write('\n')
     if len(app['builds']) > 0:
         mf.write('\n')
     writefield('Update Check Mode')
index 98abb861e027972634518a71a6b068fe5a44d3d2..5f7b2a9496ce980faeeb7e73976ddf4f773e7762 100755 (executable)
--- a/import.py
+++ b/import.py
@@ -73,6 +73,7 @@ elif url.startswith('http://code.google.com/p/'):
         print 'Unable to find source at ' + sourcecode + ' - return code ' + str(req.getcode())
         sys.exit(1)
     page = req.read()
+    repotype = None
     index = page.find('hg clone')
     if index != -1:
         repotype = 'hg'
@@ -82,7 +83,17 @@ elif url.startswith('http://code.google.com/p/'):
             print "Error while getting repo address"
             sys.exit(1)
         repo = repo[:index]
-    else:
+    if not repotype:
+        index=page.find('git clone')
+        if index != -1:
+            repotype = 'git'
+            repo = page[index + 10:]
+            index = repo.find('<')
+            if index == -1:
+                print "Error while getting repo address"
+                sys.exit(1)
+            repo = repo[:index]
+    if not repotype:
         print "Unable to determine vcs type"
         sys.exit(1)
 
@@ -110,7 +121,7 @@ if not os.path.exists(manifest):
 
 # Extract some information...
 vcsearch = re.compile(r'.*android:versionCode="([^"]+)".*').search
-vnsearch = re.compile(r'.*android:versionName="([^"]+)".').search
+vnsearch = re.compile(r'.*android:versionName="([^"]+)".*').search
 psearch = re.compile(r'.*package="([^"]+)".*').search
 version = None
 vercode = None
@@ -141,7 +152,7 @@ if not vercode:
 # Make sure it's actually new...
 for app in apps:
     if app['id'] == package:
-        print "Package ' + package + ' already exists"
+        print "Package " + package + " already exists"
         sys.exit(1)
 
 # Construct the metadata...
@@ -151,6 +162,20 @@ app['Web Site'] = url
 app['Source Code'] = sourcecode
 app['Repo Type'] = repotype
 app['Repo'] = repo
+
+# Create a build line...
+build = {}
+build['version'] = version
+build['vercode'] = vercode
+build['commit'] = '?'
+if options.subdir:
+    build['subdir'] = options.subdir
+if os.path.exists(os.path.join(root_dir, 'jni')):
+    build['buildjni'] = 'yes'
+app['builds'].append(build)
+app['comments'].append(('build:' + version,
+    "#Generated by import.py - check this is the right version, and find the right commit!"))
+
 metafile = os.path.join('metadata', package + '.txt')
 common.write_metadata(metafile, app)
 print "Wrote " + metafile