chiark / gitweb /
log versions of all installed Android SDK/NDK components
authorHans-Christoph Steiner <hans@eds.org>
Mon, 7 Nov 2016 10:39:33 +0000 (11:39 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 16 Nov 2016 22:28:03 +0000 (23:28 +0100)
Any variation in the Android tools used to build an APK can cause the build
to be unreproducible.  To help troubleshoot these times, this posts the
installed versions of the Android SDK and NDK components to the lastbuild
log, for the long term record.

refs #148

fdroidserver/build.py

index ac9ae5529a831022bbfe6ecaf4a0dc523e0f9ab7..75539a285e6fa17865289bbf39ce1ba08397c694 100644 (file)
@@ -952,6 +952,40 @@ def trybuild(app, build, build_dir, output_dir, also_check_dir, srclib_dir, extl
     return True
 
 
+def get_android_tools_versions(sdk_path, ndk_path=None):
+    '''get a list of the versions of all installed Android SDK/NDK components'''
+
+    if sdk_path[-1] != '/':
+        sdk_path += '/'
+    components = []
+    if ndk_path:
+        ndk_release_txt = os.path.join(ndk_path, 'RELEASE.TXT')
+        if os.path.isfile(ndk_release_txt):
+            with open(ndk_release_txt, 'r') as fp:
+                components.append((os.path.basename(ndk_path), fp.read()[:-1]))
+
+    pattern = re.compile('^Pkg.Revision=(.+)', re.MULTILINE)
+    for root, dirs, files in os.walk(sdk_path):
+        if 'source.properties' in files:
+            source_properties = os.path.join(root, 'source.properties')
+            with open(source_properties, 'r') as fp:
+                m = pattern.search(fp.read())
+                if m:
+                    components.append((root[len(sdk_path):], m.group(1)))
+
+    return components
+
+
+def get_android_tools_version_log(sdk_path, ndk_path):
+    '''get a list of the versions of all installed Android SDK/NDK components'''
+    log = ''
+    components = get_android_tools_versions(sdk_path, ndk_path)
+    for name, version in sorted(components):
+        log += '* ' + name + ' (' + version + ')\n'
+
+    return log
+
+
 def parse_commandline():
     """Parse the command line. Returns options, parser."""
 
@@ -1099,6 +1133,8 @@ def main():
 
         for build in app.builds:
             wikilog = None
+            tools_version_log = '== Installed Android Tools ==\n\n'
+            tools_version_log += get_android_tools_version_log(config['sdk_path'], build.ndk_path())
             try:
 
                 # For the first build of a particular app, we need to set up
@@ -1164,6 +1200,9 @@ def main():
                 failed_apps[appid] = e
                 wikilog = str(e)
 
+            if wikilog:
+                wikilog = tools_version_log + '\n\n' + wikilog
+
             if options.wiki and wikilog:
                 try:
                     # Write a page with the last build log for this version code