Skip to content

Commit

Permalink
fix:[close #27] Set Grub loader EFI path
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Oct 13, 2023
1 parent c9b3c53 commit 87b1f63
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/grub.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
)

Expand Down Expand Up @@ -107,7 +108,7 @@ func RunGrubInstall(targetRoot, bootDirectory, diskPath string, target FirmwareT
}
}

grubInstallCmd := "grub-install --boot-directory %s --target=%s --uefi-secure-boot %s"
grubInstallCmd := "grub-install --bootloader-id=debian --boot-directory %s --target=%s --uefi-secure-boot %s"

var err error
if targetRoot != "" {
Expand All @@ -119,6 +120,22 @@ func RunGrubInstall(targetRoot, bootDirectory, diskPath string, target FirmwareT
return fmt.Errorf("Failed to run grub-install: %s", err)
}

if targetRoot != "" {
return nil
}

// FIXME: This is needed on Vanilla due to some recent GRUB change. If you're using Debian sid as
// base, consider keeping it.
efibootmgrCmd := "efibootmgr --create --disk=%s --part=%s --label=vanilla --loader=\"\\EFI\\debian\\shimx64.efi\""
diskExpr := regexp.MustCompile("^/dev/[a-zA-Z]+([0-9]+[a-z][0-9]+)?")
partExpr := regexp.MustCompile("[0-9]+$")
diskName := diskExpr.FindString(diskPath)
part := partExpr.FindString(diskPath)
err = RunCommand(fmt.Sprintf(efibootmgrCmd, diskName, part))
if err != nil {
return fmt.Errorf("Failed to run grub-install: %s", err)
}

return nil
}

Expand Down

0 comments on commit 87b1f63

Please sign in to comment.