mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-14 11:00:10 +01:00
18f3acc32e
There is no longer any reason for these to be intertwined. This deliberately avoids touching some files as much as possible because they are super tangled and due to be replaced. Those files are: * fdroidserver/build.py * fdroidserver/update.py # Conflicts: # tests/testcommon.py # Conflicts: # fdroidserver/btlog.py # fdroidserver/import_subcommand.py
49 lines
2.0 KiB
Python
49 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# an fdroid plugin for exporting a repo's keystore in standard PEM format
|
|
|
|
import os
|
|
from argparse import ArgumentParser
|
|
from fdroidserver import common
|
|
from fdroidserver.common import FDroidPopen
|
|
from fdroidserver.exception import BuildException
|
|
|
|
fdroid_summary = 'export the keystore in standard PEM format'
|
|
|
|
|
|
def main():
|
|
parser = ArgumentParser()
|
|
common.setup_global_opts(parser)
|
|
common.parse_args(parser)
|
|
config = common.read_config()
|
|
env_vars = {'LC_ALL': 'C.UTF-8',
|
|
'FDROID_KEY_STORE_PASS': config['keystorepass'],
|
|
'FDROID_KEY_PASS': config['keypass']}
|
|
destkeystore = config['keystore'].replace('.jks', '.p12').replace('/', '_')
|
|
exportkeystore = config['keystore'].replace('.jks', '.pem').replace('/', '_')
|
|
if os.path.exists(destkeystore) or os.path.exists(exportkeystore):
|
|
raise BuildException('%s exists!' % exportkeystore)
|
|
p = FDroidPopen([config['keytool'], '-importkeystore',
|
|
'-srckeystore', config['keystore'],
|
|
'-srcalias', config['repo_keyalias'],
|
|
'-srcstorepass:env', 'FDROID_KEY_STORE_PASS',
|
|
'-srckeypass:env', 'FDROID_KEY_PASS',
|
|
'-destkeystore', destkeystore,
|
|
'-deststoretype', 'PKCS12',
|
|
'-deststorepass:env', 'FDROID_KEY_STORE_PASS',
|
|
'-destkeypass:env', 'FDROID_KEY_PASS'],
|
|
envs=env_vars)
|
|
if p.returncode != 0:
|
|
raise BuildException("Failed to convert to PKCS12!", p.output)
|
|
p = FDroidPopen(['openssl', 'pkcs12', '-in', destkeystore,
|
|
'-passin', 'env:FDROID_KEY_STORE_PASS', '-nokeys',
|
|
'-out', exportkeystore,
|
|
'-passout', 'env:FDROID_KEY_STORE_PASS'],
|
|
envs=env_vars)
|
|
if p.returncode != 0:
|
|
raise BuildException("Failed to convert to PEM!", p.output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|