From b41f9e67a9570337b43733291e962dc7b06135c1 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 3 Apr 2014 22:30:43 -0400 Subject: [PATCH] if keystore is given as arg to init, create keystore if it does not exist Previously, `fdroid init --keystore /tmp/foo` expected the keystore to exist, or it quit with an error. But I've changed my mind, I think it is useful to have it generate a new keystore at that location if it does not exist. For example, in tests/run-tests.sh. It still will not clobber an existing file at that location. --- fdroidserver/init.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fdroidserver/init.py b/fdroidserver/init.py index 85da8ffc..36e38e52 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -175,15 +175,20 @@ def main(): # find or generate the keystore for the repo signing key. First try the # path written in the default config.py. Then check if the user has # specified a path from the command line, which will trump all others. - # Otherwise, create ~/.local/share/fdroidserver and stick it in there. + # Otherwise, create ~/.local/share/fdroidserver and stick it in there. If + # keystore is set to NONE, that means that Java will look for keys in a + # Hardware Security Module aka Smartcard. keystore = config['keystore'] if options.keystore: - if os.path.isfile(options.keystore): + keystore = os.path.abspath(options.keystore) + if options.keystore == 'NONE': keystore = options.keystore - write_to_config('keystore', keystore) else: - logging.info('"' + options.keystore + '" does not exist or is not a file!') - sys.exit(1) + keystore = os.path.abspath(options.keystore) + if not os.path.exists(keystore): + logging.info('"' + keystore + + '" does not exist, creating a new keystore there.') + write_to_config('keystore', keystore) if options.repo_keyalias: repo_keyalias = options.repo_keyalias write_to_config('repo_keyalias', repo_keyalias) @@ -195,7 +200,6 @@ def main(): keystoredir = os.path.dirname(keystore) if not os.path.exists(keystoredir): os.makedirs(keystoredir, mode=0o700) - write_to_config('keystore', keystore) password = genpassword() write_to_config('keystorepass', password) write_to_config('keypass', password) -- 2.30.2