mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to v0.17.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
27
vendor/github.com/containerd/continuity/testutil/helpers.go
generated
vendored
Normal file
27
vendor/github.com/containerd/continuity/testutil/helpers.go
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"flag"
|
||||
)
|
||||
|
||||
var rootEnabled bool
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&rootEnabled, "test.root", false, "enable tests that require root")
|
||||
}
|
57
vendor/github.com/containerd/continuity/testutil/helpers_unix.go
generated
vendored
Normal file
57
vendor/github.com/containerd/continuity/testutil/helpers_unix.go
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
//go:build !windows
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Unmount unmounts a given mountPoint and sets t.Error if it fails
|
||||
func Unmount(t *testing.T, mountPoint string) {
|
||||
t.Log("unmount", mountPoint)
|
||||
if err := unmountAll(mountPoint); err != nil {
|
||||
t.Error("Could not umount", mountPoint, err)
|
||||
}
|
||||
}
|
||||
|
||||
// RequiresRoot skips tests that require root, unless the test.root flag has
|
||||
// been set
|
||||
func RequiresRoot(t testing.TB) {
|
||||
if !rootEnabled {
|
||||
t.Skip("skipping test that requires root")
|
||||
return
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Error("This test must be run as root.")
|
||||
}
|
||||
}
|
||||
|
||||
func unmountAll(mountpoint string) error {
|
||||
for {
|
||||
if err := unix.Unmount(mountpoint, unmountFlags); err != nil {
|
||||
if err == unix.EINVAL {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
32
vendor/github.com/containerd/continuity/testutil/helpers_windows.go
generated
vendored
Normal file
32
vendor/github.com/containerd/continuity/testutil/helpers_windows.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package testutil
|
||||
|
||||
import "testing"
|
||||
|
||||
// RequiresRoot does nothing on Windows
|
||||
func RequiresRoot(t testing.TB) {
|
||||
}
|
||||
|
||||
// RequiresRootM is similar to RequiresRoot but intended to be called from *testing.M.
|
||||
func RequiresRootM() {
|
||||
}
|
||||
|
||||
// Unmount unmounts a given mountPoint and sets t.Error if it fails
|
||||
// Does nothing on Windows
|
||||
func Unmount(t *testing.T, mountPoint string) {
|
||||
}
|
118
vendor/github.com/containerd/continuity/testutil/loopback/loopback_linux.go
generated
vendored
Normal file
118
vendor/github.com/containerd/continuity/testutil/loopback/loopback_linux.go
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package loopback
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/log"
|
||||
)
|
||||
|
||||
// New creates a loopback device
|
||||
func New(size int64) (*Loopback, error) {
|
||||
// create temporary file for the disk image
|
||||
file, err := os.CreateTemp("", "containerd-test-loopback")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create temporary file for loopback: %w", err)
|
||||
}
|
||||
|
||||
if err := file.Truncate(size); err != nil {
|
||||
file.Close()
|
||||
os.Remove(file.Name())
|
||||
return nil, fmt.Errorf("failed to resize temp file: %w", err)
|
||||
}
|
||||
file.Close()
|
||||
|
||||
// create device
|
||||
losetup := exec.Command("losetup", "--find", "--show", file.Name())
|
||||
var stdout, stderr bytes.Buffer
|
||||
losetup.Stdout = &stdout
|
||||
losetup.Stderr = &stderr
|
||||
if err := losetup.Run(); err != nil {
|
||||
os.Remove(file.Name())
|
||||
return nil, fmt.Errorf("loopback setup failed (%v): stdout=%q, stderr=%q: %w", losetup.Args, stdout.String(), stderr.String(), err)
|
||||
}
|
||||
|
||||
deviceName := strings.TrimSpace(stdout.String())
|
||||
log.L.Debugf("Created loop device %s (using %s)", deviceName, file.Name())
|
||||
|
||||
cleanup := func() error {
|
||||
// detach device
|
||||
log.L.Debugf("Removing loop device %s", deviceName)
|
||||
losetup := exec.Command("losetup", "--detach", deviceName)
|
||||
if out, err := losetup.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("Could not remove loop device %s (%v): %q: %w", deviceName, losetup.Args, string(out), err)
|
||||
}
|
||||
|
||||
// remove file
|
||||
log.L.Debugf("Removing temporary file %s", file.Name())
|
||||
return os.Remove(file.Name())
|
||||
}
|
||||
|
||||
l := Loopback{
|
||||
File: file.Name(),
|
||||
Device: deviceName,
|
||||
close: cleanup,
|
||||
}
|
||||
return &l, nil
|
||||
}
|
||||
|
||||
// Loopback device
|
||||
type Loopback struct {
|
||||
// File is the underlying sparse file
|
||||
File string
|
||||
// Device is /dev/loopX
|
||||
Device string
|
||||
close func() error
|
||||
}
|
||||
|
||||
// SoftSize returns st_size
|
||||
func (l *Loopback) SoftSize() (int64, error) {
|
||||
st, err := os.Stat(l.File)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return st.Size(), nil
|
||||
}
|
||||
|
||||
// HardSize returns st_blocks * 512; see stat(2)
|
||||
func (l *Loopback) HardSize() (int64, error) {
|
||||
st, err := os.Stat(l.File)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
st2, ok := st.Sys().(*syscall.Stat_t)
|
||||
if !ok {
|
||||
return 0, errors.New("st.Sys() is not a *syscall.Stat_t")
|
||||
}
|
||||
// NOTE: st_blocks has nothing to do with st_blksize; see stat(2)
|
||||
return st2.Blocks * 512, nil
|
||||
}
|
||||
|
||||
// Close detaches the device and removes the underlying file
|
||||
func (l *Loopback) Close() error {
|
||||
return l.close()
|
||||
}
|
21
vendor/github.com/containerd/continuity/testutil/mount_linux.go
generated
vendored
Normal file
21
vendor/github.com/containerd/continuity/testutil/mount_linux.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package testutil
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const unmountFlags int = unix.MNT_DETACH
|
21
vendor/github.com/containerd/continuity/testutil/mount_other.go
generated
vendored
Normal file
21
vendor/github.com/containerd/continuity/testutil/mount_other.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
//go:build !linux && !windows
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package testutil
|
||||
|
||||
const unmountFlags int = 0
|
Reference in New Issue
Block a user