chiark / gitweb /
Revert "Don't allow values other than 'yes' or 'no' on boolean fields, integrity...
authorCiaran Gultnieks <ciaran@ciarang.com>
Sat, 9 Nov 2013 06:52:11 +0000 (06:52 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Sat, 9 Nov 2013 06:52:11 +0000 (06:52 +0000)
This reverts commit 04f74859490e5b3d374030c126ae1a3956a88f18. Breaks too
many things.

fdroidserver/build.py
fdroidserver/common.py

index b969cff4dbd6f3ca4ecb1bb9d5f328cae1b406be..6af132ed1c13f02e78728fafb8c96ebef3d47217 100644 (file)
@@ -347,22 +347,22 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
     # We need to clean via the build tool in case the binary dirs are
     # different from the default ones
     p = None
-    if thisbuild.get('maven', 'no') != 'no':
+    if 'maven' in thisbuild:
         print "Cleaning Maven project..."
         cmd = [config['mvn3'], 'clean', '-Dandroid.sdk.path=' + config['sdk_path']]
 
         if '@' in thisbuild['maven']:
-            maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@',1)[1])
+            maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@')[1])
         else:
             maven_dir = root_dir
 
         p = FDroidPopen(cmd, cwd=maven_dir)
-    elif thisbuild.get('gradle', 'no') != 'no':
+    elif 'gradle' in thisbuild:
         print "Cleaning Gradle project..."
         cmd = [config['gradle'], 'clean']
 
         if '@' in thisbuild['gradle']:
-            gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@',1)[1])
+            gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@')[1])
         else:
             gradle_dir = root_dir
 
@@ -454,11 +454,11 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
 
     p = None
     # Build the release...
-    if thisbuild.get('maven', 'no') != 'no':
+    if 'maven' in thisbuild:
         print "Building Maven project..."
 
         if '@' in thisbuild['maven']:
-            maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@',1)[1])
+            maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@')[1])
         else:
             maven_dir = root_dir
 
@@ -482,9 +482,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
 
         p = FDroidPopen(mvncmd, cwd=maven_dir)
 
-        bindir = os.path.join(root_dir, 'target')
-
-    elif thisbuild.get('gradle', 'no') != 'no':
+    elif 'gradle' in thisbuild:
         print "Building Gradle project..."
         if '@' in thisbuild['gradle']:
             flavour = thisbuild['gradle'].split('@')[0]
@@ -536,8 +534,6 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
             cmd += ['release']
         p = FDroidPopen(cmd, cwd=root_dir)
 
-        bindir = os.path.join(root_dir, 'bin')
-
     if p.returncode != 0:
         raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout, p.stderr)
     print "Successfully built version " + thisbuild['version'] + ' of ' + app['id']
@@ -548,8 +544,11 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
     # Find the apk name in the output...
     if 'bindir' in thisbuild:
         bindir = os.path.join(build_dir, thisbuild['bindir'])
-
-    if thisbuild.get('maven', 'no') != 'no':
+    elif 'maven' in thisbuild:
+        bindir = os.path.join(root_dir, 'target')
+    else:
+        bindir = os.path.join(root_dir, 'bin')
+    if 'maven' in thisbuild:
         stdout_apk = '\n'.join([
             line for line in p.stdout.splitlines() if any(a in line for a in ('.apk','.ap_'))])
         m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk",
@@ -564,7 +563,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
             raise BuildException('Failed to find output')
         src = m.group(1)
         src = os.path.join(bindir, src) + '.apk'
-    elif thisbuild.get('gradle', 'no') != 'no':
+    elif 'gradle' in thisbuild:
         dd = build_dir
         if 'subdir' in thisbuild:
             dd = os.path.join(dd, thisbuild['subdir'])
@@ -607,7 +606,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
             vercode = re.match(pat, line).group(1)
             pat = re.compile(".*versionName='([^']*)'.*")
             version = re.match(pat, line).group(1)
-    if thisbuild['novcheck']:
+    if thisbuild.get('novcheck', 'no') == "yes":
         vercode = thisbuild['vercode']
         version = thisbuild['version']
     if not version or not vercode:
index dbf7db6c26567cde0ae54a0e8344a21e2885b45d..6bc3b41ec89b54e66692aa299003557b5b67cbb0 100644 (file)
@@ -523,7 +523,6 @@ def parse_metadata(metafile):
         for p in parts[3:]:
             pk, pv = p.split('=', 1)
             thisbuild[pk.strip()] = pv
-
         return thisbuild
 
     def add_comments(key):
@@ -533,7 +532,6 @@ def parse_metadata(metafile):
             thisinfo['comments'].append((key, comment))
         del curcomments[:]
 
-
     thisinfo = {}
     if metafile:
         if not isinstance(metafile, file):
@@ -686,20 +684,6 @@ def parse_metadata(metafile):
                 mode = 0
     add_comments(None)
 
-    # These can only contain 'yes' or 'no'
-    for key in ('submodules', 'oldsdkloc', 'forceversion', 'forcevercode', 'fixtrans', 'fixapos', 'novcheck'):
-        for build in thisinfo['builds']:
-            if key not in build:
-                build[key] = False
-                continue
-            if build[key] == 'yes':
-                build[key] = True
-            elif build[key] == 'no':
-                build[key] = False
-            else:
-                raise MetaDataException("Invalid value %s assigned to boolean build flag %s"
-                        % (build[key], key))
-
     # Mode at end of file should always be 0...
     if mode == 1:
         raise MetaDataException(field + " not terminated in " + metafile.name)
@@ -1375,7 +1359,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
         raise BuildException('Missing subdir ' + root_dir)
 
     # Initialise submodules if requred...
-    if build['submodules']:
+    if build.get('submodules', 'no') == 'yes':
         if options.verbose:
             print "Initialising submodules..."
         vcs.initsubmodules()
@@ -1465,7 +1449,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
         props += '\n'
         # Fix old-fashioned 'sdk-location' by copying
         # from sdk.dir, if necessary...
-        if build['oldsdkloc']:
+        if build.get('oldsdkloc', 'no') == "yes":
             sdkloc = re.match(r".*^sdk.dir=(\S+)$.*", props,
                 re.S|re.M).group(1)
             props += "sdk-location=%s\n" % sdkloc
@@ -1483,7 +1467,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
         f.close()
 
     flavour = None
-    if build.get('gradle', 'no') != 'no':
+    if 'gradle' in build:
         flavour = build['gradle'].split('@')[0]
         if flavour in ['main', 'yes', '']:
             flavour = None
@@ -1498,7 +1482,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
             raise BuildException("Failed to remove debuggable flags")
 
     # Insert version code and number into the manifest if necessary...
-    if build['forceversion']:
+    if 'forceversion' in build:
         print "Changing the version name..."
         for path in manifest_paths(root_dir, flavour):
             if not os.path.isfile(path):
@@ -1513,7 +1497,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
                     's/versionName[ ]*=[ ]*"[^"]*"/versionName = "' + build['version'] + '"/g',
                     path]) != 0:
                     raise BuildException("Failed to amend build.gradle")
-    if build['forcevercode']:
+    if 'forcevercode' in build:
         print "Changing the version code..."
         for path in manifest_paths(root_dir, flavour):
             if not os.path.isfile(path):
@@ -1540,7 +1524,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
                 subprocess.call('rm -rf ' + dest, shell=True)
 
     # Fix apostrophes translation files if necessary...
-    if build['fixapos']:
+    if build.get('fixapos', 'no') == 'yes':
         for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
             for filename in files:
                 if filename.endswith('.xml'):
@@ -1551,7 +1535,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
                         raise BuildException("Failed to amend " + filename)
 
     # Fix translation files if necessary...
-    if build['fixtrans']:
+    if build.get('fixtrans', 'no') == 'yes':
         for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
             for filename in files:
                 if filename.endswith('.xml'):
@@ -1640,6 +1624,40 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
         if p.returncode != 0:
             raise BuildException("Error running prebuild command for %s:%s" %
                     (app['id'], build['version']), p.stdout, p.stderr)
+    print "Applying generic clean-ups..."
+
+    if build.get('anal-tics', 'no') == 'yes':
+        fp = os.path.join(root_dir, 'src', 'com', 'google', 'android', 'apps', 'analytics')
+        os.makedirs(fp)
+        with open(os.path.join(fp, 'GoogleAnalyticsTracker.java'), 'w') as f:
+            f.write("""
+            package com.google.android.apps.analytics;
+            public class GoogleAnalyticsTracker {
+                private static GoogleAnalyticsTracker instance;
+                private GoogleAnalyticsTracker() {
+                }
+                public static GoogleAnalyticsTracker getInstance() {
+                    if(instance == null)
+                        instance = new GoogleAnalyticsTracker();
+                    return instance;
+                }
+                public void start(String i,int think ,Object not) {
+                }
+                public void dispatch() {
+                }
+                public void stop() {
+                }
+                public void setProductVersion(String uh, String hu) {
+                }
+                public void trackEvent(String that,String just,String aint,int happening) {
+                }
+                public void trackPageView(String nope) {
+                }
+                public void setCustomVar(int mind,String your,String own,int business) {
+                }
+            }
+            """)
+
 
     return (root_dir, srclibpaths)