(s string)
| 43 | } |
| 44 | |
| 45 | func canExecProbably(s string) (bool, error) { |
| 46 | if s == "" { |
| 47 | return true, nil |
| 48 | } |
| 49 | p, err := platforms.Parse(s) |
| 50 | if err != nil { |
| 51 | return false, err |
| 52 | } |
| 53 | if platforms.Default().Match(p) { |
| 54 | return true, nil |
| 55 | } |
| 56 | if runtime.GOOS == "linux" { |
| 57 | qemuArch, err := qemuArchFromOCIArch(p.Architecture) |
| 58 | if err != nil { |
| 59 | return false, err |
| 60 | } |
| 61 | candidates := []string{ |
| 62 | "/proc/sys/fs/binfmt_misc/qemu-" + qemuArch, |
| 63 | "/proc/sys/fs/binfmt_misc/buildkit-qemu-" + qemuArch, |
| 64 | } |
| 65 | // Rosetta 2 for Linux on ARM Mac |
| 66 | // https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta |
| 67 | if runtime.GOARCH == "arm64" && p.Architecture == "amd64" { |
| 68 | candidates = append(candidates, "/proc/sys/fs/binfmt_misc/rosetta") |
| 69 | } |
| 70 | for _, cand := range candidates { |
| 71 | if _, err := os.Stat(cand); err == nil { |
| 72 | return true, nil |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | return false, nil |
| 77 | } |
| 78 | |
| 79 | func CanExecProbably(ss ...string) (bool, error) { |
| 80 | for _, s := range ss { |
no test coverage detected
searching dependent graphs…