Skip to content

Commit

Permalink
util: collect separate kmods index depending on version
Browse files Browse the repository at this point in the history
The builds for 23.05-SNAPSHOT and 23.05.6-and-later also need to be included
in the kmod-split handling.

See discussion on the buildbot commit for details: openwrt/buildbot@a75ce026

Signed-off-by: Eric Fahlgren <[email protected]>
  • Loading branch information
efahl authored and aparcar committed Dec 1, 2024
1 parent 1da1678 commit 07ef08e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
3 changes: 2 additions & 1 deletion asu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
parse_feeds_conf,
parse_packages_file,
parse_kernel_version,
is_post_kmod_split_build,
)

logging.basicConfig(encoding="utf-8", level=settings.log_level)
Expand Down Expand Up @@ -81,7 +82,7 @@ def index(request: Request):
def json_v1_target_index(path: str) -> dict[str, str]:
base_path: str = f"{settings.upstream_url}/{path}"
base_packages: dict[str, str] = parse_packages_file(f"{base_path}/packages")
if path.startswith(("snapshots", "releases/24")):
if is_post_kmod_split_build(path):
kmods_directory: str = parse_kernel_version(f"{base_path}/profiles.json")
if kmods_directory:
kmod_packages: dict[str, str] = parse_packages_file(
Expand Down
30 changes: 30 additions & 0 deletions asu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,36 @@ def parse_feeds_conf(url: str) -> list[str]:
)


def is_post_kmod_split_build(path: str) -> bool:
"""Root cause of what's going on here can be found at
https://github.com/openwrt/buildbot/commit/a75ce026
The short version is that kmods are no longer in the packages/index.json
for the versions listed below, so we need to find 'linux_kernel' in the
profiles.json and do some extra work.
Versions for which kmods are in 'kmods/<kernel-version>/index.json' and not
in 'packages/index.json':
- SNAPSHOT
- all of 24.10 and later
- 23.05 builds for 23.05-SNAPSHOT, and 23.05.6 and later
"""

if path.startswith("snapshots"):
return True

version = path.split("/")[1]
if version.startswith("24."):
return True
if version.startswith("23."):
minor_version = version.split(".")[-1]
if minor_version == "05-SNAPSHOT" or minor_version >= "6":
return True

return False


def parse_kernel_version(url: str) -> str:
"""Download a target's profiles.json and return the kernel version string."""
res: httpx.Response = httpx.get(url)
Expand Down
46 changes: 46 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
parse_feeds_conf,
parse_manifest,
parse_packages_file,
parse_kernel_version,
is_post_kmod_split_build,
run_cmd,
verify_usign,
)
Expand Down Expand Up @@ -139,6 +141,50 @@ class Response:
assert index == {}


def test_get_kernel_version(monkeypatch):
class Response:
status_code = 200

json_data = {
"linux_kernel": {
"release": "1",
"vermagic": "ed1b0ea64b60bcea5dd4112f33d0dcbe",
"version": "6.6.63",
},
}

def json(self):
return Response.json_data

monkeypatch.setattr(httpx, "get", lambda url: Response())

version = parse_kernel_version("httpx://fake_url")
assert version == "6.6.63-1-ed1b0ea64b60bcea5dd4112f33d0dcbe"

Response.json_data = {}
version = parse_kernel_version("httpx://fake_url")
assert version == ""


def test_check_kmod_split():
cases = {
"releases/22.07.3/targets/x86/64": False,
"releases/23.05.0-rc3/targets/x86/64": False,
"releases/23.05.2/targets/x86/64": False,
"releases/23.05.5/targets/x86/64": False,
"releases/23.05.6/targets/x86/64": True,
"releases/23.05-SNAPSHOT/targets/x86/64": True,
"releases/24.10.0-rc1/targets/x86/64": True,
"releases/24.10.2/targets/x86/64": True,
"releases/24.10-SNAPSHOT/targets/x86/64": True,
"snapshots/targets/x86/64": True,
}

for path, expected in cases.items():
result: bool = is_post_kmod_split_build(path)
assert result == expected


def test_get_feeds(monkeypatch):
class Response:
status_code = 200
Expand Down

0 comments on commit 07ef08e

Please sign in to comment.