From: Hans-Christoph Steiner Date: Mon, 7 Nov 2016 10:39:33 +0000 (+0100) Subject: log versions of all installed Android SDK/NDK components X-Git-Tag: 0.8~145^2~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ad2b9b99c2a7084e1ef4df06d635c7b63bee89e3;p=fdroidserver.git log versions of all installed Android SDK/NDK components 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 --- diff --git a/fdroidserver/build.py b/fdroidserver/build.py index ac9ae552..75539a28 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -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