diff --git a/xbstrap/__init__.py b/xbstrap/__init__.py index ef5c7d4..5169876 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 b94cba6..573b0ef 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 @@ -1086,12 +1093,15 @@ def __init__(self, cfg, pkg_yml): stage = HostStage(self._cfg, self, False, stage_yml) self._stages[stage.stage_name] = stage else: - stage = HostStage(self._cfg, self, True, self._this_yml) + step_yml = self._this_yml + if self.containerless: + step_yml["containerless"] = True + stage = HostStage(self._cfg, self, True, step_yml) self._stages[stage.stage_name] = stage 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 +1125,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 +1742,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 +1843,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' }