From 08b0d02944eb94359726ac61af3c3ab84b53ee7d Mon Sep 17 00:00:00 2001 From: Sarah Brofeldt Date: Mon, 4 Jan 2021 19:39:21 +0100 Subject: [PATCH] dockerTools: Fix streamLayeredImage for symlinks When archiving `/nix/store/foo` and `foo` is itself a symlink, we must not traverse the symlink target, but archive the `foo` symlink itself --- pkgs/build-support/docker/stream_layered_image.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/docker/stream_layered_image.py b/pkgs/build-support/docker/stream_layered_image.py index cbae0f723f9..e35bd0b0e8c 100644 --- a/pkgs/build-support/docker/stream_layered_image.py +++ b/pkgs/build-support/docker/stream_layered_image.py @@ -83,7 +83,11 @@ def archive_paths_to(obj, paths, mtime): for path in paths: path = pathlib.Path(path) - files = itertools.chain([path], path.rglob("*")) + if path.is_symlink(): + files = [path] + else: + files = itertools.chain([path], path.rglob("*")) + for filename in sorted(files): ti = append_root(tar.gettarinfo(filename))