chiark / gitweb /
Merge branch 'java-home-lookup' into 'master'
authorHans-Christoph Steiner <hans@guardianproject.info>
Tue, 9 Aug 2016 15:44:06 +0000 (15:44 +0000)
committerHans-Christoph Steiner <hans@guardianproject.info>
Tue, 9 Aug 2016 15:44:06 +0000 (15:44 +0000)
Fix JDK lookup

Fix two cases when JDK path lookup could fail (found those issues on my Fedora 24 box).

See merge request !153

12 files changed:
.travis.yml
buildserver/config.buildserver.py
buildserver/provision-android-ndk
buildserver/provision-android-sdk
docs/fdroid.texi
examples/config.py
fdroidserver/build.py
fdroidserver/common.py
fdroidserver/init.py
fdroidserver/metadata.py
fdroidserver/update.py
makebuildserver

index e7b004c0a4945c2cd51f9eae58be69afaf0a795f..45a8049931b5280c9075dcf8f6e2b4ddfa01fae0 100644 (file)
@@ -28,7 +28,7 @@ install:
       sudo pip3 install pep8 pyflakes pylint;
       sudo pip3 install -e  .;
       sudo rm -rf fdroidserver.egg-info;
-      echo y | android --verbose update sdk --no-ui --all --filter platform-tools,build-tools-24.0.0;
+      echo y | android --verbose update sdk --no-ui --all --filter platform-tools,build-tools-24.0.1;
       elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
       sudo add-apt-repository ppa:guardianproject/fdroidserver -y;
       sudo apt-get -q update -y;
index 50976dbe9ba8302061593451c6e3b312072e9b69..57ae0b2b6e5e8a52ea56d48d64fcc4f26823ce29 100644 (file)
@@ -2,6 +2,7 @@ sdk_path = "/home/vagrant/android-sdk"
 ndk_paths = {
     'r9b': "/home/vagrant/android-ndk/r9b",
     'r10e': "/home/vagrant/android-ndk/r10e",
+    'r12b': "/home/vagrant/android-ndk/r12b",
 }
 java_paths = {
     '8': "/usr/lib/jvm/java-8-openjdk-i386",
index 36aa1a5c9e03f724bacd9bb0e8ef6ebe31e08339..ce1a8683bc8f46039cc34f5007e822639d12c6ee 100644 (file)
@@ -20,5 +20,10 @@ if [ ! -e $NDK_BASE/r10e ]; then
     mv android-ndk-r10e r10e
 fi
 
+if [ ! -e $NDK_BASE/r12b ]; then
+    unzip /vagrant/cache/android-ndk-r12b-linux-x86_64.zip > /dev/null
+    mv android-ndk-r12b r12b
+fi
+
 chmod -R a+rX $NDK_BASE/
 find $NDK_BASE/ -type f -executable -print0 | xargs -0 chmod a+x
index 31bb95b2f873c5c798386a803876476de6bacee3..57eacdc46ca4f73c2bace349691450eb3ebc6539 100644 (file)
@@ -41,6 +41,10 @@ done
 # install all cached build-tools
 for f in `ls -1 build-tools*.zip`; do
     ver=`unzip -c $f "*/source.properties" | sed -n 's,^Pkg.Revision=,,p'`
+    if [[ $ver == 24.0.0 ]] && [[ $f =~ .*r24\.0\.1.* ]]; then
+        # 24.0.1 has the wrong revision in the zip
+        ver=24.0.1
+    fi
     cached=,build-tools-${ver}${cached}
 done
 
index e61d0994caba66dba7591383c3e89bb1c081231b..d84c59a5b620697a81d001d689379b2ed91a464d 100644 (file)
@@ -1125,9 +1125,9 @@ Version of the NDK to use in this build. Defaults to the latest NDK release
 that included legacy toolchains, so as to not break builds that require
 toolchains no longer included in current versions of the NDK.
 
-The buildserver supports r9b with its legacy toolchains and the latest release
-as of writing this document, r10e. You may add support for more versions by
-adding them to 'ndk_paths' in your config file.
+The buildserver supports r9b with its legacy toolchains, r10e and the
+latest release as of writing this document, r12b. You may add support
+for more versions by adding them to 'ndk_paths' in your config file.
 
 @item gradle=<flavour1>[,<flavour2>,...]
 Build with Gradle instead of Ant, specifying what flavours to use. Flavours
index 97628e7e0ad8f97d394c75ac1dae9262d667716b..464528db682ed42a3c2c68cc6ea89c3687897b83 100644 (file)
@@ -12,7 +12,8 @@
 # not installed.
 # ndk_paths = {
 #     'r9b': None,
-#     'r10e': "$ANDROID_NDK",
+#     'r10e': None,
+#     'r12b': "$ANDROID_NDK",
 # }
 
 # java_paths = {
@@ -20,7 +21,7 @@
 # }
 
 # Build tools version to be used
-# build_tools = "24.0.0"
+# build_tools = "24.0.1"
 
 # Force all build to use the above version of build -tools, good for testing
 # builds without having all of the possible build-tools installed.
index 70ad1aee6a9460afcc023aeaa98009cddeb6f27a..d02947bdb5aaa4583bfc41ce9cec5c1dc10106ce 100644 (file)
@@ -460,7 +460,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
     ndk_path = build.ndk_path()
     if build.ndk or (build.buildjni and build.buildjni != ['no']):
         if not ndk_path:
-            logging.critical("Android NDK version '%s' could not be found!" % build.ndk or 'r10e')
+            logging.critical("Android NDK version '%s' could not be found!" % build.ndk or 'r12b')
             logging.critical("Configured versions:")
             for k, v in config['ndk_paths'].items():
                 if k.endswith("_orig"):
index a9a4b48773497ce25deb45e8ec841f654ed92365..593bab2da947abc1686dbea301066fc5a10c3754 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': "24.0.0",
+    'build_tools': "24.0.1",
     'force_build_tools': False,
     'java_paths': None,
     'ant': "ant",
index caa777346fbd29393fce069541d2eaa2f6993e78..f29b2d53891057e33bf117363c177092f677865f 100644 (file)
@@ -235,7 +235,7 @@ def main():
     logging.info('  Android SDK:\t\t\t' + config['sdk_path'])
     if aapt:
         logging.info('  Android SDK Build Tools:\t' + os.path.dirname(aapt))
-    logging.info('  Android NDK r10e (optional):\t$ANDROID_NDK')
+    logging.info('  Android NDK r12b (optional):\t$ANDROID_NDK')
     logging.info('  Keystore for signing key:\t' + keystore)
     if repo_keyalias is not None:
         logging.info('  Alias for key in store:\t' + repo_keyalias)
index 9ba9b1fdef17d8a1ecb0acb9c2a9c5dd418d80c6..f20b22303ef8291e2bb3db3df073001dc09be614 100644 (file)
@@ -348,7 +348,7 @@ class Build():
     def ndk_path(self):
         version = self.ndk
         if not version:
-            version = 'r10e'  # falls back to latest
+            version = 'r12b'  # falls back to latest
         paths = fdroidserver.common.config['ndk_paths']
         if version not in paths:
             return ''
index 9c7bcbadc2c8a2f9494a13717c653377ca9c3571..07c8db3024422f34522f108ae971a96fe16da715 100644 (file)
@@ -31,6 +31,8 @@ from datetime import datetime, timedelta
 from xml.dom.minidom import Document
 from argparse import ArgumentParser
 import time
+
+import collections
 from pyasn1.error import PyAsn1Error
 from pyasn1.codec.der import decoder, encoder
 from pyasn1_modules import rfc2315
@@ -44,12 +46,15 @@ from . import metadata
 from .common import FDroidPopen, FDroidPopenBytes, SdkToolsPopen
 from .metadata import MetaDataException
 
-METADATA_VERSION = 16
+METADATA_VERSION = 17
 
 screen_densities = ['640', '480', '320', '240', '160', '120']
 
 all_screen_densities = ['0'] + screen_densities
 
+UsesPermission = collections.namedtuple('UsesPermission', ['name', 'maxSdkVersion'])
+UsesPermissionSdk23 = collections.namedtuple('UsesPermissionSdk23', ['name', 'maxSdkVersion'])
+
 
 def dpi_to_px(density):
     return (int(density) * 48) / 160
@@ -530,7 +535,8 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False):
     icon_pat = re.compile(".*application-icon-([0-9]+):'([^']+?)'.*")
     icon_pat_nodpi = re.compile(".*icon='([^']+?)'.*")
     sdkversion_pat = re.compile(".*'([0-9]*)'.*")
-    string_pat = re.compile(".* name='([^']*)'.*")
+    permission_pat = re.compile(".*(name='(?P<name>.*?)')(.*maxSdkVersion='(?P<maxSdkVersion>.*?)')?.*")
+    feature_pat = re.compile(".*name='([^']*)'.*")
     for apkfile in glob.glob(os.path.join(repodir, '*.apk')):
 
         apkfilename = apkfile[len(repodir) + 1:]
@@ -558,7 +564,8 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False):
             if os.path.exists(os.path.join(repodir, srcfilename)):
                 apk['srcname'] = srcfilename
             apk['size'] = os.path.getsize(apkfile)
-            apk['permissions'] = set()
+            apk['uses-permission'] = set()
+            apk['uses-permission-sdk-23'] = set()
             apk['features'] = set()
             apk['icons_src'] = {}
             apk['icons'] = {}
@@ -626,20 +633,34 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False):
                     apk['nativecode'] = []
                     for arch in line[13:].split(' '):
                         apk['nativecode'].append(arch[1:-1])
-                elif line.startswith("uses-permission:"):
-                    perm = re.match(string_pat, line).group(1)
-                    if perm.startswith("android.permission."):
-                        perm = perm[19:]
-                    apk['permissions'].add(perm)
-                elif line.startswith("uses-feature:"):
-                    perm = re.match(string_pat, line).group(1)
+                elif line.startswith('uses-permission:'):
+                    perm_match = re.match(permission_pat, line).groupdict()
+
+                    permission = UsesPermission(
+                        perm_match['name'],
+                        perm_match['maxSdkVersion']
+                    )
+
+                    apk['uses-permission'].add(permission)
+                elif line.startswith('uses-permission-sdk-23:'):
+                    perm_match = re.match(permission_pat, line).groupdict()
+
+                    permission_sdk_23 = UsesPermissionSdk23(
+                        perm_match['name'],
+                        perm_match['maxSdkVersion']
+                    )
+
+                    apk['uses-permission-sdk-23'].add(permission_sdk_23)
+
+                elif line.startswith('uses-feature:'):
+                    feature = re.match(feature_pat, line).group(1)
                     # Filter out this, it's only added with the latest SDK tools and
                     # causes problems for lots of apps.
-                    if perm != "android.hardware.screen.portrait" \
-                            and perm != "android.hardware.screen.landscape":
-                        if perm.startswith("android.feature."):
-                            perm = perm[16:]
-                        apk['features'].add(perm)
+                    if feature != "android.hardware.screen.portrait" \
+                            and feature != "android.hardware.screen.landscape":
+                        if feature.startswith("android.feature."):
+                            feature = feature[16:]
+                        apk['features'].add(feature)
 
             if 'minSdkVersion' not in apk:
                 logging.warn("No SDK version information found in {0}".format(apkfile))
@@ -1048,7 +1069,28 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
             addElementNonEmpty('obbPatchFileSha256', apk.get('obbPatchFileSha256'), doc, apkel)
             if 'added' in apk:
                 addElement('added', time.strftime('%Y-%m-%d', apk['added']), doc, apkel)
-            addElementNonEmpty('permissions', ','.join(apk['permissions']), doc, apkel)
+
+            # TODO: remove old permission format
+            old_permissions = set()
+            for perm in apk['uses-permission']:
+                perm_name = perm.name
+                if perm_name.startswith("android.permission."):
+                    perm_name = perm_name[19:]
+                old_permissions.add(perm_name)
+            addElementNonEmpty('permissions', ','.join(old_permissions), doc, apkel)
+
+            for permission in apk['uses-permission']:
+                permel = doc.createElement('uses-permission')
+                permel.setAttribute('name', permission.name)
+                if permission.maxSdkVersion is not None:
+                    permel.setAttribute('maxSdkVersion', permission.maxSdkVersion)
+                    apkel.appendChild(permel)
+            for permission_sdk_23 in apk['uses-permission-sdk-23']:
+                permel = doc.createElement('uses-permission-sdk-23')
+                permel.setAttribute('name', permission_sdk_23.name)
+                if permission_sdk_23.maxSdkVersion is not None:
+                    permel.setAttribute('maxSdkVersion', permission_sdk_23.maxSdkVersion)
+                    apkel.appendChild(permel)
             if 'nativecode' in apk:
                 addElement('nativecode', ','.join(apk['nativecode']), doc, apkel)
             addElementNonEmpty('features', ','.join(apk['features']), doc, apkel)
index 6a4793f24164ae76971d467303d704c0ea851333..08be3829d45da67618622326efcb85f4227ccb1a 100755 (executable)
@@ -245,6 +245,8 @@ cachefiles = [
      '8956e9efeea95f49425ded8bb697013b66e162b064b0f66b5c75628f76e0f532'),
     ('https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64-legacy-toolchains.tar.bz2',
      'de93a394f7c8f3436db44568648f87738a8d09801a52f459dcad3fc047e045a1'),
+    ('https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip',
+     'eafae2d614e5475a3bcfd7c5f201db5b963cc1290ee3e8ae791ff0c66757781e'),
 ]