chiark / gitweb /
common: don't insert $ANDROID_NDK to local.props
[fdroidserver.git] / fdroidserver / common.py
index f27177fe1f4ad44d28a3add0f8d750c3c36398f6..9f7e6c1ba37572626cd1cda8796fd23c23955037 100644 (file)
@@ -56,9 +56,10 @@ default_config = {
     'sdk_path': "$ANDROID_HOME",
     'ndk_paths': {
         'r9b': None,
-        'r10e': "$ANDROID_NDK",
+        'r10e': None,
+        'r12b': "$ANDROID_NDK",
     },
-    'build_tools': "23.0.3",
+    'build_tools': "24.0.0",
     'force_build_tools': False,
     'java_paths': None,
     'ant': "ant",
@@ -1372,7 +1373,12 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
             props += "sdk.dir=%s\n" % config['sdk_path']
             props += "sdk-location=%s\n" % config['sdk_path']
         ndk_path = build.ndk_path()
-        if ndk_path:
+        # if it wasn't expanded correctly (because the NDK is not
+        # installed or $ANDROID_NDK not set properly), don't insert it.
+        # even if not actually used, Gradle will error with a cryptic
+        # message.
+        # https://gitlab.com/fdroid/fdroidserver/issues/171
+        if ndk_path and ndk_path[0] != '$':
             # Add ndk location
             props += "ndk.dir=%s\n" % ndk_path
             props += "ndk-location=%s\n" % ndk_path
@@ -1570,9 +1576,11 @@ class KnownApks:
 
     # Record an apk (if it's new, otherwise does nothing)
     # Returns the date it was added.
-    def recordapk(self, apk, app):
+    def recordapk(self, apk, app, default_date=None):
         if apk not in self.apks:
-            self.apks[apk] = (app, time.gmtime(time.time()))
+            if default_date is None:
+                default_date = time.gmtime(time.time())
+            self.apks[apk] = (app, default_date)
             self.changed = True
         _, added = self.apks[apk]
         return added
@@ -1794,7 +1802,8 @@ def set_FDroidPopen_env(build=None):
     set up the environment variables for the build environment
 
     There is only a weak standard, the variables used by gradle, so also set
-    up the most commonly used environment variables for SDK and NDK
+    up the most commonly used environment variables for SDK and NDK.  Also, if
+    there is no locale set, this will set the locale (e.g. LANG) to en_US.UTF-8.
     '''
     global env, orig_path
 
@@ -1806,6 +1815,15 @@ def set_FDroidPopen_env(build=None):
         for k, v in config['java_paths'].items():
             env['JAVA%s_HOME' % k] = v
 
+    missinglocale = True
+    for k, v in env.items():
+        if k == 'LANG' and v != 'C':
+            missinglocale = False
+        elif k == 'LC_ALL':
+            missinglocale = False
+    if missinglocale:
+        env['LANG'] = 'en_US.UTF-8'
+
     if build is not None:
         path = build.ndk_path()
         paths = orig_path.split(os.pathsep)