feat: move update checks to general config
This commit is contained in:
parent
5ec321bcb0
commit
346d411d52
1 changed files with 20 additions and 7 deletions
|
|
@ -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,17 +122,21 @@ 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:
|
||||
== 0
|
||||
):
|
||||
return False
|
||||
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue