chiark / gitweb /
Only report files that were actually cleaned of signing stuff
[fdroidserver.git] / fdroid
1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
3 #
4 # fdroid.py - part of the FDroid server tools
5 # Copyright (C) 2010-13, Ciaran Gultnieks, ciaran@ciarang.com
6 # Copyright (C) 2013-2014 Daniel Martí <mvdan@mvdan.cc>
7 #
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.
12 #
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.
17 #
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/>.
20
21 import sys
22 import logging
23
24 commands = {
25     "build": "Build a package from source",
26     "init": "Quickly start a new repository",
27     "publish": "Sign and place packages in the repo",
28     "gpgsign": "Add gpg signatures for packages in repo",
29     "update": "Update repo information for new packages",
30     "verify": "Verify the integrity of downloaded packages",
31     "checkupdates": "Check for updates to applications",
32     "import": "Add a new application from its source code",
33     "install": "Install built packages on devices",
34     "readmeta": "Read all the metadata files and exit",
35     "rewritemeta": "Rewrite all the metadata files",
36     "lint": "Warn about possible metadata errors",
37     "scanner": "Scan the source code of a package",
38     "stats": "Update the stats of the repo",
39     "server": "Interact with the repo HTTP server",
40     }
41
42
43 def print_help():
44     print "usage: fdroid [-h|--help] <command> [<args>]"
45     print
46     print "Valid commands are:"
47     for cmd, summary in commands.items():
48         print "   " + cmd + ' ' * (15 - len(cmd)) + summary
49     print
50
51
52 def main():
53
54     if len(sys.argv) <= 1:
55         print_help()
56         sys.exit(0)
57
58     command = sys.argv[1]
59     if command not in commands:
60         if command in ('-h', '--help'):
61             print_help()
62             sys.exit(0)
63         else:
64             print "Command '%s' not recognised.\n" % command
65             print_help()
66             sys.exit(1)
67
68     verbose = any(s in sys.argv for s in ['-v', '--verbose'])
69     quiet = any(s in sys.argv for s in ['-q', '--quiet'])
70     if verbose and quiet:
71         print "Specifying verbose and quiet and the same time is silly"
72         sys.exit(1)
73
74     if verbose:
75         logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
76     elif quiet:
77         logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARN)
78     else:
79         logging.basicConfig(format='%(message)s', level=logging.INFO)
80
81     # Trick optparse into displaying the right usage when --help is used.
82     sys.argv[0] += ' ' + command
83
84     del sys.argv[1]
85     mod = __import__('fdroidserver.' + command, None, None, [command])
86     try:
87         mod.main()
88     except Exception, e:
89         if verbose:
90             raise
91         else:
92             print str(e)
93         sys.exit(1)
94     sys.exit(0)
95
96 if __name__ == "__main__":
97     main()