mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-18 02:05:51 +03:00
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.
This commit is contained in:
parent
92b98478a8
commit
a9161ceb5a
@ -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"]
|
||||
|
Loading…
Reference in New Issue
Block a user