diff options
author | nikstur <nikstur@outlook.com> | 2024-01-28 01:55:05 +0100 |
---|---|---|
committer | nikstur <nikstur@outlook.com> | 2024-01-28 13:37:23 +0100 |
commit | a9161ceb5a3669ced280ce0805ad38470b5904b2 (patch) | |
tree | a7f57bf64f88f28b9a73c58616b862e2d23b8cfa /nixos | |
parent | 92b98478a830a7f7e6f65195aa1b2257798fe423 (diff) | |
download | nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.tar nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.tar.gz nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.tar.bz2 nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.tar.lz nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.tar.xz nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.tar.zst nixlib-a9161ceb5a3669ced280ce0805ad38470b5904b2.zip |
nixos/etc: remove leading slash from target paths in build-composefs-dump.py
This is necessary so that duplicates in the composefs dump are avoided.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/etc/build-composefs-dump.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nixos/modules/system/etc/build-composefs-dump.py b/nixos/modules/system/etc/build-composefs-dump.py index a1b922d97369..bf4ec791ecf7 100644 --- a/nixos/modules/system/etc/build-composefs-dump.py +++ b/nixos/modules/system/etc/build-composefs-dump.py @@ -58,7 +58,7 @@ class ComposefsPath: ): if path is None: path = attrs["target"] - self.path = "/" + path + self.path = path self.size = size self.filetype = filetype self.mode = mode @@ -87,6 +87,10 @@ def eprint(*args: Any, **kwargs: Any) -> None: print(*args, **kwargs, file=sys.stderr) +def normalize_path(path: str) -> str: + return str("/" + os.path.normpath(path).lstrip("/")) + + def leading_directories(path: str) -> list[str]: """Return the leading directories of path @@ -145,6 +149,10 @@ def main() -> None: paths: dict[str, ComposefsPath] = {} for attrs in config: + # Normalize the target path to work around issues in how targets are + # declared in `environment.etc`. + attrs["target"] = normalize_path(attrs["target"]) + target = attrs["target"] source = attrs["source"] mode = attrs["mode"] |