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"]
|
"override": system_config["override"]
|
||||||
if isinstance(system_config.get("override"), list)
|
if isinstance(system_config.get("override"), list)
|
||||||
else [],
|
else [],
|
||||||
|
"needs-update": system_config["needs-update"]
|
||||||
|
if isinstance(system_config.get("needs-update"), list)
|
||||||
|
else [],
|
||||||
"env": system_config["env"]
|
"env": system_config["env"]
|
||||||
if isinstance(system_config.get("env"), dict)
|
if isinstance(system_config.get("env"), dict)
|
||||||
else {},
|
else {},
|
||||||
|
|
@ -66,6 +69,12 @@ def resolve_config(system_config: dict) -> dict:
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
|
|
||||||
|
base_config["needs-update"] += (
|
||||||
|
system_config["needs-update"]
|
||||||
|
if isinstance(system_config.get("needs-update"), list)
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
|
||||||
base_config["env"] = (
|
base_config["env"] = (
|
||||||
base_config["env"] | system_config["env"]
|
base_config["env"] | system_config["env"]
|
||||||
if isinstance(system_config.get("env"), dict)
|
if isinstance(system_config.get("env"), dict)
|
||||||
|
|
@ -113,18 +122,22 @@ def is_already_latest() -> bool:
|
||||||
json.dumps(system_config, ensure_ascii=False).strip()
|
json.dumps(system_config, ensure_ascii=False).strip()
|
||||||
== contents.strip()
|
== contents.strip()
|
||||||
):
|
):
|
||||||
if isinstance(system_config["distro-config"].get("should-update"), str):
|
if len(system_config["distro-config"]["needs-update"]) == 0:
|
||||||
return (
|
return False
|
||||||
|
|
||||||
|
for update_check in system_config["distro-config"]["needs-update"]:
|
||||||
|
if (
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["bash", "-s"],
|
["bash", "-s"],
|
||||||
text=True,
|
text=True,
|
||||||
input=system_config["distro-config"]["should-update"],
|
input=update_check,
|
||||||
env=os.environ.copy() | system_config["env"],
|
env=os.environ.copy() | system_config["env"],
|
||||||
).returncode
|
).returncode
|
||||||
!= 0
|
== 0
|
||||||
)
|
):
|
||||||
else:
|
return False
|
||||||
return True
|
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue