make get_android_tools_versions() search ndk_paths from config

This commit is contained in:
Hans-Christoph Steiner 2021-05-26 17:35:39 +02:00
parent 7a1d236c8d
commit 09fa49a7a3
No known key found for this signature in database
GPG key ID: 3E177817BA1B9BFA
3 changed files with 10 additions and 12 deletions

View file

@ -237,7 +237,7 @@ def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
try: try:
cmd_stdout = chan.makefile('rb', 1024) cmd_stdout = chan.makefile('rb', 1024)
output = bytes() output = bytes()
output += common.get_android_tools_version_log(build.ndk_path()).encode() output += common.get_android_tools_version_log().encode()
while not chan.exit_status_ready(): while not chan.exit_status_ready():
line = cmd_stdout.readline() line = cmd_stdout.readline()
if line: if line:
@ -402,7 +402,7 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
log_path = os.path.join(log_dir, log_path = os.path.join(log_dir,
common.get_toolsversion_logname(app, build)) common.get_toolsversion_logname(app, build))
with open(log_path, 'w') as f: with open(log_path, 'w') as f:
f.write(common.get_android_tools_version_log(build.ndk_path())) f.write(common.get_android_tools_version_log())
else: else:
if build.sudo: if build.sudo:
logging.warning('%s:%s runs this on the buildserver with sudo:\n\t%s\nThese commands were skipped because fdroid build is not running on a dedicated build server.' logging.warning('%s:%s runs this on the buildserver with sudo:\n\t%s\nThese commands were skipped because fdroid build is not running on a dedicated build server.'
@ -1088,7 +1088,7 @@ def main():
build_starttime = common.get_wiki_timestamp() build_starttime = common.get_wiki_timestamp()
tools_version_log = '' tools_version_log = ''
if not options.onserver: if not options.onserver:
tools_version_log = common.get_android_tools_version_log(build.ndk_path()) tools_version_log = common.get_android_tools_version_log()
common.write_running_status_json(status_output) common.write_running_status_json(status_output)
try: try:

View file

@ -3872,7 +3872,7 @@ def get_wiki_timestamp(timestamp=None):
return time.strftime("%Y-%m-%d %H:%M:%SZ", timestamp) return time.strftime("%Y-%m-%d %H:%M:%SZ", timestamp)
def get_android_tools_versions(ndk_path=None): def get_android_tools_versions():
'''get a list of the versions of all installed Android SDK/NDK components''' '''get a list of the versions of all installed Android SDK/NDK components'''
global config global config
@ -3880,11 +3880,9 @@ def get_android_tools_versions(ndk_path=None):
if sdk_path[-1] != '/': if sdk_path[-1] != '/':
sdk_path += '/' sdk_path += '/'
components = [] components = []
if ndk_path: for ndk_path in config.get('ndk_paths', []):
ndk_release_txt = os.path.join(ndk_path, 'RELEASE.TXT') version = get_ndk_version(ndk_path)
if os.path.isfile(ndk_release_txt): components.append((os.path.basename(ndk_path), str(version)))
with open(ndk_release_txt, 'r') as fp:
components.append((os.path.basename(ndk_path), fp.read()[:-1]))
pattern = re.compile(r'^Pkg.Revision *= *(.+)', re.MULTILINE) pattern = re.compile(r'^Pkg.Revision *= *(.+)', re.MULTILINE)
for root, dirs, files in os.walk(sdk_path): for root, dirs, files in os.walk(sdk_path):
@ -3898,10 +3896,10 @@ def get_android_tools_versions(ndk_path=None):
return components return components
def get_android_tools_version_log(ndk_path=None): def get_android_tools_version_log():
'''get a list of the versions of all installed Android SDK/NDK components''' '''get a list of the versions of all installed Android SDK/NDK components'''
log = '== Installed Android Tools ==\n\n' log = '== Installed Android Tools ==\n\n'
components = get_android_tools_versions(ndk_path) components = get_android_tools_versions()
for name, version in sorted(components): for name, version in sorted(components):
log += '* ' + name + ' (' + version + ')\n' log += '* ' + name + ' (' + version + ')\n'

View file

@ -362,7 +362,7 @@ class BuildTest(unittest.TestCase):
with mock.patch( with mock.patch(
'fdroidserver.common.force_exit', lambda *args: None 'fdroidserver.common.force_exit', lambda *args: None
) as a, mock.patch( ) as a, mock.patch(
'fdroidserver.common.get_android_tools_version_log', lambda s: 'fake' 'fdroidserver.common.get_android_tools_version_log', lambda: 'fake'
) as b, mock.patch( ) as b, mock.patch(
'fdroidserver.common.FDroidPopen', FakeProcess 'fdroidserver.common.FDroidPopen', FakeProcess
) as c, mock.patch( ) as c, mock.patch(