mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 15:02:51 +03: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:
parent
fa1cc48d57
commit
5f5bcd2e11
3 changed files with 35 additions and 25 deletions
|
@ -9,7 +9,7 @@
|
||||||
# Override the path to the Android NDK, $ANDROID_NDK by default
|
# Override the path to the Android NDK, $ANDROID_NDK by default
|
||||||
# ndk_path = "/path/to/android-ndk"
|
# ndk_path = "/path/to/android-ndk"
|
||||||
# Build tools version to be used
|
# Build tools version to be used
|
||||||
build_tools = "21.1.2"
|
# build_tools = "21.1.2"
|
||||||
|
|
||||||
# Command for running Ant
|
# Command for running Ant
|
||||||
# ant = "/path/to/ant"
|
# ant = "/path/to/ant"
|
||||||
|
|
|
@ -169,7 +169,7 @@ def find_sdk_tools_cmd(cmd):
|
||||||
'''find a working path to a tool from the Android SDK'''
|
'''find a working path to a tool from the Android SDK'''
|
||||||
|
|
||||||
tooldirs = []
|
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
|
# try to find a working path to this command, in all the recent possible paths
|
||||||
if 'build_tools' in config:
|
if 'build_tools' in config:
|
||||||
build_tools = os.path.join(config['sdk_path'], 'build-tools')
|
build_tools = os.path.join(config['sdk_path'], 'build-tools')
|
||||||
|
@ -199,8 +199,11 @@ def find_sdk_tools_cmd(cmd):
|
||||||
|
|
||||||
def test_sdk_exists(thisconfig):
|
def test_sdk_exists(thisconfig):
|
||||||
if 'sdk_path' not in thisconfig:
|
if 'sdk_path' not in thisconfig:
|
||||||
logging.error("'sdk_path' not set in config.py!")
|
if 'aapt' in thisconfig and os.path.isfile(thisconfig['aapt']):
|
||||||
return False
|
return True
|
||||||
|
else:
|
||||||
|
logging.error("'sdk_path' not set in config.py!")
|
||||||
|
return False
|
||||||
if thisconfig['sdk_path'] == default_config['sdk_path']:
|
if thisconfig['sdk_path'] == default_config['sdk_path']:
|
||||||
logging.error('No Android SDK found!')
|
logging.error('No Android SDK found!')
|
||||||
logging.error('You can use ANDROID_HOME to set the path to your SDK, i.e.:')
|
logging.error('You can use ANDROID_HOME to set the path to your SDK, i.e.:')
|
||||||
|
|
|
@ -124,6 +124,7 @@ def main():
|
||||||
prefix = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
|
prefix = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
examplesdir = prefix + '/examples'
|
examplesdir = prefix + '/examples'
|
||||||
|
|
||||||
|
aapt = None
|
||||||
fdroiddir = os.getcwd()
|
fdroiddir = os.getcwd()
|
||||||
test_config = dict()
|
test_config = dict()
|
||||||
common.fill_config_defaults(test_config)
|
common.fill_config_defaults(test_config)
|
||||||
|
@ -133,21 +134,28 @@ def main():
|
||||||
if options.android_home is not None:
|
if options.android_home is not None:
|
||||||
test_config['sdk_path'] = options.android_home
|
test_config['sdk_path'] = options.android_home
|
||||||
elif not common.test_sdk_exists(test_config):
|
elif not common.test_sdk_exists(test_config):
|
||||||
# if neither --android-home nor the default sdk_path exist, prompt the user
|
if os.path.isfile('/usr/bin/aapt'):
|
||||||
default_sdk_path = '/opt/android-sdk'
|
# remove sdk_path and build_tools, they are not required
|
||||||
while not options.no_prompt:
|
test_config.pop('sdk_path', None)
|
||||||
try:
|
test_config.pop('build_tools', None)
|
||||||
s = raw_input('Enter the path to the Android SDK ('
|
# make sure at least aapt is found, since this can't do anything without it
|
||||||
+ default_sdk_path + ') here:\n> ')
|
test_config['aapt'] = common.find_sdk_tools_cmd('aapt')
|
||||||
except KeyboardInterrupt:
|
else:
|
||||||
print('')
|
# if neither --android-home nor the default sdk_path exist, prompt the user
|
||||||
sys.exit(1)
|
default_sdk_path = '/opt/android-sdk'
|
||||||
if re.match('^\s*$', s) is not None:
|
while not options.no_prompt:
|
||||||
test_config['sdk_path'] = default_sdk_path
|
try:
|
||||||
else:
|
s = raw_input('Enter the path to the Android SDK ('
|
||||||
test_config['sdk_path'] = s
|
+ default_sdk_path + ') here:\n> ')
|
||||||
if common.test_sdk_exists(test_config):
|
except KeyboardInterrupt:
|
||||||
break
|
print('')
|
||||||
|
sys.exit(1)
|
||||||
|
if re.match('^\s*$', s) is not None:
|
||||||
|
test_config['sdk_path'] = default_sdk_path
|
||||||
|
else:
|
||||||
|
test_config['sdk_path'] = s
|
||||||
|
if common.test_sdk_exists(test_config):
|
||||||
|
break
|
||||||
if not common.test_sdk_exists(test_config):
|
if not common.test_sdk_exists(test_config):
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
|
@ -162,16 +170,14 @@ def main():
|
||||||
# "$ANDROID_HOME" may be used if the env var is set up correctly.
|
# "$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
|
# If android_home is not None, the path given from the command line
|
||||||
# will be directly written in the config.
|
# will be directly written in the config.
|
||||||
write_to_config(test_config, 'sdk_path', options.android_home)
|
if 'sdk_path' in test_config:
|
||||||
|
write_to_config(test_config, 'sdk_path', options.android_home)
|
||||||
else:
|
else:
|
||||||
logging.warn('Looks like this is already an F-Droid repo, cowardly refusing to overwrite it...')
|
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.')
|
logging.info('Try running `fdroid init` in an empty directory.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if os.path.exists('/usr/bin/aapt'):
|
if not 'aapt' in test_config or not os.path.isfile(test_config['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
|
# try to find a working aapt, in all the recent possible paths
|
||||||
build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
|
build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
|
||||||
aaptdirs = []
|
aaptdirs = []
|
||||||
|
@ -278,7 +284,8 @@ def main():
|
||||||
logging.info('Built repo based in "' + fdroiddir + '"')
|
logging.info('Built repo based in "' + fdroiddir + '"')
|
||||||
logging.info('with this config:')
|
logging.info('with this config:')
|
||||||
logging.info(' Android SDK:\t\t\t' + config['sdk_path'])
|
logging.info(' Android SDK:\t\t\t' + config['sdk_path'])
|
||||||
logging.info(' Android SDK Build Tools:\t' + os.path.dirname(aapt))
|
if aapt:
|
||||||
|
logging.info(' Android SDK Build Tools:\t' + os.path.dirname(aapt))
|
||||||
logging.info(' Android NDK (optional):\t' + ndk_path)
|
logging.info(' Android NDK (optional):\t' + ndk_path)
|
||||||
logging.info(' Keystore for signing key:\t' + keystore)
|
logging.info(' Keystore for signing key:\t' + keystore)
|
||||||
if repo_keyalias is not None:
|
if repo_keyalias is not None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue