Merge pull request #108416 from srhb/streamlayeredimage-symlinked-storepaths
dockerTools: Fix streamLayeredImage for symlinks
This commit is contained in:
commit
5540dd9b9b
|
@ -247,5 +247,12 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||||
).strip()
|
).strip()
|
||||||
== "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64"}"
|
== "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64"}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with subtest("buildLayeredImage doesn't dereference /nix/store symlink layers"):
|
||||||
|
docker.succeed(
|
||||||
|
"docker load --input='${examples.layeredStoreSymlink}'",
|
||||||
|
"docker run --rm ${examples.layeredStoreSymlink.imageName} bash -c 'test -L ${examples.layeredStoreSymlink.passthru.symlink}'",
|
||||||
|
"docker rmi ${examples.layeredStoreSymlink.imageName}",
|
||||||
|
)
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
|
@ -416,4 +416,15 @@ rec {
|
||||||
contents = crossPkgs.hello;
|
contents = crossPkgs.hello;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# layered image where a store path is itself a symlink
|
||||||
|
layeredStoreSymlink =
|
||||||
|
let
|
||||||
|
target = pkgs.writeTextDir "dir/target" "Content doesn't matter.";
|
||||||
|
symlink = pkgs.runCommandNoCC "symlink" {} "ln -s ${target} $out";
|
||||||
|
in
|
||||||
|
pkgs.dockerTools.buildLayeredImage {
|
||||||
|
name = "layeredstoresymlink";
|
||||||
|
tag = "latest";
|
||||||
|
contents = [ pkgs.bash symlink ];
|
||||||
|
} // { passthru = { inherit symlink; }; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,11 @@ def archive_paths_to(obj, paths, mtime):
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
path = pathlib.Path(path)
|
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):
|
for filename in sorted(files):
|
||||||
ti = append_root(tar.gettarinfo(filename))
|
ti = append_root(tar.gettarinfo(filename))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue