1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-03 17:50:11 +02:00

do not set sdk_path in config.py if using system-provided aapt

By not setting sdk_path when /usr/bin/aapt is found, sdk_path then defaults
to $ANDROID_HOME when its used.  Since in this case, aapt will be used from
the system path, using aapt entirely ignores sdk_path.  If the user runs
`fdroid build` in this setup, sdk_path will be $ANDROID_HOME, so it should
check the env vars for it, but maybe that doesn't actually work like that
yet.
This commit is contained in:
Hans-Christoph Steiner 2014-12-09 15:20:29 +01:00
parent fa1cc48d57
commit 5f5bcd2e11
3 changed files with 35 additions and 25 deletions

View File

@ -9,7 +9,7 @@
# Override the path to the Android NDK, $ANDROID_NDK by default
# ndk_path = "/path/to/android-ndk"
# Build tools version to be used
build_tools = "21.1.2"
# build_tools = "21.1.2"
# Command for running Ant
# ant = "/path/to/ant"

View File

@ -169,7 +169,7 @@ def find_sdk_tools_cmd(cmd):
'''find a working path to a tool from the Android SDK'''
tooldirs = []
if 'sdk_path' in config and os.path.exists(config['sdk_path']):
if config is not None and 'sdk_path' in config and os.path.exists(config['sdk_path']):
# try to find a working path to this command, in all the recent possible paths
if 'build_tools' in config:
build_tools = os.path.join(config['sdk_path'], 'build-tools')
@ -199,6 +199,9 @@ def find_sdk_tools_cmd(cmd):
def test_sdk_exists(thisconfig):
if 'sdk_path' not in thisconfig:
if 'aapt' in thisconfig and os.path.isfile(thisconfig['aapt']):
return True
else:
logging.error("'sdk_path' not set in config.py!")
return False
if thisconfig['sdk_path'] == default_config['sdk_path']:

View File

@ -124,6 +124,7 @@ def main():
prefix = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
examplesdir = prefix + '/examples'
aapt = None
fdroiddir = os.getcwd()
test_config = dict()
common.fill_config_defaults(test_config)
@ -133,6 +134,13 @@ def main():
if options.android_home is not None:
test_config['sdk_path'] = options.android_home
elif not common.test_sdk_exists(test_config):
if os.path.isfile('/usr/bin/aapt'):
# remove sdk_path and build_tools, they are not required
test_config.pop('sdk_path', None)
test_config.pop('build_tools', None)
# make sure at least aapt is found, since this can't do anything without it
test_config['aapt'] = common.find_sdk_tools_cmd('aapt')
else:
# if neither --android-home nor the default sdk_path exist, prompt the user
default_sdk_path = '/opt/android-sdk'
while not options.no_prompt:
@ -162,16 +170,14 @@ def main():
# "$ANDROID_HOME" may be used if the env var is set up correctly.
# If android_home is not None, the path given from the command line
# will be directly written in the config.
if 'sdk_path' in test_config:
write_to_config(test_config, 'sdk_path', options.android_home)
else:
logging.warn('Looks like this is already an F-Droid repo, cowardly refusing to overwrite it...')
logging.info('Try running `fdroid init` in an empty directory.')
sys.exit()
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:
if not 'aapt' in test_config or not os.path.isfile(test_config['aapt']):
# try to find a working aapt, in all the recent possible paths
build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
aaptdirs = []
@ -278,6 +284,7 @@ def main():
logging.info('Built repo based in "' + fdroiddir + '"')
logging.info('with this config:')
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 (optional):\t' + ndk_path)
logging.info(' Keystore for signing key:\t' + keystore)