From 1bc527fe379f6dc36887cb9bb5a537cb1d6e997f Mon Sep 17 00:00:00 2001 From: no92 Date: Wed, 9 Aug 2023 01:16:30 +0200 Subject: [PATCH] base: implement the containerless property for tools Co-authored-by: Fedor Lapshin --- xbstrap/__init__.py | 3 +++ xbstrap/base.py | 39 ++++++++++++++++++++++++++++++++++----- xbstrap/schema.yml | 2 ++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/xbstrap/__init__.py b/xbstrap/__init__.py index 3af3c3c..34179eb 100755 --- a/xbstrap/__init__.py +++ b/xbstrap/__init__.py @@ -69,6 +69,8 @@ def do_runtool(args): for name in tools: tool_pkgs.append(cfg.get_tool_pkg(name)) + has_containerless = any(x.containerless for x in tool_pkgs) + xbstrap.base.run_program( cfg, context, @@ -77,6 +79,7 @@ def do_runtool(args): tool_pkgs=tool_pkgs, workdir=workdir, for_package=for_package, + containerless=has_containerless, ) diff --git a/xbstrap/base.py b/xbstrap/base.py index db4c578..81a8c8b 100644 --- a/xbstrap/base.py +++ b/xbstrap/base.py @@ -553,8 +553,9 @@ def get_target_pkg(self, name): class ScriptStep: - def __init__(self, step_yml): + def __init__(self, step_yml, containerless=False): self._step_yml = step_yml + self._containerless = containerless @property def args(self): @@ -574,7 +575,7 @@ def workdir(self): @property def containerless(self): - return self._step_yml.get("containerless", False) + return self._step_yml.get("containerless", False) or self._containerless @property def quiet(self): @@ -999,10 +1000,10 @@ def __init__(self, cfg, pkg, inherited, stage_yml): if "compile" in self._this_yml: for step_yml in self._this_yml["compile"]: - self._compile_steps.append(ScriptStep(step_yml)) + self._compile_steps.append(ScriptStep(step_yml, pkg.containerless)) if "install" in self._this_yml: for step_yml in self._this_yml["install"]: - self._install_steps.append(ScriptStep(step_yml)) + self._install_steps.append(ScriptStep(step_yml, pkg.containerless)) @property def pkg(self): @@ -1022,6 +1023,12 @@ def subject_id(self): def subject_type(self): return "tool stage" + @property + def containerless(self): + if "containerless" not in self._this_yml: + return False + return self._this_yml["containerless"] + @property def compile_steps(self): yield from self._compile_steps @@ -1091,7 +1098,7 @@ def __init__(self, cfg, pkg_yml): if "configure" in self._this_yml: for step_yml in self._this_yml["configure"]: - self._configure_steps.append(ScriptStep(step_yml)) + self._configure_steps.append(ScriptStep(step_yml, self.containerless)) if "tasks" in self._this_yml: for task_yml in self._this_yml["tasks"]: @@ -1115,6 +1122,12 @@ def exports_aclocal(self): return False return self._this_yml["exports_aclocal"] + @property + def containerless(self): + if "containerless" not in self._this_yml: + return False + return self._this_yml["containerless"] + @property def source(self): if "from_source" in self._this_yml: @@ -1726,6 +1739,16 @@ def run_program( ): pkg_queue = [] pkg_visited = set() + tools_all_containerless = ( + all(x.containerless for x in tool_pkgs) if tool_pkgs else containerless + ) + + tools_some_containerless = ( + any(x.containerless for x in tool_pkgs) if tool_pkgs else containerless + ) + + if tools_some_containerless is not tools_all_containerless: + raise GenericError("mixing containerless with non-containerless tools is not supported") for pkg in tool_pkgs: assert pkg.name not in pkg_visited @@ -1817,6 +1840,12 @@ def run_program( if runtime is None: use_container = False + if tools_all_containerless and use_container: + raise GenericError("running containerless is not allowed by your configuration") + + if containerless is not tools_all_containerless: + raise GenericError("containerless steps can only use containerless tools") + if use_container: if runtime == "dummy": manifest["source_root"] = cfg.source_root diff --git a/xbstrap/schema.yml b/xbstrap/schema.yml index 7b02c6c..0fd1280 100644 --- a/xbstrap/schema.yml +++ b/xbstrap/schema.yml @@ -278,6 +278,8 @@ properties: type: boolean 'exports_shared_libs': type: boolean + 'containerless': + type: boolean 'architecture': { type: string } 'configure': { $ref: '#/definitions/build_steps' } 'compile': { $ref: '#/definitions/build_steps' }