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