mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 07:20:29 +03:00
find cmds from SDK build-tools in a more flexible way, on the fly
This is a more flexible approach than testing for the complete SDK and build-tools up front. This will only test for the commands that are actually being run, so that if you only have `aapt` installed, you can do `fdroid update` without errors, but other commands will still give appropriate errors. This also makes the build_tools item in config.py optional, it is only needed if you want to force a specific version of the build-tools.
This commit is contained in:
parent
298a88a498
commit
9244256461
6 changed files with 132 additions and 46 deletions
|
|
@ -168,28 +168,31 @@ def main():
|
|||
logging.info('Try running `fdroid init` in an empty directory.')
|
||||
sys.exit()
|
||||
|
||||
# try to find a working aapt, in all the recent possible paths
|
||||
build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
|
||||
aaptdirs = []
|
||||
aaptdirs.append(os.path.join(build_tools, test_config['build_tools']))
|
||||
aaptdirs.append(build_tools)
|
||||
for f in os.listdir(build_tools):
|
||||
if os.path.isdir(os.path.join(build_tools, f)):
|
||||
aaptdirs.append(os.path.join(build_tools, f))
|
||||
for d in sorted(aaptdirs, reverse=True):
|
||||
if os.path.isfile(os.path.join(d, 'aapt')):
|
||||
aapt = os.path.join(d, 'aapt')
|
||||
break
|
||||
if os.path.isfile(aapt):
|
||||
dirname = os.path.basename(os.path.dirname(aapt))
|
||||
if dirname == 'build-tools':
|
||||
# this is the old layout, before versioned build-tools
|
||||
test_config['build_tools'] = ''
|
||||
else:
|
||||
test_config['build_tools'] = dirname
|
||||
write_to_config(test_config, 'build_tools')
|
||||
if not common.test_build_tools_exists(test_config):
|
||||
sys.exit(3)
|
||||
if os.path.exists('/usr/bin/aapt'):
|
||||
# make sure at least aapt is found, since this can't do anything without it
|
||||
config['aapt'] = common.find_sdk_tools_cmd('aapt')
|
||||
else:
|
||||
# try to find a working aapt, in all the recent possible paths
|
||||
build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
|
||||
aaptdirs = []
|
||||
aaptdirs.append(os.path.join(build_tools, test_config['build_tools']))
|
||||
aaptdirs.append(build_tools)
|
||||
for f in os.listdir(build_tools):
|
||||
if os.path.isdir(os.path.join(build_tools, f)):
|
||||
aaptdirs.append(os.path.join(build_tools, f))
|
||||
for d in sorted(aaptdirs, reverse=True):
|
||||
if os.path.isfile(os.path.join(d, 'aapt')):
|
||||
aapt = os.path.join(d, 'aapt')
|
||||
break
|
||||
if os.path.isfile(aapt):
|
||||
dirname = os.path.basename(os.path.dirname(aapt))
|
||||
if dirname == 'build-tools':
|
||||
# this is the old layout, before versioned build-tools
|
||||
test_config['build_tools'] = ''
|
||||
else:
|
||||
test_config['build_tools'] = dirname
|
||||
write_to_config(test_config, 'build_tools')
|
||||
common.ensure_build_tools_exists(test_config)
|
||||
|
||||
# now that we have a local config.py, read configuration...
|
||||
config = common.read_config(options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue