Skip to content

Commit

Permalink
Merge pull request #1981 from rancher-sandbox/codesign-xml
Browse files Browse the repository at this point in the history
`codesign --xml` requires macOS Monterey or later
  • Loading branch information
AkihiroSuda authored Nov 3, 2023
2 parents 5f9fdf3 + 828973d commit e75c56a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (
"text/template"
"time"

"github.com/coreos/go-semver/semver"
"github.com/lima-vm/lima/pkg/driver"
"github.com/lima-vm/lima/pkg/driverutil"
"github.com/lima-vm/lima/pkg/osutil"
"github.com/lima-vm/lima/pkg/qemu"
"github.com/lima-vm/lima/pkg/qemu/entitlementutil"

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

Expand Down

0 comments on commit e75c56a

Please sign in to comment.