|
7 | 7 | "io/fs"
|
8 | 8 | "os"
|
9 | 9 | "os/exec"
|
| 10 | + "os/user" |
10 | 11 | "path/filepath"
|
11 | 12 | "runtime"
|
12 | 13 | "strconv"
|
@@ -615,11 +616,20 @@ func getFirmware(qemuExe string, arch limayaml.Arch) (string, error) {
|
615 | 616 | default:
|
616 | 617 | return "", fmt.Errorf("unexpected architecture: %q", arch)
|
617 | 618 | }
|
618 |
| - binDir := filepath.Dir(qemuExe) // "/usr/local/bin" |
619 |
| - localDir := filepath.Dir(binDir) // "/usr/local" |
620 | 619 |
|
| 620 | + currentUser, err := user.Current() |
| 621 | + if err != nil { |
| 622 | + return "", err |
| 623 | + } |
| 624 | + |
| 625 | + binDir := filepath.Dir(qemuExe) // "/usr/local/bin" |
| 626 | + localDir := filepath.Dir(binDir) // "/usr/local" |
| 627 | + userLocalDir := filepath.Join(currentUser.HomeDir, ".local") // "$HOME/.local" |
| 628 | + |
| 629 | + relativePath := fmt.Sprintf("share/qemu/edk2-%s-code.fd", arch) |
621 | 630 | candidates := []string{
|
622 |
| - filepath.Join(localDir, fmt.Sprintf("share/qemu/edk2-%s-code.fd", arch)), // macOS (homebrew) |
| 631 | + filepath.Join(userLocalDir, relativePath), // XDG-like |
| 632 | + filepath.Join(localDir, relativePath), // macOS (homebrew) |
623 | 633 | }
|
624 | 634 |
|
625 | 635 | switch arch {
|
@@ -648,5 +658,5 @@ func getFirmware(qemuExe string, arch limayaml.Arch) (string, error) {
|
648 | 658 | if arch == limayaml.X8664 {
|
649 | 659 | return "", fmt.Errorf("could not find firmware for %q (hint: try setting `firmware.legacyBIOS` to `true`)", qemuExe)
|
650 | 660 | }
|
651 |
| - return "", fmt.Errorf("could not find firmware for %q", qemuExe) |
| 661 | + return "", fmt.Errorf("could not find firmware for %q (hint: try copying the \"edk-%s-code.fd\" firmware to $HOME/.local/share/qemu/)", arch, qemuExe) |
652 | 662 | }
|
0 commit comments