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

Containerless tools #74

Merged
merged 1 commit into from
Dec 18, 2023
Merged
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
3 changes: 3 additions & 0 deletions xbstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -77,6 +79,7 @@ def do_runtool(args):
tool_pkgs=tool_pkgs,
workdir=workdir,
for_package=for_package,
containerless=has_containerless,
)


Expand Down
39 changes: 34 additions & 5 deletions xbstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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"]:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions xbstrap/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
Loading