Skip to content

Commit

Permalink
build: fix APK manifest parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Spooren <mail@aparcar.org>
  • Loading branch information
aparcar committed Nov 12, 2024
1 parent 606050f commit 16c9f98
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion asu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,12 @@ def parse_manifest(manifest_content: str) -> dict[str, str]:
Returns:
dict: Dictionary of packages and versions
"""
return dict(map(lambda pv: pv.split(" - "), manifest_content.splitlines()))
if " - " in manifest_content:
separator = " - " # OPKG format
else:
separator = " " # APK format

return dict(map(lambda pv: pv.split(separator), manifest_content.splitlines()))


def check_manifest(
Expand Down
25 changes: 25 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
get_request_hash,
get_str_hash,
parse_feeds_conf,
parse_manifest,
parse_packages_file,
run_cmd,
verify_usign,
Expand Down Expand Up @@ -193,3 +194,27 @@ def test_run_cmd():

assert returncode == 0
assert "testtarget/testsubtarget" in stdout


def test_parse_manifest_opkg():
manifest = parse_manifest(
"test - 1.0\n" "test2 - 2.0\n" "test3 - 3.0\n" "test4 - 3.0\n"
)

assert manifest == {
"test": "1.0",
"test2": "2.0",
"test3": "3.0",
"test4": "3.0",
}


def test_parse_manifest_apk():
manifest = parse_manifest("test 1.0\n" "test2 2.0\n" "test3 3.0\n" "test4 3.0\n")

assert manifest == {
"test": "1.0",
"test2": "2.0",
"test3": "3.0",
"test4": "3.0",
}

0 comments on commit 16c9f98

Please sign in to comment.