From 2397c13d306386e23c8847cf9dcddf6c1be7de97 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Wed, 17 Sep 2014 00:20:37 +0200 Subject: [PATCH] Fix --android-home in 'fdroid init' when ANDROID_HOME is set --- fdroidserver/init.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fdroidserver/init.py b/fdroidserver/init.py index e656256a..6f96a24b 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -36,11 +36,11 @@ config = {} options = None -def write_to_config(config, key, value=None): +def write_to_config(thisconfig, key, value=None): '''write a key/value to the local config.py''' if value is None: origkey = key + '_orig' - value = config[origkey] if origkey in config else config[key] + value = thisconfig[origkey] if origkey in thisconfig else thisconfig[key] with open('config.py', 'r') as f: data = f.read() pattern = '\n[\s#]*' + key + '\s*=\s*"[^"]*"' @@ -158,7 +158,11 @@ def main(): shutil.copy(os.path.join(examplesdir, 'fdroid-icon.png'), fdroiddir) shutil.copyfile(os.path.join(examplesdir, 'config.py'), 'config.py') os.chmod('config.py', 0o0600) - write_to_config(test_config, 'sdk_path') + # If android_home is None, test_config['sdk_path'] will be used and + # "$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. + 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.') -- 2.30.2