feat: add support for post-stages
This commit is contained in:
parent
346d411d52
commit
8e7e5cb576
2 changed files with 31 additions and 25 deletions
|
|
@ -22,7 +22,7 @@ def gen_rootfs(system_config: dict, rootfs_path: str) -> RootFS:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["bash", "-s"],
|
["bash", "-s"],
|
||||||
text=True,
|
text=True,
|
||||||
input=system_config["distro-config"]["before-stages"],
|
input=system_config["distro-config"]["initialise"],
|
||||||
cwd=rootfs_path,
|
cwd=rootfs_path,
|
||||||
env=os.environ.copy() | system_config["env"],
|
env=os.environ.copy() | system_config["env"],
|
||||||
).returncode
|
).returncode
|
||||||
|
|
@ -33,12 +33,10 @@ def gen_rootfs(system_config: dict, rootfs_path: str) -> RootFS:
|
||||||
|
|
||||||
modules = {}
|
modules = {}
|
||||||
|
|
||||||
if isinstance(system_config.get("modules"), list):
|
|
||||||
for module in system_config["modules"]:
|
for module in system_config["modules"]:
|
||||||
modules[module["name"]] = module["run"]
|
modules[module["name"]] = module["run"]
|
||||||
|
|
||||||
if isinstance(system_config.get("stages"), list):
|
for stage in system_config["stages"] + system_config["post-stages"]:
|
||||||
for stage in system_config["stages"]:
|
|
||||||
if stage.get("module") not in modules.keys():
|
if stage.get("module") not in modules.keys():
|
||||||
output.error(f"{stage.get('module')} not found within module list.")
|
output.error(f"{stage.get('module')} not found within module list.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
@ -46,12 +44,11 @@ def gen_rootfs(system_config: dict, rootfs_path: str) -> RootFS:
|
||||||
inputs = stage["inputs"] if isinstance(stage.get("inputs"), list) else []
|
inputs = stage["inputs"] if isinstance(stage.get("inputs"), list) else []
|
||||||
run_script_rootfs(rootfs, modules[stage["module"]], inputs)
|
run_script_rootfs(rootfs, modules[stage["module"]], inputs)
|
||||||
|
|
||||||
if isinstance(system_config["distro-config"].get("after-stages"), str):
|
|
||||||
if (
|
if (
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["bash", "-s"],
|
["bash", "-s"],
|
||||||
text=True,
|
text=True,
|
||||||
input=system_config["distro-config"]["after-stages"],
|
input=system_config["distro-config"]["finalise"],
|
||||||
cwd=str(rootfs_path),
|
cwd=str(rootfs_path),
|
||||||
env=os.environ.copy() | system_config["env"],
|
env=os.environ.copy() | system_config["env"],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ def resolve_config(system_config: dict) -> dict:
|
||||||
"stages": system_config["stages"]
|
"stages": system_config["stages"]
|
||||||
if isinstance(system_config.get("stages"), list)
|
if isinstance(system_config.get("stages"), list)
|
||||||
else [],
|
else [],
|
||||||
|
"post-stages": system_config["post-stages"]
|
||||||
|
if isinstance(system_config.get("post-stages"), list)
|
||||||
|
else [],
|
||||||
"override": system_config["override"]
|
"override": system_config["override"]
|
||||||
if isinstance(system_config.get("override"), list)
|
if isinstance(system_config.get("override"), list)
|
||||||
else [],
|
else [],
|
||||||
|
|
@ -63,6 +66,12 @@ def resolve_config(system_config: dict) -> dict:
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
|
|
||||||
|
base_config["post-stages"] = (
|
||||||
|
system_config["post-stages"]
|
||||||
|
if isinstance(system_config.get("post-stages"), list)
|
||||||
|
else []
|
||||||
|
) + base_config["post-stages"]
|
||||||
|
|
||||||
base_config["override"] += (
|
base_config["override"] += (
|
||||||
system_config["override"]
|
system_config["override"]
|
||||||
if isinstance(system_config.get("override"), list)
|
if isinstance(system_config.get("override"), list)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue