3 # gpgsign.py - part of the FDroid server tools
4 # Copyright (C) 2015, Ciaran Gultnieks, ciaran@ciarang.com
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from argparse import ArgumentParser
25 from .common import FDroidPopen
33 global config, options
35 # Parse command line...
36 parser = ArgumentParser(usage="%(prog)s [options]")
37 common.setup_global_opts(parser)
38 options = parser.parse_args()
40 config = common.read_config(options)
42 if 'jarsigner' not in config:
43 logging.critical('Java jarsigner not found! Install in standard location or set java_paths!')
47 if config['archive_older'] != 0:
48 repodirs.append('archive')
51 for output_dir in repodirs:
52 if not os.path.isdir(output_dir):
53 logging.error("Missing output directory '" + output_dir + "'")
56 unsigned = os.path.join(output_dir, 'index_unsigned.jar')
57 if os.path.exists(unsigned):
59 args = [config['jarsigner'], '-keystore', config['keystore'],
60 '-storepass:file', config['keystorepassfile'],
61 '-digestalg', 'SHA1', '-sigalg', 'SHA1withRSA',
62 unsigned, config['repo_keyalias']]
63 if config['keystore'] == 'NONE':
64 args += config['smartcardoptions']
65 else: # smardcards never use -keypass
66 args += ['-keypass:file', config['keypassfile']]
69 logging.critical("Failed to sign index")
71 os.rename(unsigned, os.path.join(output_dir, 'index.jar'))
72 logging.info('Signed index in ' + output_dir)
76 logging.info("Nothing to do")
78 if __name__ == "__main__":