2 # -*- coding: utf-8 -*-
4 # publish.py - part of the FDroid server tools
5 # Copyright (C) 2010-2014, Ciaran Gultnieks, ciaran@ciarang.com
6 # Copyright (C) 2013-2014 Daniel Martà <mvdan@mvdan.cc>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 from optparse import OptionParser
31 from common import FDroidPopen, BuildException
39 global config, options
41 # Parse command line...
42 parser = OptionParser(usage="Usage: %prog [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
43 parser.add_option("-v", "--verbose", action="store_true", default=False,
44 help="Spew out even more information than normal")
45 parser.add_option("-q", "--quiet", action="store_true", default=False,
46 help="Restrict output to warnings and errors")
47 (options, args) = parser.parse_args()
49 config = common.read_config(options)
52 if not os.path.isdir(output_dir):
53 logging.error("Missing output directory")
56 # Process any apks that are waiting to be signed...
57 for apkfile in sorted(glob.glob(os.path.join(output_dir, '*.apk'))):
59 apkfilename = os.path.basename(apkfile)
60 sigfilename = apkfilename + ".txt"
61 sigpath = os.path.join(output_dir, sigfilename)
63 if not os.path.exists(sigpath):
64 p = FDroidPopen(['gpg', '-a',
67 os.path.join(output_dir, apkfilename)])
69 logging.error("Signing failed.")
72 logging.info('Signed ' + apkfilename)
75 if __name__ == "__main__":