mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-16 16:37:10 +08:00
vendor: update buildkit to 539be170
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
13
vendor/github.com/tonistiigi/fsutil/diff_containerd.go
generated
vendored
13
vendor/github.com/tonistiigi/fsutil/diff_containerd.go
generated
vendored
@ -33,6 +33,19 @@ const (
|
||||
ChangeKindDelete
|
||||
)
|
||||
|
||||
func (k ChangeKind) String() string {
|
||||
switch k {
|
||||
case ChangeKindAdd:
|
||||
return "add"
|
||||
case ChangeKindModify:
|
||||
return "modify"
|
||||
case ChangeKindDelete:
|
||||
return "delete"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// ChangeFunc is the type of function called for each change
|
||||
// computed during a directory changes calculation.
|
||||
type ChangeFunc func(ChangeKind, string, os.FileInfo, error) error
|
||||
|
14
vendor/github.com/tonistiigi/fsutil/diskwriter_freebsd.go
generated
vendored
Normal file
14
vendor/github.com/tonistiigi/fsutil/diskwriter_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// +build freebsd
|
||||
|
||||
package fsutil
|
||||
|
||||
import (
|
||||
"github.com/tonistiigi/fsutil/types"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func createSpecialFile(path string, mode uint32, stat *types.Stat) error {
|
||||
dev := unix.Mkdev(uint32(stat.Devmajor), uint32(stat.Devminor))
|
||||
|
||||
return unix.Mknod(path, mode, dev)
|
||||
}
|
2
vendor/github.com/tonistiigi/fsutil/diskwriter_unix.go
generated
vendored
2
vendor/github.com/tonistiigi/fsutil/diskwriter_unix.go
generated
vendored
@ -45,7 +45,7 @@ func handleTarTypeBlockCharFifo(path string, stat *types.Stat) error {
|
||||
mode |= syscall.S_IFBLK
|
||||
}
|
||||
|
||||
if err := syscall.Mknod(path, mode, int(mkdev(stat.Devmajor, stat.Devminor))); err != nil {
|
||||
if err := createSpecialFile(path, mode, stat); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
|
13
vendor/github.com/tonistiigi/fsutil/diskwriter_unixnobsd.go
generated
vendored
Normal file
13
vendor/github.com/tonistiigi/fsutil/diskwriter_unixnobsd.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// +build !windows,!freebsd
|
||||
|
||||
package fsutil
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/tonistiigi/fsutil/types"
|
||||
)
|
||||
|
||||
func createSpecialFile(path string, mode uint32, stat *types.Stat) error {
|
||||
return syscall.Mknod(path, mode, int(mkdev(stat.Devmajor, stat.Devminor)))
|
||||
}
|
2
vendor/github.com/tonistiigi/fsutil/docker-bake.hcl
generated
vendored
2
vendor/github.com/tonistiigi/fsutil/docker-bake.hcl
generated
vendored
@ -63,5 +63,5 @@ target "shfmt" {
|
||||
|
||||
target "cross" {
|
||||
inherits = ["build"]
|
||||
platforms = ["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x"]
|
||||
platforms = ["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "freebsd/amd64", "freebsd/arm64"]
|
||||
}
|
||||
|
2
vendor/github.com/tonistiigi/fsutil/go.mod
generated
vendored
2
vendor/github.com/tonistiigi/fsutil/go.mod
generated
vendored
@ -4,7 +4,7 @@ go 1.13
|
||||
|
||||
require (
|
||||
github.com/containerd/continuity v0.1.0
|
||||
github.com/docker/docker v20.10.3-0.20210817025855-ba2adeebdb8d+incompatible // master (v21.xx-dev)
|
||||
github.com/docker/docker v20.10.3-0.20211208011758-87521affb077+incompatible // master (v21.xx-dev)
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/google/go-cmp v0.5.2 // indirect
|
||||
|
4
vendor/github.com/tonistiigi/fsutil/go.sum
generated
vendored
4
vendor/github.com/tonistiigi/fsutil/go.sum
generated
vendored
@ -23,8 +23,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/docker/docker v20.10.3-0.20210817025855-ba2adeebdb8d+incompatible h1:tSd7TeZCH0j9m4P14bfe/eO1KYawrt3DztHI8gZAmLM=
|
||||
github.com/docker/docker v20.10.3-0.20210817025855-ba2adeebdb8d+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v20.10.3-0.20211208011758-87521affb077+incompatible h1:gUm2bOLaaAPkV1z4te7ahrXTWyA+PNNWroISSOttSgU=
|
||||
github.com/docker/docker v20.10.3-0.20211208011758-87521affb077+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
|
45
vendor/github.com/tonistiigi/fsutil/prefix/match.go
generated
vendored
45
vendor/github.com/tonistiigi/fsutil/prefix/match.go
generated
vendored
@ -1,45 +0,0 @@
|
||||
package prefix
|
||||
|
||||
import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Match matches a path against a pattern. It returns m = true if the path
|
||||
// matches the pattern, and partial = true if the pattern has more separators
|
||||
// than the path and the common components match (for example, name = foo and
|
||||
// pattern = foo/bar/*). slashSeparator determines whether the path and pattern
|
||||
// are '/' delimited (true) or use the native path separator (false).
|
||||
func Match(pattern, name string, slashSeparator bool) (m bool, partial bool) {
|
||||
separator := filepath.Separator
|
||||
if slashSeparator {
|
||||
separator = '/'
|
||||
}
|
||||
count := strings.Count(name, string(separator))
|
||||
if strings.Count(pattern, string(separator)) > count {
|
||||
pattern = trimUntilIndex(pattern, string(separator), count)
|
||||
partial = true
|
||||
}
|
||||
if slashSeparator {
|
||||
m, _ = path.Match(pattern, name)
|
||||
} else {
|
||||
m, _ = filepath.Match(pattern, name)
|
||||
}
|
||||
return m, partial
|
||||
}
|
||||
|
||||
func trimUntilIndex(str, sep string, count int) string {
|
||||
s := str
|
||||
i := 0
|
||||
c := 0
|
||||
for {
|
||||
idx := strings.Index(s, sep)
|
||||
s = s[idx+len(sep):]
|
||||
i += idx + len(sep)
|
||||
c++
|
||||
if c > count {
|
||||
return str[:i-len(sep)]
|
||||
}
|
||||
}
|
||||
}
|
215
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
215
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/docker/docker/pkg/fileutils"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tonistiigi/fsutil/prefix"
|
||||
"github.com/tonistiigi/fsutil/types"
|
||||
)
|
||||
|
||||
@ -36,20 +35,15 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return errors.WithStack(&os.PathError{Op: "walk", Path: root, Err: syscall.ENOTDIR})
|
||||
}
|
||||
|
||||
var pm *fileutils.PatternMatcher
|
||||
if opt != nil && opt.ExcludePatterns != nil {
|
||||
pm, err = fileutils.NewPatternMatcher(opt.ExcludePatterns)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid excludepatterns: %s", opt.ExcludePatterns)
|
||||
}
|
||||
}
|
||||
var (
|
||||
includePatterns []string
|
||||
includeMatcher *fileutils.PatternMatcher
|
||||
excludeMatcher *fileutils.PatternMatcher
|
||||
)
|
||||
|
||||
var includePatterns []string
|
||||
if opt != nil && opt.IncludePatterns != nil {
|
||||
includePatterns = make([]string, len(opt.IncludePatterns))
|
||||
for k := range opt.IncludePatterns {
|
||||
includePatterns[k] = filepath.Clean(opt.IncludePatterns[k])
|
||||
}
|
||||
copy(includePatterns, opt.IncludePatterns)
|
||||
}
|
||||
if opt != nil && opt.FollowPaths != nil {
|
||||
targets, err := FollowLinks(p, opt.FollowPaths)
|
||||
@ -61,13 +55,32 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
includePatterns = dedupePaths(includePatterns)
|
||||
}
|
||||
}
|
||||
if len(includePatterns) != 0 {
|
||||
includeMatcher, err = fileutils.NewPatternMatcher(includePatterns)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid includepatterns: %s", opt.IncludePatterns)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
lastIncludedDir string
|
||||
if opt != nil && opt.ExcludePatterns != nil {
|
||||
excludeMatcher, err = fileutils.NewPatternMatcher(opt.ExcludePatterns)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid excludepatterns: %s", opt.ExcludePatterns)
|
||||
}
|
||||
}
|
||||
|
||||
parentDirs []string // used only for exclude handling
|
||||
parentMatchedExclude []bool
|
||||
)
|
||||
type visitedDir struct {
|
||||
fi os.FileInfo
|
||||
path string
|
||||
origpath string
|
||||
pathWithSep string
|
||||
includeMatchInfo fileutils.MatchInfo
|
||||
excludeMatchInfo fileutils.MatchInfo
|
||||
calledFn bool
|
||||
}
|
||||
|
||||
// used only for include/exclude handling
|
||||
var parentDirs []visitedDir
|
||||
|
||||
seenFiles := make(map[uint64]string)
|
||||
return filepath.Walk(root, func(path string, fi os.FileInfo, err error) (retErr error) {
|
||||
@ -90,87 +103,84 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return nil
|
||||
}
|
||||
|
||||
if opt != nil {
|
||||
if includePatterns != nil {
|
||||
skip := false
|
||||
if lastIncludedDir != "" {
|
||||
if strings.HasPrefix(path, lastIncludedDir+string(filepath.Separator)) {
|
||||
skip = true
|
||||
}
|
||||
}
|
||||
var dir visitedDir
|
||||
|
||||
if !skip {
|
||||
matched := false
|
||||
partial := true
|
||||
for _, pattern := range includePatterns {
|
||||
if ok, p := prefix.Match(pattern, path, false); ok {
|
||||
matched = true
|
||||
if !p {
|
||||
partial = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
if fi.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !partial && fi.IsDir() {
|
||||
lastIncludedDir = path
|
||||
}
|
||||
if includeMatcher != nil || excludeMatcher != nil {
|
||||
for len(parentDirs) != 0 {
|
||||
lastParentDir := parentDirs[len(parentDirs)-1].pathWithSep
|
||||
if strings.HasPrefix(path, lastParentDir) {
|
||||
break
|
||||
}
|
||||
parentDirs = parentDirs[:len(parentDirs)-1]
|
||||
}
|
||||
if pm != nil {
|
||||
for len(parentMatchedExclude) != 0 {
|
||||
lastParentDir := parentDirs[len(parentDirs)-1]
|
||||
if strings.HasPrefix(path, lastParentDir) {
|
||||
break
|
||||
}
|
||||
parentDirs = parentDirs[:len(parentDirs)-1]
|
||||
parentMatchedExclude = parentMatchedExclude[:len(parentMatchedExclude)-1]
|
||||
}
|
||||
|
||||
var m bool
|
||||
if len(parentMatchedExclude) != 0 {
|
||||
m, err = pm.MatchesUsingParentResult(path, parentMatchedExclude[len(parentMatchedExclude)-1])
|
||||
} else {
|
||||
m, err = pm.MatchesOrParentMatches(path)
|
||||
}
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to match excludepatterns")
|
||||
}
|
||||
|
||||
var dirSlash string
|
||||
if fi.IsDir() {
|
||||
dirSlash = path + string(filepath.Separator)
|
||||
parentDirs = append(parentDirs, dirSlash)
|
||||
parentMatchedExclude = append(parentMatchedExclude, m)
|
||||
}
|
||||
|
||||
if m {
|
||||
if fi.IsDir() {
|
||||
if !pm.Exclusions() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
for _, pat := range pm.Patterns() {
|
||||
if !pat.Exclusion() {
|
||||
continue
|
||||
}
|
||||
patStr := pat.String() + string(filepath.Separator)
|
||||
if strings.HasPrefix(patStr, dirSlash) {
|
||||
goto passedFilter
|
||||
}
|
||||
}
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
if fi.IsDir() {
|
||||
dir = visitedDir{
|
||||
fi: fi,
|
||||
path: path,
|
||||
origpath: origpath,
|
||||
pathWithSep: path + string(filepath.Separator),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
passedFilter:
|
||||
skip := false
|
||||
|
||||
if includeMatcher != nil {
|
||||
var parentIncludeMatchInfo fileutils.MatchInfo
|
||||
if len(parentDirs) != 0 {
|
||||
parentIncludeMatchInfo = parentDirs[len(parentDirs)-1].includeMatchInfo
|
||||
}
|
||||
m, matchInfo, err := includeMatcher.MatchesUsingParentResults(path, parentIncludeMatchInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to match includepatterns")
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
dir.includeMatchInfo = matchInfo
|
||||
}
|
||||
|
||||
if !m {
|
||||
skip = true
|
||||
}
|
||||
}
|
||||
|
||||
if excludeMatcher != nil {
|
||||
var parentExcludeMatchInfo fileutils.MatchInfo
|
||||
if len(parentDirs) != 0 {
|
||||
parentExcludeMatchInfo = parentDirs[len(parentDirs)-1].excludeMatchInfo
|
||||
}
|
||||
m, matchInfo, err := excludeMatcher.MatchesUsingParentResults(path, parentExcludeMatchInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to match excludepatterns")
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
dir.excludeMatchInfo = matchInfo
|
||||
}
|
||||
|
||||
if m {
|
||||
if fi.IsDir() && !excludeMatcher.Exclusions() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
skip = true
|
||||
}
|
||||
}
|
||||
|
||||
if includeMatcher != nil || excludeMatcher != nil {
|
||||
defer func() {
|
||||
if fi.IsDir() {
|
||||
parentDirs = append(parentDirs, dir)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if skip {
|
||||
return nil
|
||||
}
|
||||
|
||||
dir.calledFn = true
|
||||
|
||||
stat, err := mkstat(origpath, path, fi, seenFiles)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -185,6 +195,31 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return nil
|
||||
}
|
||||
}
|
||||
for i, parentDir := range parentDirs {
|
||||
if parentDir.calledFn {
|
||||
continue
|
||||
}
|
||||
parentStat, err := mkstat(parentDir.origpath, parentDir.path, parentDir.fi, seenFiles)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
if opt != nil && opt.Map != nil {
|
||||
if allowed := opt.Map(parentStat.Path, parentStat); !allowed {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if err := fn(parentStat.Path, &StatInfo{parentStat}, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
parentDirs[i].calledFn = true
|
||||
}
|
||||
if err := fn(stat.Path, &StatInfo{stat}, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user