From 0a4995cd3b45d383525b52005248eb33e7081570 Mon Sep 17 00:00:00 2001 From: "Felix C. Stegerman" Date: Sat, 10 Apr 2021 07:18:28 +0000 Subject: [PATCH 1/2] read_pkg_args(): allow appid_vercode.apk in addition to appid:vercode --- fdroidserver/common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index f9ec11aa..45109513 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -599,7 +599,9 @@ def read_pkg_args(appid_versionCode_pairs, allow_vercodes=False): if not appid_versionCode_pairs: return vercodes + apk_regex = re.compile(r'_(\d+)\.apk$') for p in appid_versionCode_pairs: + p = apk_regex.sub(r':\1', p) if allow_vercodes and ':' in p: package, vercode = p.split(':') try: From cff575f4029d951c0703cdd4bf24d63dacd8fcca Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 12 Apr 2021 09:11:58 +0200 Subject: [PATCH 2/2] common: add test case for read_pkg_args() --- tests/common.TestCase | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/common.TestCase b/tests/common.TestCase index 37d2d7ad..e6316b7e 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -1712,6 +1712,48 @@ class CommonTest(unittest.TestCase): ) self.assertSequenceEqual(expected, sorted(components)) + def test_read_pkg_args(self): + allow_vercodes = False + self.assertEqual( + {'org.fdroid.fdroid': []}, + fdroidserver.common.read_pkg_args(['org.fdroid.fdroid'], allow_vercodes) + ) + self.assertNotEqual( + {'com.example': ['123456']}, + fdroidserver.common.read_pkg_args(['com.example:123456'], allow_vercodes) + ) + + allow_vercodes = True + self.assertEqual( + {'org.fdroid.fdroid': []}, + fdroidserver.common.read_pkg_args(['org.fdroid.fdroid'], allow_vercodes) + ) + self.assertEqual( + {'com.example': ['123456']}, + fdroidserver.common.read_pkg_args(['com.example:123456'], allow_vercodes) + ) + self.assertEqual( + {'org.debian_kit': ['6']}, + fdroidserver.common.read_pkg_args(['org.debian_kit_6.apk'], allow_vercodes) + ) + appid_versionCode_pairs = ( + 'org.fdroid.fdroid:1', + 'com.example:12345', + 'com.example:67890', + ) + self.assertEqual( + {'com.example': ['12345', '67890'], 'org.fdroid.fdroid': ['1']}, + fdroidserver.common.read_pkg_args(appid_versionCode_pairs, allow_vercodes) + ) + appid_versionCode_pairs = ( + 'com.example:67890', + 'org.c_base.c_beam_29.apk', + ) + self.assertEqual( + {'com.example': ['67890'], 'org.c_base.c_beam': ['29']}, + fdroidserver.common.read_pkg_args(appid_versionCode_pairs, allow_vercodes) + ) + if __name__ == "__main__": os.chdir(os.path.dirname(__file__))