2 # -*- coding: utf-8 -*-
4 # verify.py - part of the FDroid server tools
5 # Copyright (C) 2013, 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 optparse import OptionParser
25 from common import FDroidPopen
32 p = FDroidPopen(["adb", "devices"])
34 raise Exception("An error occured when finding devices: %s" % p.stderr)
36 return [l.split()[0] for l in p.stdout.splitlines()[1:-1]]
41 global options, config
43 # Parse command line...
44 parser = OptionParser()
45 parser.add_option("-v", "--verbose", action="store_true", default=False,
46 help="Spew out even more information than normal")
47 (options, args) = parser.parse_args()
49 config = common.read_config(options)
52 if not os.path.isdir(output_dir):
53 print "No signed output directory - nothing to do"
57 allapps = metadata.read_metadata()
59 apps = common.read_app_args(args, options, allapps)
63 for build in app['builds']:
64 apk = os.path.join(output_dir, common.getapkname(app, build))
65 if os.path.exists(apk):
68 raise Exception("No available signed apks for %s" % app['id'])
71 build = app['builds'][0]
72 apk = os.path.join(output_dir, common.getapkname(app, build))
73 if not os.path.exists(apk):
74 raise Exception("No such signed apk: %s" % apk)
76 # Get device list each time to avoid device not found errors
79 raise Exception("No attached devices found")
80 print "Installing %s..." % apk
82 print "Installing %s on %s..." % (apk, dev)
83 p = FDroidPopen(["adb", "-s", dev, "install", apk ])
85 for line in p.stdout.splitlines():
86 if line.startswith("Failure"):
89 raise Exception("Failed to install %s on %s: %s" % (
94 if __name__ == "__main__":