mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
dockerTools: Test buildLayeredImage with symlinks
This exercises layer creation in face of store path symlinks, ensuring they are not dereferenced, which can lead to broken layer tarballs
This commit is contained in:
parent
08b0d02944
commit
ffe5ff6009
2 changed files with 18 additions and 0 deletions
|
@ -247,5 +247,12 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
|||
).strip()
|
||||
== "${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;
|
||||
};
|
||||
|
||||
# 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; }; };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue