diff --git a/usr/lib/akshara/utils/gen_rootfs.py b/usr/lib/akshara/utils/gen_rootfs.py index 289c7e1..918eef5 100644 --- a/usr/lib/akshara/utils/gen_rootfs.py +++ b/usr/lib/akshara/utils/gen_rootfs.py @@ -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 diff --git a/usr/lib/akshara/utils/update.py b/usr/lib/akshara/utils/update.py index 3737ae4..70f668d 100644 --- a/usr/lib/akshara/utils/update.py +++ b/usr/lib/akshara/utils/update.py @@ -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"])