feat: handle custom immutable paths

This commit is contained in:
Rudra Saraswat 2026-04-03 19:14:57 +01:00
parent 8579f58f68
commit f17c272b65
2 changed files with 33 additions and 11 deletions

View file

@ -52,6 +52,7 @@ def merge_etc(new_rootfs: RootFS, overrides_keep_new: dict) -> None:
for name in dcmp.left_only:
subprocess.run(["cp", "-ax", "--", os.path.join(dcmp.left, name), dir_name])
for name in dcmp.diff_files:
subprocess.run(["rm", "-f", "--", os.path.join(dir_name, name)])
subprocess.run(["cp", "-ax", "--", os.path.join(dcmp.left, name), dir_name])
for sub_dcmp in dcmp.subdirs.values():
handle_diff_etc_files(sub_dcmp)
@ -169,10 +170,25 @@ def update() -> None:
new_rootfs = gen_rootfs(system_config, "/var/cache/akshara/rootfs")
if (
len(
[
kernel
for kernel in os.listdir(f"{new_rootfs}/boot")
if kernel.startswith("vmlinuz")
]
)
== 0
):
output.error("new rootfs contains no kernel")
output.error("refusing to proceed with applying update")
exit(1)
overrides_keep_new = (
{
override["path"]: override["keep"] == "new"
for override in system_config["override"]
if isinstance(override.get("keep"), str)
}
if isinstance(system_config.get("override"), list)
else {}
@ -207,19 +223,22 @@ def update() -> None:
merge_var(new_rootfs, overrides_keep_new)
if (
len(
with open(
os.path.join(str(new_rootfs), "usr/immutable.list"), "w"
) as immutable_list_file:
immutable_set = set(
[
kernel
for kernel in os.listdir(f"{new_rootfs}/boot")
if kernel.startswith("vmlinuz")
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 {}
)
== 0
):
output.error("new rootfs contains no kernel")
output.error("refusing to proceed with applying update")
exit(1)
immutable_set.add("/usr")
immutable_list_file.write("\n".join(list(immutable_set)))
subprocess.run(["cp", "-ax", str(new_rootfs), "/.update_rootfs"])

View file

@ -36,4 +36,7 @@ if [ -d "$NEWROOT"/.update_rootfs ]; then
touch "$NEWROOT"/.successful-update
fi
mount -o ro,bind "$NEWROOT"/usr "$NEWROOT"/usr
# Handle immutable paths
if [ -f "$NEWROOT/usr/immutable.list" ]; then
while IFS= read -r immutablepath; do mount -o ro,bind "$NEWROOT"/"$immutablepath" "$NEWROOT"/"$immutablepath" >/dev/null 2>&1 || true; done < "$NEWROOT"/usr/immutable.list
fi