chiark / gitweb /
Add srclib proj.prop lines if not already there
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 17 Nov 2013 22:20:58 +0000 (23:20 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Sun, 17 Nov 2013 22:23:25 +0000 (23:23 +0100)
fdroidserver/common.py

index 6f5e596797c7ab7aa7fc6e641b7eee2c9ccdab24..e085be292872f5dbef89e30f7fb851ee1d2a9d18 100644 (file)
@@ -1650,7 +1650,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
                 name, subdir = name.split('/',1)
             libpath = getsrclib(name+'@'+ref, srclib_dir, srclibpaths, subdir, preponly=onserver)
             srclibpaths.append((name, number, libpath))
-            place_srclib(root_dir, number, libpath)
+            place_srclib(root_dir, int(number), libpath)
                 
     basesrclib = vcs.getsrclib()
     # If one was used for the main source, add that too.
@@ -2018,8 +2018,19 @@ def place_srclib(root_dir, number, libpath):
     if not number:
         return
     relpath = os.path.relpath(libpath, root_dir)
-    if subprocess.call(['sed','-i',
-            's@\(android\.library\.reference\.'
-            +str(number)+'\)=.*@\\1='+relpath+'@',
-            'project.properties'], cwd=root_dir) != 0:
-        raise BuildException("Failed to place srclibs in project.properties")
+    proppath = os.path.join(root_dir, 'project.properties')
+
+    with open(proppath, "r") as o:
+        lines = o.readlines()
+
+    with open(proppath, "w") as o:
+        placed = False
+        for line in lines:
+            if line.startswith('android.library.reference.%d=' % number):
+                o.write('android.library.reference.%d=%s\n' % (number,relpath))
+                placed = True
+            else:
+                o.write(line)
+        if not placed:
+            o.write('android.library.reference.%d=%s\n' % (number,relpath))
+