Skip to content

Commit

Permalink
Merge pull request #1729 from YunoHost/extras_packages_from_raw_bash
Browse files Browse the repository at this point in the history
Support packages_from_raw_bash in extra packages
  • Loading branch information
alexAubin authored Oct 30, 2023
2 parents 24cb534 + 662998a commit 157f8c8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,6 @@ class AptDependenciesAppResource(AppResource):
packages: List = []
packages_from_raw_bash: str = ""
extras: Dict[str, Dict[str, Union[str, List]]] = {}

def __init__(self, properties: Dict[str, Any], *args, **kwargs):
super().__init__(properties, *args, **kwargs)

Expand All @@ -1106,15 +1105,27 @@ def __init__(self, properties: Dict[str, Any], *args, **kwargs):
if isinstance(values.get("packages"), str):
values["packages"] = [value.strip() for value in values["packages"].split(",")] # type: ignore

if isinstance(values.get("packages_from_raw_bash"), str):
out, err = self.check_output_bash_snippet(values.get("packages_from_raw_bash"))
if err:
logger.error(
f"Error while running apt resource packages_from_raw_bash snippet for '{key}' extras:"
)
logger.error(err)
values["packages"] = values.get("packages", []) + [value.strip() for value in out.split("\n")]

if (
not isinstance(values.get("repo"), str)
or not isinstance(values.get("key"), str)
or not isinstance(values.get("packages"), list)
):
raise YunohostError(
"In apt resource in the manifest: 'extras' repo should have the keys 'repo', 'key' defined as strings and 'packages' defined as list",
"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 157f8c8

Please sign in to comment.