Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: allow to define additional configs #728

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions asu/apply_config_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

for config in $(grep '#' /builder/.config_local | awk '{print $2}'); do sed -i 's/'${config}'.*//' /builder/.config ; done;

cat /builder/.config_local >> /builder/.config
48 changes: 48 additions & 0 deletions asu/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,54 @@ def build(req: dict, job=None):
},
)

if "configs" in req:
log.debug("Found extra configs")
configs = ""
for config in req.get("configs"):
configs += f"{config}\n"

(store_path / bin_dir / ".config_local").write_text(configs)

mounts.append(
{
"type": "bind",
"source": str(store_path / bin_dir / ".config_local"),
"target": "/builder/.config_local",
"read_only": True,
}
)
mounts.append(
{
"type": "bind",
"source": str(store_path / "../../asu/apply_config_local.sh"),
"target": "/builder/apply_config_local.sh",
"read_only": True,
},
)

returncode, job.meta["stdout"], job.meta["stderr"] = run_container(
podman,
image,
[
"/bin/sh",
"-c",
(
"/builder/apply_config_local.sh"
),
],
mounts=mounts,
copy=["/builder/.config", store_path / bin_dir ],
)

mounts.append(
{
"type": "bind",
"source": str(store_path / bin_dir / ".config"),
"target": "/builder/.config",
"read_only": True,
},
)

returncode, job.meta["stdout"], job.meta["stderr"] = run_container(
podman,
image,
Expand Down
11 changes: 11 additions & 0 deletions asu/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def get_request_hash(req: dict) -> str:
req.get("profile", "").replace(",", "_"),
get_packages_hash(req.get("packages", [])),
get_manifest_hash(req.get("packages_versions", {})),
get_configs_hash(req.get("configs", [])),
str(req.get("diff_packages", False)),
req.get("filesystem", ""),
get_str_hash(req.get("defaults", "")),
Expand All @@ -154,6 +155,16 @@ def get_packages_hash(packages: list) -> str:
"""
return get_str_hash(" ".join(sorted(list(set(packages)))), 12)

def get_configs_hash(configs: list) -> str:
"""Return sha256sum of configs list
Duplicate configs are automatically removed and the list is sorted to be
reproducible
Args:
configs (list): list of configs
Returns:
str: hash of `req`
"""
return get_str_hash(" ".join(sorted(list(set(configs)))), 12)

def fingerprint_pubkey_usign(pubkey: str) -> str:
"""Return fingerprint of signify/usign public key
Expand Down
12 changes: 12 additions & 0 deletions asu/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,18 @@ components:
profile:
type: string
example: 8dev_carambola2
configs:
type: array
example:
- CONFIG_VERSION_DIST=MyRouterOS
- CONFIG_VERSION_NUMBER=1.6
- CONFIG_TARGET_ROOTFS_TARGZ=y
- CONFIG_TARGET_ROOTFS_JFFS2=y
- "# CONFIG_TARGET_ROOTFS_SQUASHFS is not set"
items:
type: string
description: |
List of configs, only the few ones not related to kernel/packages as they will not be recompiled.
diff_packages:
type: boolean
description: |
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,4 @@ def test_api_build_defaults_filled_allowed(app):
)

assert response.status == "200 OK"
assert response.json.get("request_hash") == "0e4cbc84b22e7cbf885102248cc9c965"
assert response.json.get("request_hash") == "bbb1466d022881e53030751402b77e86"
Loading