1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

check for invalid appids passed to commands

This commit is contained in:
Felix C. Stegerman 2021-04-03 01:34:38 +02:00
parent 380f3b2e9f
commit 3e557a1a8a
No known key found for this signature in database
GPG Key ID: B218FF2C27FC6CC6
5 changed files with 36 additions and 13 deletions

View File

@ -618,13 +618,35 @@ def read_pkg_args(appid_versionCode_pairs, allow_vercodes=False):
return vercodes
def get_metadata_files(vercodes):
"""
Build a list of metadata files and raise an exception for invalid appids.
:param vercodes: version codes as returned by read_pkg_args()
:returns: a list of corresponding metadata/*.yml files
"""
found_invalid = False
metadatafiles = []
for appid in vercodes.keys():
f = os.path.join('metadata', '%s.yml' % appid)
if os.path.exists(f):
metadatafiles.append(f)
else:
found_invalid = True
logging.critical(_("No such package: %s") % appid)
if found_invalid:
raise FDroidException(_("Found invalid appids in arguments"))
return metadatafiles
def read_app_args(appid_versionCode_pairs, allapps, allow_vercodes=False):
"""Build a list of App instances for processing
On top of what read_pkg_args does, this returns the whole app
metadata, but limiting the builds list to the builds matching the
appid_versionCode_pairs and vercodes specified. If no appid_versionCode_pairs are specified, then
all App and Build instances are returned.
appid_versionCode_pairs and vercodes specified. If no
appid_versionCode_pairs are specified, then all App and Build instances are
returned.
"""

View File

@ -68,6 +68,7 @@ def main():
if options.appid:
vercodes = common.read_pkg_args(options.appid, True)
common.get_metadata_files(vercodes) # only check appids
apks = {appid: None for appid in vercodes}
# Get the signed APK with the highest vercode

View File

@ -566,17 +566,7 @@ def read_metadata(appids={}, sort_by_time=False):
if appids:
vercodes = fdroidserver.common.read_pkg_args(appids)
found_invalid = False
metadatafiles = []
for appid in vercodes.keys():
f = os.path.join('metadata', '%s.yml' % appid)
if os.path.exists(f):
metadatafiles.append(f)
else:
found_invalid = True
logging.critical(_("No such package: %s") % appid)
if found_invalid:
raise FDroidException(_("Found invalid appids in arguments"))
metadatafiles = fdroidserver.common.get_metadata_files(vercodes)
else:
metadatafiles = (glob.glob(os.path.join('metadata', '*.yml'))
+ glob.glob('.fdroid.yml'))

View File

@ -268,6 +268,7 @@ def main():
allapps = metadata.read_metadata()
vercodes = common.read_pkg_args(options.appid, True)
common.get_metadata_files(vercodes) # only check appids
signed_apks = dict()
generated_keys = dict()
allaliases = check_for_key_collisions(allapps)

View File

@ -188,6 +188,7 @@ def main():
logging.error(_("No unsigned directory - nothing to do"))
sys.exit(0)
processed = set()
verified = 0
notverified = 0
@ -204,6 +205,8 @@ def main():
if vercodes[appid] and vercode not in vercodes[appid]:
continue
processed.add(appid)
try:
logging.info("Processing {apkfilename}".format(apkfilename=apkfilename))
@ -236,6 +239,12 @@ def main():
logging.info("...NOT verified - {0}".format(e))
notverified += 1
for appid in options.appid:
package = appid.split(":")[0]
if package not in processed:
logging.critical(_("No APK for package: %s") % package)
notverified += 1
if verified > 0:
logging.info("{0} successfully verified".format(verified))
if notverified > 0: