Skip to content

Commit

Permalink
Fixed issues when adding modules to missing build key
Browse files Browse the repository at this point in the history
"build" key is only required for the "policy-set" type.
However, we still want users to be able to use the "build"
key and "cfbs build" in all projects, so we need to add the
key for them when necessary, and account for the fact that
the key might be missing.

Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
  • Loading branch information
olehermanse committed Jan 8, 2024
1 parent e67b3bf commit c43c23f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cfbs/cfbs_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def add_with_dependencies(self, module, remote_config=None, dependent=None):
if "dependencies" in module:
for dep in module["dependencies"]:
self.add_with_dependencies(dep, remote_config, module["name"])
if "build" not in self._data:
self._data["build"] = []
self._data["build"].append(module)
if dependent:
print("Added module: %s (Dependency of %s)" % (module["name"], dependent))
Expand Down Expand Up @@ -351,7 +353,7 @@ def add_command(
if not to_add:
user_error("Must specify at least one module to add")

before = {m["name"] for m in self["build"]}
before = {m["name"] for m in self.get("build", [])}

if to_add[0].endswith(SUPPORTED_ARCHIVES) or to_add[0].startswith(
("https://", "git://", "ssh://")
Expand Down
2 changes: 1 addition & 1 deletion cfbs/cfbs_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_module_for_build(self, name, dependent):
return None

def _module_is_in_build(self, module):
return module["name"] in (m["name"] for m in self["build"])
return "build" in self and module["name"] in (m["name"] for m in self["build"])

def get_module_from_build(self, module):
for m in self["build"]:
Expand Down

0 comments on commit c43c23f

Please sign in to comment.