diff --git a/usr/lib/akshara/utils/helpers.py b/usr/lib/akshara/utils/helpers.py index 93e903f..779ceca 100644 --- a/usr/lib/akshara/utils/helpers.py +++ b/usr/lib/akshara/utils/helpers.py @@ -22,6 +22,9 @@ def resolve_config(system_config: dict) -> dict: "override": system_config["override"] if isinstance(system_config.get("override"), list) else [], + "needs-update": system_config["needs-update"] + if isinstance(system_config.get("needs-update"), list) + else [], "env": system_config["env"] if isinstance(system_config.get("env"), dict) else {}, @@ -66,6 +69,12 @@ def resolve_config(system_config: dict) -> dict: else [] ) + base_config["needs-update"] += ( + system_config["needs-update"] + if isinstance(system_config.get("needs-update"), list) + else [] + ) + base_config["env"] = ( base_config["env"] | system_config["env"] if isinstance(system_config.get("env"), dict) @@ -113,18 +122,22 @@ def is_already_latest() -> bool: json.dumps(system_config, ensure_ascii=False).strip() == contents.strip() ): - if isinstance(system_config["distro-config"].get("should-update"), str): - return ( + if len(system_config["distro-config"]["needs-update"]) == 0: + return False + + for update_check in system_config["distro-config"]["needs-update"]: + if ( subprocess.run( ["bash", "-s"], text=True, - input=system_config["distro-config"]["should-update"], + input=update_check, env=os.environ.copy() | system_config["env"], ).returncode - != 0 - ) - else: - return True + == 0 + ): + return False + + return True else: return False else: