From 082c666bdbf366dfed59f3c2bf0fb3532e125983 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 18 Jan 2022 23:51:44 -0800 Subject: [PATCH] exec: check full platform vector when checking for emulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of doing a direct string comparison we should use `platforms.Only` so that we can also detect the variants that are compatible but don’t match directly. Signed-off-by: Tonis Tiigi --- solver/llbsolver/ops/exec_binfmt.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/solver/llbsolver/ops/exec_binfmt.go b/solver/llbsolver/ops/exec_binfmt.go index 2012536d6..729b113d9 100644 --- a/solver/llbsolver/ops/exec_binfmt.go +++ b/solver/llbsolver/ops/exec_binfmt.go @@ -85,20 +85,18 @@ func (m *staticEmulatorMount) IdentityMapping() *idtools.IdentityMapping { func getEmulator(p *pb.Platform, idmap *idtools.IdentityMapping) (*emulator, error) { all := archutil.SupportedPlatforms(false) - m := make(map[string]struct{}, len(all)) - - for _, p := range all { - m[p] = struct{}{} - } - pp := platforms.Normalize(ocispecs.Platform{ Architecture: p.Architecture, OS: p.OS, Variant: p.Variant, }) - if _, ok := m[platforms.Format(pp)]; ok { - return nil, nil + for _, ps := range all { + if p, err := platforms.Parse(ps); err == nil { + if platforms.Only(p).Match(pp) { + return nil, nil + } + } } a, ok := qemuArchMap[pp.Architecture]