fix: move /usr/etc and /usr/var creation to gen_rootfs
This commit is contained in:
parent
6a42abc503
commit
caed15d641
2 changed files with 20 additions and 20 deletions
|
|
@ -61,4 +61,24 @@ def gen_rootfs(system_config: dict, rootfs_path: str) -> RootFS:
|
|||
json.dump(system_config, system_json_file, ensure_ascii=False)
|
||||
pass
|
||||
|
||||
with open(
|
||||
os.path.join(str(rootfs), "usr/immutable.list"), "w"
|
||||
) as immutable_list_file:
|
||||
immutable_set = set(
|
||||
[
|
||||
override["path"]
|
||||
for override in system_config["override"]
|
||||
if isinstance(override.get("immutable"), bool) and override["immutable"]
|
||||
]
|
||||
if isinstance(system_config.get("override"), list)
|
||||
else {}
|
||||
)
|
||||
|
||||
immutable_set.add("/usr")
|
||||
|
||||
immutable_list_file.write("\n".join(list(immutable_set)))
|
||||
|
||||
subprocess.run(["cp", "-ax", f"{rootfs}/etc", f"{rootfs}/usr/etc"])
|
||||
subprocess.run(["cp", "-ax", f"{rootfs}/var", f"{rootfs}/usr/var"])
|
||||
|
||||
return rootfs
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ def merge_etc(new_rootfs: RootFS, overrides_keep_new: dict) -> None:
|
|||
new_rootfs: New RootFS instance.
|
||||
overrides_keep_new: Dictionary comprising overrides and whether to keep new.
|
||||
"""
|
||||
subprocess.run(["cp", "-ax", f"{new_rootfs}/etc", f"{new_rootfs}/usr/etc"])
|
||||
|
||||
if not os.path.isdir("/usr/etc"):
|
||||
subprocess.run(["rm", "-rf", "/usr/etc"])
|
||||
subprocess.run(["cp", "-ax", "/etc", "/usr/etc"])
|
||||
|
|
@ -102,7 +100,6 @@ def merge_var(new_rootfs: RootFS, overrides_keep_new: dict) -> None:
|
|||
new_rootfs: Path to rootfs.
|
||||
overrides_keep_new: Dictionary comprising overrides and whether to keep new.
|
||||
"""
|
||||
subprocess.run(["cp", "-ax", f"{new_rootfs}/var", f"{new_rootfs}/usr/var"])
|
||||
subprocess.run(["rm", "-rf", f"{new_rootfs}/var/lib"])
|
||||
subprocess.run(["cp", "-ax", "/var/lib", f"{new_rootfs}/var/lib"])
|
||||
|
||||
|
|
@ -329,23 +326,6 @@ def update() -> None:
|
|||
output.info("merging /var...")
|
||||
merge_var(new_rootfs, overrides_keep_new)
|
||||
|
||||
with open(
|
||||
os.path.join(str(new_rootfs), "usr/immutable.list"), "w"
|
||||
) as immutable_list_file:
|
||||
immutable_set = set(
|
||||
[
|
||||
override["path"]
|
||||
for override in system_config["override"]
|
||||
if isinstance(override.get("immutable"), bool) and override["immutable"]
|
||||
]
|
||||
if isinstance(system_config.get("override"), list)
|
||||
else {}
|
||||
)
|
||||
|
||||
immutable_set.add("/usr")
|
||||
|
||||
immutable_list_file.write("\n".join(list(immutable_set)))
|
||||
|
||||
subprocess.run(["cp", "-ax", str(new_rootfs), "/.update_rootfs"])
|
||||
|
||||
handle_boot(new_rootfs, system_config["boot"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue