Skip to content

Commit

Permalink
build: allow to define additional configs
Browse files Browse the repository at this point in the history
  • Loading branch information
a-gave committed Feb 3, 2024
1 parent 287b967 commit 3ef4de3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
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 @@ -152,6 +152,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 @@ -116,6 +116,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 @@ -142,6 +143,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 @@ -216,6 +216,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

0 comments on commit 3ef4de3

Please sign in to comment.