Contributing guidelines and issue reporting guide
Well-formed report checklist
Description of bug
Bug description
When doing a multi-platform build, the link destinations are retargeted to the root, I'd argue potentially incorrectly.
Likely, the links are already invalid - especially if they're absolute links, I'd be unpacking the local export to a subdir, not the root filesystem. Iff we want to rewrite the links at all, I think the correct behavior would be to instead rewrite the absolute links to relative ones, so that they just work. But I think the correct thing to do for local exports + tar exports is to preserve the link destinations as they were, and not attempt to rewrite them.
Reproduction
# The debian:bookworm-slim image contains symlinks like /etc/alternatives/awk -> /usr/bin/mawk
FROM debian:bookworm-slim
# also create a test symlink to make it easier to inspect
RUN ln -s /usr/bin/bash /test-symlink
Build using single-platform (good case):
$ buildctl build \
--frontend dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=local,dest=./good \
--opt platform=linux/amd64
$ readlink ./good/etc/alternatives/awk ./good/test-symlink
/usr/bin/mawk
/usr/bin/bash
Build using multi-platform (bad case):
$ buildctl build \
--frontend dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=local,dest=./bad \
--opt platform=linux/amd64,linux/arm64
$ ❯ readlink ./bad/linux_amd64/etc/alternatives/awk ./good/linux_amd64/test-symlink
/linux_amd64/usr/bin/mawk
/linux_amd64/usr/bin/bash
Version information
Buildkit v0.29.0.
Contributing guidelines and issue reporting guide
Well-formed report checklist
Description of bug
Bug description
When doing a multi-platform build, the link destinations are retargeted to the root, I'd argue potentially incorrectly.
Likely, the links are already invalid - especially if they're absolute links, I'd be unpacking the local export to a subdir, not the root filesystem. Iff we want to rewrite the links at all, I think the correct behavior would be to instead rewrite the absolute links to relative ones, so that they just work. But I think the correct thing to do for local exports + tar exports is to preserve the link destinations as they were, and not attempt to rewrite them.
Reproduction
Build using single-platform (good case):
Build using multi-platform (bad case):
Version information
Buildkit v0.29.0.