Skip to content

Commit

Permalink
build: use new imagebuilder setup.sh for appropriate versions
Browse files Browse the repository at this point in the history
Properly detect versions for which the slim imagebuilder containers using
setup.sh is being used.  Set up the container accordingly.

Signed-off-by: Eric Fahlgren <[email protected]>
  • Loading branch information
efahl authored and aparcar committed Dec 5, 2024
1 parent fe97d0a commit 28a1629
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
7 changes: 5 additions & 2 deletions asu/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
get_podman,
get_request_hash,
parse_manifest,
is_snapshot_build,
report_error,
run_cmd,
)
Expand Down Expand Up @@ -164,11 +165,13 @@ def build(build_request: BuildRequest, job=None):
)
container.start()

if build_request.version.lower().endswith("snapshot"):
log.debug("Setting up ImageBuilder")
if is_snapshot_build(build_request.version):
log.info("Running setup.sh for ImageBuilder")
returncode, job.meta["stdout"], job.meta["stderr"] = run_cmd(
container, ["sh", "setup.sh"]
)
if returncode:
report_error(job, "Could not set up ImageBuilder")

returncode, job.meta["stdout"], job.meta["stderr"] = run_cmd(
container, ["make", "info"]
Expand Down
7 changes: 6 additions & 1 deletion asu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ def parse_feeds_conf(url: str) -> list[str]:
)


def is_snapshot_build(version: str) -> bool:
"""For imagebuilder containers using 'setup.sh' instead of fully populated."""
return version.lower().endswith("snapshot")


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
Expand All @@ -381,7 +386,7 @@ def is_post_kmod_split_build(path: str) -> bool:
if path.startswith("snapshots"):
return True

version = path.split("/")[1]
version: str = path.split("/")[1]
if version.startswith("24."):
return True
if version.startswith("23."):
Expand Down
25 changes: 23 additions & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
get_podman,
get_request_hash,
get_str_hash,
is_post_kmod_split_build,
parse_feeds_conf,
parse_kernel_version,
parse_manifest,
parse_packages_file,
parse_kernel_version,
is_post_kmod_split_build,
is_snapshot_build,
run_cmd,
verify_usign,
)
Expand Down Expand Up @@ -196,6 +197,26 @@ def test_check_kmod_split():
assert result == expected


def test_check_snapshot_versions():
cases = {
"22.07.3": False,
"23.05.0-rc3": False,
"23.05.2": False,
"23.05.5": False,
"23.05.6": False,
"23.05-SNAPSHOT": True,
"24.10.0-rc1": False,
"24.10.2": False,
"24.10-SNAPSHOT": True,
"SNAPSHOT": True,
}

for version, expected in cases.items():
result: bool = is_snapshot_build(version)
print(version, expected, result)
assert result == expected


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

0 comments on commit 28a1629

Please sign in to comment.