@@ -17,14 +17,14 @@ import (
1717 "github.com/docker/docker/builder"
1818 "github.com/docker/docker/builder/remotecontext"
1919 "github.com/docker/docker/builder/remotecontext/urlutil"
20- "github.com/docker/docker/pkg/archive"
21- "github.com/docker/docker/pkg/idtools"
2220 "github.com/docker/docker/pkg/longpath"
2321 "github.com/docker/docker/pkg/progress"
2422 "github.com/docker/docker/pkg/streamformatter"
2523 "github.com/docker/docker/pkg/system"
2624 "github.com/moby/buildkit/frontend/dockerfile/instructions"
25+ "github.com/moby/go-archive"
2726 "github.com/moby/sys/symlink"
27+ "github.com/moby/sys/user"
2828 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2929 "github.com/pkg/errors"
3030)
@@ -446,9 +446,15 @@ func downloadSource(output io.Writer, stdout io.Writer, srcURL string) (remote b
446446 return lc , filename , err
447447}
448448
449+ type identity struct {
450+ UID int
451+ GID int
452+ SID string
453+ }
454+
449455type copyFileOptions struct {
450456 decompress bool
451- identity * idtools. Identity
457+ identity * identity
452458 archiver * archive.Archiver
453459}
454460
@@ -498,7 +504,7 @@ func performCopyForInfo(dest copyInfo, source copyInfo, options copyFileOptions)
498504 return copyFile (archiver , srcPath , destPath , options .identity )
499505}
500506
501- func copyDirectory (archiver * archive.Archiver , source , dest string , identity * idtools. Identity ) error {
507+ func copyDirectory (archiver * archive.Archiver , source , dest string , identity * identity ) error {
502508 destExists , err := isExistingDirectory (dest )
503509 if err != nil {
504510 return errors .Wrapf (err , "failed to query destination path" )
@@ -513,13 +519,13 @@ func copyDirectory(archiver *archive.Archiver, source, dest string, identity *id
513519 return nil
514520}
515521
516- func copyFile (archiver * archive.Archiver , source , dest string , identity * idtools. Identity ) error {
522+ func copyFile (archiver * archive.Archiver , source , dest string , identity * identity ) error {
517523 if identity == nil {
518524 if err := os .MkdirAll (filepath .Dir (dest ), 0o755 ); err != nil {
519525 return err
520526 }
521527 } else {
522- if err := idtools . MkdirAllAndChownNew (filepath .Dir (dest ), 0o755 , * identity ); err != nil {
528+ if err := user . MkdirAllAndChown (filepath .Dir (dest ), 0o755 , identity . UID , identity . GID , user . WithOnlyNew ); err != nil {
523529 return errors .Wrapf (err , "failed to create new directory" )
524530 }
525531 }
0 commit comments