Merge pull request #456 from priyawadhwa/composer
Fix bug in extracting hardlinks in multistage builds
This commit is contained in:
commit
a7599d1563
|
|
@ -1,3 +1,10 @@
|
|||
FROM composer@sha256:4598feb4b58b4370893a29cbc654afa9420b4debed1d574531514b78a24cd608 AS composer
|
||||
FROM php@sha256:13813f20fec7ded7bf3a4305ea0ccd4df3cea900e263f7f86c3d5737f86669eb
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# make sure hardlink extracts correctly
|
||||
FROM jboss/base-jdk@sha256:138591422fdab93a5844c13f6cbcc685631b37a16503675e9f340d2503617a41
|
||||
|
||||
FROM gcr.io/kaniko-test/hardlink-base:latest
|
||||
RUN ls -al /usr/libexec/git-core/git /usr/bin/git /usr/libexec/git-core/git-diff
|
||||
RUN stat /usr/bin/git
|
||||
|
|
|
|||
|
|
@ -245,8 +245,8 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error {
|
|||
return errors.Wrapf(err, "error removing %s to make way for new link", hdr.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.Link(filepath.Clean(filepath.Join("/", hdr.Linkname)), path); err != nil {
|
||||
link := filepath.Clean(filepath.Join(dest, hdr.Linkname))
|
||||
if err := os.Link(link, path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ func filesAreHardlinks(first, second string) checker {
|
|||
if err != nil {
|
||||
t.Fatalf("error getting file %s", first)
|
||||
}
|
||||
fi2, err := os.Stat(filepath.Join(second))
|
||||
fi2, err := os.Stat(filepath.Join(root, second))
|
||||
if err != nil {
|
||||
t.Fatalf("error getting file %s", second)
|
||||
}
|
||||
|
|
@ -499,11 +499,11 @@ func TestExtractFile(t *testing.T) {
|
|||
tmpdir: "/tmp/hardlink",
|
||||
hdrs: []*tar.Header{
|
||||
fileHeader("/bin/gzip", "gzip-binary", 0751),
|
||||
hardlinkHeader("/bin/uncompress", "/tmp/hardlink/bin/gzip"),
|
||||
hardlinkHeader("/bin/uncompress", "/bin/gzip"),
|
||||
},
|
||||
checkers: []checker{
|
||||
fileExists("/bin/gzip"),
|
||||
filesAreHardlinks("/bin/uncompress", "/tmp/hardlink/bin/gzip"),
|
||||
filesAreHardlinks("/bin/uncompress", "/bin/gzip"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue