Skip to content

Commit e75c56a

Browse files
authored
Merge pull request #1981 from rancher-sandbox/codesign-xml
`codesign --xml` requires macOS Monterey or later
2 parents 5f9fdf3 + 828973d commit e75c56a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pkg/start/start.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import (
1313
"text/template"
1414
"time"
1515

16+
"github.com/coreos/go-semver/semver"
1617
"github.com/lima-vm/lima/pkg/driver"
1718
"github.com/lima-vm/lima/pkg/driverutil"
19+
"github.com/lima-vm/lima/pkg/osutil"
1820
"github.com/lima-vm/lima/pkg/qemu"
1921
"github.com/lima-vm/lima/pkg/qemu/entitlementutil"
2022

@@ -125,12 +127,19 @@ func Start(ctx context.Context, inst *store.Instance) error {
125127
// Ask the user to sign the qemu binary with the "com.apple.security.hypervisor" if needed.
126128
// Workaround for https://github.com/lima-vm/lima/issues/1742
127129
if runtime.GOOS == "darwin" && inst.VMType == limayaml.QEMU {
128-
qExe, _, err := qemu.Exe(inst.Arch)
130+
macOSProductVersion, err := osutil.ProductVersion()
129131
if err != nil {
130-
return fmt.Errorf("failed to find the QEMU binary for the architecture %q: %w", inst.Arch, err)
132+
return err
131133
}
132-
if accel := qemu.Accel(inst.Arch); accel == "hvf" {
133-
entitlementutil.AskToSignIfNotSignedProperly(qExe)
134+
// The codesign --xml option is only available on macOS Monterey and later
135+
if !macOSProductVersion.LessThan(*semver.New("12.0.0")) {
136+
qExe, _, err := qemu.Exe(inst.Arch)
137+
if err != nil {
138+
return fmt.Errorf("failed to find the QEMU binary for the architecture %q: %w", inst.Arch, err)
139+
}
140+
if accel := qemu.Accel(inst.Arch); accel == "hvf" {
141+
entitlementutil.AskToSignIfNotSignedProperly(qExe)
142+
}
134143
}
135144
}
136145

0 commit comments

Comments
 (0)