mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-08 18:31:07 +03:00
fdroid update --create-key
to create a keystore/key
This provides the final option in this series, allowing the user to just add --create-key to `fdroid update, and thereby upgrade an unsigned repo to a proper signed repo. It also might be useful closes #13 https://gitlab.com/fdroid/fdroidserver/issues/13
This commit is contained in:
parent
276123856c
commit
de1c80f9b4
2 changed files with 74 additions and 0 deletions
|
@ -23,6 +23,7 @@ import os
|
|||
import shutil
|
||||
import glob
|
||||
import re
|
||||
import socket
|
||||
import zipfile
|
||||
import hashlib
|
||||
import pickle
|
||||
|
@ -1019,6 +1020,8 @@ def main():
|
|||
|
||||
# Parse command line...
|
||||
parser = OptionParser()
|
||||
parser.add_option("--create-key", action="store_true", default=False,
|
||||
help="Create a repo signing key in a keystore")
|
||||
parser.add_option("-c", "--create-metadata", action="store_true", default=False,
|
||||
help="Create skeleton metadata files that are missing")
|
||||
parser.add_option("--delete-unknown", action="store_true", default=False,
|
||||
|
@ -1065,6 +1068,32 @@ def main():
|
|||
logging.critical(k + ' "' + config[k] + '" does not exist! Correct it in config.py.')
|
||||
sys.exit(1)
|
||||
|
||||
# if the user asks to create a keystore, do it now, reusing whatever it can
|
||||
if options.create_key:
|
||||
if os.path.exists(config['keystore']):
|
||||
logging.critical("Cowardily refusing to overwrite existing signing key setup!")
|
||||
logging.critical("\t'" + config['keystore'] + "'")
|
||||
sys.exit(1)
|
||||
|
||||
if not 'repo_keyalias' in config:
|
||||
config['repo_keyalias'] = socket.getfqdn()
|
||||
common.write_to_config(config, 'repo_keyalias', config['repo_keyalias'])
|
||||
if not 'keydname' in config:
|
||||
config['keydname'] = 'CN=' + config['repo_keyalias'] + ', OU=F-Droid'
|
||||
common.write_to_config(config, 'keydname', config['keydname'])
|
||||
if not 'keystore' in config:
|
||||
config['keystore'] = common.default_config.keystore
|
||||
common.write_to_config(config, 'keystore', config['keystore'])
|
||||
|
||||
password = common.genpassword()
|
||||
if not 'keystorepass' in config:
|
||||
config['keystorepass'] = password
|
||||
common.write_to_config(config, 'keystorepass', config['keystorepass'])
|
||||
if not 'keypass' in config:
|
||||
config['keypass'] = password
|
||||
common.write_to_config(config, 'keypass', config['keypass'])
|
||||
common.genkeystore(config)
|
||||
|
||||
# Get all apps...
|
||||
apps = metadata.read_metadata()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue