mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 07:22:29 +03:00
check for invalid appids passed to commands
This commit is contained in:
parent
380f3b2e9f
commit
3e557a1a8a
5 changed files with 36 additions and 13 deletions
|
@ -618,13 +618,35 @@ def read_pkg_args(appid_versionCode_pairs, allow_vercodes=False):
|
||||||
return vercodes
|
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):
|
def read_app_args(appid_versionCode_pairs, allapps, allow_vercodes=False):
|
||||||
"""Build a list of App instances for processing
|
"""Build a list of App instances for processing
|
||||||
|
|
||||||
On top of what read_pkg_args does, this returns the whole app
|
On top of what read_pkg_args does, this returns the whole app
|
||||||
metadata, but limiting the builds list to the builds matching the
|
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
|
appid_versionCode_pairs and vercodes specified. If no
|
||||||
all App and Build instances are returned.
|
appid_versionCode_pairs are specified, then all App and Build instances are
|
||||||
|
returned.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ def main():
|
||||||
if options.appid:
|
if options.appid:
|
||||||
|
|
||||||
vercodes = common.read_pkg_args(options.appid, True)
|
vercodes = common.read_pkg_args(options.appid, True)
|
||||||
|
common.get_metadata_files(vercodes) # only check appids
|
||||||
apks = {appid: None for appid in vercodes}
|
apks = {appid: None for appid in vercodes}
|
||||||
|
|
||||||
# Get the signed APK with the highest vercode
|
# Get the signed APK with the highest vercode
|
||||||
|
|
|
@ -566,17 +566,7 @@ def read_metadata(appids={}, sort_by_time=False):
|
||||||
|
|
||||||
if appids:
|
if appids:
|
||||||
vercodes = fdroidserver.common.read_pkg_args(appids)
|
vercodes = fdroidserver.common.read_pkg_args(appids)
|
||||||
found_invalid = False
|
metadatafiles = fdroidserver.common.get_metadata_files(vercodes)
|
||||||
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"))
|
|
||||||
else:
|
else:
|
||||||
metadatafiles = (glob.glob(os.path.join('metadata', '*.yml'))
|
metadatafiles = (glob.glob(os.path.join('metadata', '*.yml'))
|
||||||
+ glob.glob('.fdroid.yml'))
|
+ glob.glob('.fdroid.yml'))
|
||||||
|
|
|
@ -268,6 +268,7 @@ def main():
|
||||||
|
|
||||||
allapps = metadata.read_metadata()
|
allapps = metadata.read_metadata()
|
||||||
vercodes = common.read_pkg_args(options.appid, True)
|
vercodes = common.read_pkg_args(options.appid, True)
|
||||||
|
common.get_metadata_files(vercodes) # only check appids
|
||||||
signed_apks = dict()
|
signed_apks = dict()
|
||||||
generated_keys = dict()
|
generated_keys = dict()
|
||||||
allaliases = check_for_key_collisions(allapps)
|
allaliases = check_for_key_collisions(allapps)
|
||||||
|
|
|
@ -188,6 +188,7 @@ def main():
|
||||||
logging.error(_("No unsigned directory - nothing to do"))
|
logging.error(_("No unsigned directory - nothing to do"))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
processed = set()
|
||||||
verified = 0
|
verified = 0
|
||||||
notverified = 0
|
notverified = 0
|
||||||
|
|
||||||
|
@ -204,6 +205,8 @@ def main():
|
||||||
if vercodes[appid] and vercode not in vercodes[appid]:
|
if vercodes[appid] and vercode not in vercodes[appid]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
processed.add(appid)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
logging.info("Processing {apkfilename}".format(apkfilename=apkfilename))
|
logging.info("Processing {apkfilename}".format(apkfilename=apkfilename))
|
||||||
|
@ -236,6 +239,12 @@ def main():
|
||||||
logging.info("...NOT verified - {0}".format(e))
|
logging.info("...NOT verified - {0}".format(e))
|
||||||
notverified += 1
|
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:
|
if verified > 0:
|
||||||
logging.info("{0} successfully verified".format(verified))
|
logging.info("{0} successfully verified".format(verified))
|
||||||
if notverified > 0:
|
if notverified > 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue