mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
Better parsing of args, install now works as it should
This commit is contained in:
parent
3aec0aacd7
commit
84bf3d758f
@ -40,6 +40,9 @@ __package() {
|
|||||||
|
|
||||||
__signed_package() {
|
__signed_package() {
|
||||||
files=( repo/*.apk )
|
files=( repo/*.apk )
|
||||||
|
if [ "${files[0]}" == "repo/*.apk" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
files=( ${files[@]#repo/} )
|
files=( ${files[@]#repo/} )
|
||||||
files=${files[@]%_*}
|
files=${files[@]%_*}
|
||||||
COMPREPLY=( $( compgen -W "$files" -- $cur ) )
|
COMPREPLY=( $( compgen -W "$files" -- $cur ) )
|
||||||
|
@ -110,9 +110,9 @@ def read_config(opts, config_file='config.py'):
|
|||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def read_app_args(args, options, allapps, allow_vercodes=False):
|
def read_pkg_args(args, options, allow_vercodes=False):
|
||||||
if not args:
|
if not args:
|
||||||
return []
|
return {}
|
||||||
|
|
||||||
vercodes = {}
|
vercodes = {}
|
||||||
for p in args:
|
for p in args:
|
||||||
@ -125,11 +125,18 @@ def read_app_args(args, options, allapps, allow_vercodes=False):
|
|||||||
continue
|
continue
|
||||||
elif vercode and vercode not in vercodes[package]:
|
elif vercode and vercode not in vercodes[package]:
|
||||||
vercodes[package] += [vercode] if vercode else []
|
vercodes[package] += [vercode] if vercode else []
|
||||||
packages = vercodes.keys()
|
|
||||||
apps = [app for app in allapps if app['id'] in packages]
|
return vercodes
|
||||||
if len(apps) != len(packages):
|
|
||||||
|
def read_app_args(args, options, allapps, allow_vercodes=False):
|
||||||
|
vercodes = read_pkg_args(args, options, allow_vercodes)
|
||||||
|
|
||||||
|
apps = [app for app in allapps if app['id'] in vercodes]
|
||||||
|
if not apps:
|
||||||
|
raise Exception("No packages specified")
|
||||||
|
if len(apps) != len(vercodes):
|
||||||
allids = [app["id"] for app in allapps]
|
allids = [app["id"] for app in allapps]
|
||||||
for p in packages:
|
for p in vercodes:
|
||||||
if p not in allids:
|
if p not in allids:
|
||||||
print "No such package: %s" % p
|
print "No such package: %s" % p
|
||||||
raise Exception("Found invalid app ids in arguments")
|
raise Exception("Found invalid app ids in arguments")
|
||||||
@ -154,6 +161,18 @@ def read_app_args(args, options, allapps, allow_vercodes=False):
|
|||||||
|
|
||||||
return apps
|
return apps
|
||||||
|
|
||||||
|
apk_regex = None
|
||||||
|
|
||||||
|
def apknameinfo(basename):
|
||||||
|
global apk_regex
|
||||||
|
if apk_regex is None:
|
||||||
|
apk_regex = re.compile(r"^([a-zA-Z\.]+)_([0-9]+)\.apk$")
|
||||||
|
m = apk_regex.match(basename)
|
||||||
|
try:
|
||||||
|
result = (m.group(1), m.group(2))
|
||||||
|
except AttributeError:
|
||||||
|
raise Exception("Invalid apk name: %s" % basename)
|
||||||
|
return result
|
||||||
|
|
||||||
def getapkname(app, build):
|
def getapkname(app, build):
|
||||||
return "%s_%s.apk" % (app['id'], build['vercode'])
|
return "%s_%s.apk" % (app['id'], build['vercode'])
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# import.py - part of the FDroid server tools
|
# import.py - part of the FDroid server tools
|
||||||
# Copyright (C) 2010-13, Ciaran Gultnieks, ciaran@ciarang.com
|
# Copyright (C) 2010-13, Ciaran Gultnieks, ciaran@ciarang.com
|
||||||
|
# Copyright (C) 2013 Daniel Martí <mvdan@mvdan.cc>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# verify.py - part of the FDroid server tools
|
# verify.py - part of the FDroid server tools
|
||||||
# Copyright (C) 2013, Ciaran Gultnieks, ciaran@ciarang.com
|
# Copyright (C) 2013, Ciaran Gultnieks, ciaran@ciarang.com
|
||||||
|
# Copyright (C) 2013 Daniel Martí <mvdan@mvdan.cc>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -19,6 +20,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import glob
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -44,6 +46,8 @@ def main():
|
|||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
|
parser.add_option("-a", "--all", action="store_true", default=False,
|
||||||
|
help="Install all signed applications available")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
@ -53,26 +57,39 @@ def main():
|
|||||||
print "No signed output directory - nothing to do"
|
print "No signed output directory - nothing to do"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Get all apps...
|
if args:
|
||||||
allapps = metadata.read_metadata()
|
|
||||||
|
|
||||||
apps = common.read_app_args(args, options, allapps, True)
|
vercodes = common.read_pkg_args(args, options, True)
|
||||||
|
apks = { appid : None for appid in vercodes }
|
||||||
|
|
||||||
for app in apps:
|
# Get the signed apk with the highest vercode
|
||||||
last = None
|
for apkfile in sorted(glob.glob(os.path.join(output_dir, '*.apk'))):
|
||||||
for build in app['builds']:
|
|
||||||
apk = os.path.join(output_dir, common.getapkname(app, build))
|
|
||||||
if os.path.exists(apk):
|
|
||||||
last = build
|
|
||||||
if last is None:
|
|
||||||
raise Exception("No available signed apks for %s" % app['id'])
|
|
||||||
|
|
||||||
for app in apps:
|
apkfilename = os.path.basename(apkfile)
|
||||||
build = app['builds'][0]
|
appid, vercode = common.apknameinfo(apkfilename)
|
||||||
apk = os.path.join(output_dir, common.getapkname(app, build))
|
if appid not in apks:
|
||||||
if not os.path.exists(apk):
|
continue
|
||||||
raise Exception("No such signed apk: %s" % apk)
|
if vercodes[appid] and vc not in vercodes[appid]:
|
||||||
continue
|
continue
|
||||||
|
apks[appid] = apkfile
|
||||||
|
|
||||||
|
for appid, apk in apks.iteritems():
|
||||||
|
if not apk:
|
||||||
|
raise Exception("No signed apk available for %s" % appid)
|
||||||
|
|
||||||
|
elif options.all:
|
||||||
|
|
||||||
|
for apkfile in sorted(glob.glob(os.path.join(output_dir, '*.apk'))):
|
||||||
|
|
||||||
|
apkfilename = os.path.basename(apkfile)
|
||||||
|
appid, vercode = common.apknameinfo(apkfilename)
|
||||||
|
apks[appid] = apkfile
|
||||||
|
|
||||||
|
else:
|
||||||
|
print "If you really want to install all the signed apps, use --all"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
for appid, apk in apks.iteritems():
|
||||||
# Get device list each time to avoid device not found errors
|
# Get device list each time to avoid device not found errors
|
||||||
devs = devices()
|
devs = devices()
|
||||||
if not devs:
|
if not devs:
|
||||||
|
Loading…
Reference in New Issue
Block a user