Skip to content

Commit

Permalink
Improve support for packages_from_raw_bash
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandre Aubin <[email protected]>
  • Loading branch information
tituspijean and alexAubin authored Oct 15, 2023
1 parent 96e9945 commit a69b809
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,10 @@ def __init__(self, properties: Dict[str, Any], *args, **kwargs):
out, err = self.check_output_bash_snippet(values.get("packages_from_raw_bash"))
if err:
logger.error(
"Error while running apt resource packages_from_raw_bash snippet for '" + str(key) + "' extras:"
f"Error while running apt resource packages_from_raw_bash snippet for '{key}' extras:"
)
logger.error(err)
values["packages"] = [value.strip() for value in out.split("\n")]
values["packages"] = values.get("packages", []) + [value.strip() for value in out.split("\n")]

if (
not isinstance(values.get("repo"), str)
Expand All @@ -1126,6 +1126,9 @@ def __init__(self, properties: Dict[str, Any], *args, **kwargs):
"In apt resource in the manifest: 'extras' repo should have the keys 'repo', 'key' defined as strings, 'packages' defined as list or 'packages_from_raw_bash' defined as string",
raw_msg=True,
)

# Drop 'extras' entries associated to no packages
self.extras = {key: value for key, values in self.extras.items() if values["packages"]}

def provision_or_update(self, context: Dict = {}):
script = " ".join(["ynh_install_app_dependencies", *self.packages])
Expand Down

0 comments on commit a69b809

Please sign in to comment.