chiark / gitweb /
if keystore is given as arg to init, create keystore if it does not exist
authorHans-Christoph Steiner <hans@eds.org>
Fri, 4 Apr 2014 02:30:43 +0000 (22:30 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 7 Apr 2014 20:00:18 +0000 (16:00 -0400)
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

index 85da8ffc5242813160cb4a1c09b0e4a136a9ace5..36e38e52f75350694e046ff73f63ad02582600f5 100644 (file)
@@ -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)