chiark / gitweb /
Glob scanignore and scandelete
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 15 Apr 2014 21:53:44 +0000 (23:53 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 15 Apr 2014 21:53:44 +0000 (23:53 +0200)
These fields can still be used without globbing, but globbing can be very
useful in some cases.

fdroidserver/common.py

index 8d3ce290dc3a6f9a447359a7a4ab27ffbb6d04a6..47444e42e3d573f6e6964a69920cc27a5b5f0e71 100644 (file)
@@ -19,6 +19,7 @@
 
 import os, sys, re
 import shutil
+import glob
 import stat
 import subprocess
 import time
@@ -1173,6 +1174,18 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
 
     return (root_dir, srclibpaths)
 
+# Split and extend via globbing the paths from a field
+def getpaths(build_dir, build, field):
+    paths = []
+    if field not in build:
+        return paths
+    for p in build[field]:
+        p = p.strip()
+        full_path = os.path.join(build_dir, p)
+        full_path = os.path.normpath(full_path)
+        paths += [r[len(build_dir):] for r in glob.glob(full_path)]
+    return paths
+
 # Scan the source code in the given directory (and all subdirectories)
 # and return the number of fatal problems encountered
 def scan_source(build_dir, root_dir, thisbuild):
@@ -1197,24 +1210,8 @@ def scan_source(build_dir, root_dir, thisbuild):
             re.compile(r'ouya.*sdk', re.IGNORECASE),
             ]
 
-    def getpaths(field):
-        paths = []
-        if field not in thisbuild:
-            return paths
-        for p in thisbuild[field]:
-            p = p.strip()
-            if p == '.':
-                p = '/'
-            elif p.startswith('./'):
-                p = p[1:]
-            elif not p.startswith('/'):
-                p = '/' + p;
-            if p not in paths:
-                paths.append(p)
-        return paths
-
-    scanignore = getpaths('scanignore')
-    scandelete = getpaths('scandelete')
+    scanignore = getpaths(build_dir, thisbuild, 'scanignore')
+    scandelete = getpaths(build_dir, thisbuild, 'scandelete')
 
     try:
         ms = magic.open(magic.MIME_TYPE)