mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-15 03:20:10 +01:00
throw error when CLI appid args end with a : but no Version Code
This is already the behavior in read_app_args(), but wasn't implemented in read_pkg_args() yet.
This commit is contained in:
parent
21e91564a0
commit
0d5c7516f2
@ -868,13 +868,13 @@ def get_local_metadata_files():
|
|||||||
return glob.glob('.fdroid.[a-jl-z]*[a-rt-z]')
|
return glob.glob('.fdroid.[a-jl-z]*[a-rt-z]')
|
||||||
|
|
||||||
|
|
||||||
def read_pkg_args(appid_versionCode_pairs, allow_vercodes=False):
|
def read_pkg_args(appid_versionCode_pairs, allow_version_codes=False):
|
||||||
"""No summary.
|
"""No summary.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
appids
|
appids
|
||||||
arguments in the form of multiple appid:[vc] strings
|
arguments in the form of multiple appid:[versionCode] strings
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -884,13 +884,18 @@ def read_pkg_args(appid_versionCode_pairs, allow_vercodes=False):
|
|||||||
if not appid_versionCode_pairs:
|
if not appid_versionCode_pairs:
|
||||||
return vercodes
|
return vercodes
|
||||||
|
|
||||||
|
error = False
|
||||||
apk_regex = re.compile(r'_(\d+)\.apk$')
|
apk_regex = re.compile(r'_(\d+)\.apk$')
|
||||||
for p in appid_versionCode_pairs:
|
for p in appid_versionCode_pairs:
|
||||||
# Convert the apk name to a appid:versioncode pair
|
# Convert the apk name to a appid:versioncode pair
|
||||||
p = apk_regex.sub(r':\1', p)
|
p = apk_regex.sub(r':\1', p)
|
||||||
if allow_vercodes and ':' in p:
|
if allow_version_codes and ':' in p:
|
||||||
package, vercode = p.split(':')
|
package, vercode = p.split(':')
|
||||||
|
try:
|
||||||
vercode = version_code_string_to_int(vercode)
|
vercode = version_code_string_to_int(vercode)
|
||||||
|
except ValueError as e:
|
||||||
|
logging.error('"%s": %s' % (p, str(e)))
|
||||||
|
error = True
|
||||||
else:
|
else:
|
||||||
package, vercode = p, None
|
package, vercode = p, None
|
||||||
if package not in vercodes:
|
if package not in vercodes:
|
||||||
@ -899,6 +904,9 @@ def read_pkg_args(appid_versionCode_pairs, allow_vercodes=False):
|
|||||||
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 []
|
||||||
|
|
||||||
|
if error:
|
||||||
|
raise FDroidException(_("Found invalid versionCodes for some apps"))
|
||||||
|
|
||||||
return vercodes
|
return vercodes
|
||||||
|
|
||||||
|
|
||||||
@ -930,7 +938,7 @@ def get_metadata_files(vercodes):
|
|||||||
return metadatafiles
|
return metadatafiles
|
||||||
|
|
||||||
|
|
||||||
def read_app_args(appid_versionCode_pairs, allapps, allow_vercodes=False):
|
def read_app_args(appid_versionCode_pairs, allapps, allow_version_codes=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
|
||||||
@ -940,7 +948,7 @@ def read_app_args(appid_versionCode_pairs, allapps, allow_vercodes=False):
|
|||||||
returned.
|
returned.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
vercodes = read_pkg_args(appid_versionCode_pairs, allow_vercodes)
|
vercodes = read_pkg_args(appid_versionCode_pairs, allow_version_codes)
|
||||||
|
|
||||||
if not vercodes:
|
if not vercodes:
|
||||||
return allapps
|
return allapps
|
||||||
|
@ -2321,6 +2321,13 @@ class CommonTest(unittest.TestCase):
|
|||||||
fdroidserver.common.read_pkg_args(appid_versionCode_pairs, allow_vercodes),
|
fdroidserver.common.read_pkg_args(appid_versionCode_pairs, allow_vercodes),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_read_pkg_args_errors(self):
|
||||||
|
allow_vercodes = True
|
||||||
|
with self.assertRaises(FDroidException):
|
||||||
|
fdroidserver.common.read_pkg_args(['org.fdroid.fdroid:'], allow_vercodes),
|
||||||
|
with self.assertRaises(FDroidException):
|
||||||
|
fdroidserver.common.read_pkg_args(['org.fdroid.fdroid:foo'], allow_vercodes),
|
||||||
|
|
||||||
def test_apk_strip_v1_signatures(self):
|
def test_apk_strip_v1_signatures(self):
|
||||||
before = os.path.join(self.basedir, 'no_targetsdk_minsdk1_unsigned.apk')
|
before = os.path.join(self.basedir, 'no_targetsdk_minsdk1_unsigned.apk')
|
||||||
after = os.path.join(self.testdir, 'after.apk')
|
after = os.path.join(self.testdir, 'after.apk')
|
||||||
|
Loading…
Reference in New Issue
Block a user