meta: ability to specify capabilities for stages
Add new stage metadata `CAPABILITIES` where stages can request additional capabilities that are not in the default set. Currently this is not used by any stage since the default set contains the sum of all needed capabilities.
This commit is contained in:
parent
bdcc9ea218
commit
d14e5f3ee8
2 changed files with 15 additions and 3 deletions
|
|
@ -296,6 +296,7 @@ class ModuleInfo:
|
||||||
self.info = info["info"]
|
self.info = info["info"]
|
||||||
self.desc = info["desc"]
|
self.desc = info["desc"]
|
||||||
self.opts = info["schema"]
|
self.opts = info["schema"]
|
||||||
|
self.caps = info["caps"]
|
||||||
|
|
||||||
def _load_opts(self, version, fallback=None):
|
def _load_opts(self, version, fallback=None):
|
||||||
raw = self.opts[version]
|
raw = self.opts[version]
|
||||||
|
|
@ -388,9 +389,16 @@ class ModuleInfo:
|
||||||
detail = fullname, lineno, e.colno, line
|
detail = fullname, lineno, e.colno, line
|
||||||
raise SyntaxError(msg, detail) from None
|
raise SyntaxError(msg, detail) from None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _parse_caps(cls, _klass, _name, node):
|
||||||
|
if not node:
|
||||||
|
return set()
|
||||||
|
|
||||||
|
return {e.s for e in node.value.elts}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, root, klass, name) -> Optional["ModuleInfo"]:
|
def load(cls, root, klass, name) -> Optional["ModuleInfo"]:
|
||||||
names = ["SCHEMA", "SCHEMA_2"]
|
names = ["SCHEMA", "SCHEMA_2", "CAPABILITIES"]
|
||||||
|
|
||||||
def filter_type(lst, target):
|
def filter_type(lst, target):
|
||||||
return [x for x in lst if isinstance(x, target)]
|
return [x for x in lst if isinstance(x, target)]
|
||||||
|
|
@ -425,13 +433,17 @@ class ModuleInfo:
|
||||||
def parse_schema(node):
|
def parse_schema(node):
|
||||||
return cls._parse_schema(klass, name, node)
|
return cls._parse_schema(klass, name, node)
|
||||||
|
|
||||||
|
def parse_caps(node):
|
||||||
|
return cls._parse_caps(klass, name, node)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'schema': {
|
'schema': {
|
||||||
"1": parse_schema(values.get("SCHEMA")),
|
"1": parse_schema(values.get("SCHEMA")),
|
||||||
"2": parse_schema(values.get("SCHEMA_2")),
|
"2": parse_schema(values.get("SCHEMA_2")),
|
||||||
},
|
},
|
||||||
'desc': doclist[0],
|
'desc': doclist[0],
|
||||||
'info': "\n".join(doclist[1:])
|
'info': "\n".join(doclist[1:]),
|
||||||
|
'caps': parse_caps(values.get("CAPABILITIES"))
|
||||||
}
|
}
|
||||||
return cls(klass, name, path, info)
|
return cls(klass, name, path, info)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ class Stage:
|
||||||
build_root.mount_boot = bool(self.build)
|
build_root.mount_boot = bool(self.build)
|
||||||
|
|
||||||
# drop capabilities other than `DEFAULT_CAPABILITIES`
|
# drop capabilities other than `DEFAULT_CAPABILITIES`
|
||||||
build_root.caps = DEFAULT_CAPABILITIES
|
build_root.caps = DEFAULT_CAPABILITIES | self.info.caps
|
||||||
|
|
||||||
tmpdir = store.tempdir(prefix="buildroot-tmp-")
|
tmpdir = store.tempdir(prefix="buildroot-tmp-")
|
||||||
tmpdir = cm.enter_context(tmpdir)
|
tmpdir = cm.enter_context(tmpdir)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue