efivarfs, osimage: fix boot entry handling
efivarfs was updated to handle partition UUIDs in the mixed-endian
format [1], enabling it to produce correct boot entries. Its interface
was changed in the process, leading to further changes in osimage.
In addition, BootEntry.Marshal will replace any backslash with a
forward slash in the EFI executable path.
[1] https://en.wikipedia.org/wiki/Universally_unique_identifier#Encoding
Change-Id: Ib8300e01fd1664d0c08bb033b1dc36addb925b20
Reviewed-on: https://review.monogon.dev/c/monogon/+/456
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/build/mkimage/osimage/BUILD.bazel b/metropolis/node/build/mkimage/osimage/BUILD.bazel
index d9cacae..88f1dd8 100644
--- a/metropolis/node/build/mkimage/osimage/BUILD.bazel
+++ b/metropolis/node/build/mkimage/osimage/BUILD.bazel
@@ -11,5 +11,6 @@
"@com_github_diskfs_go_diskfs//disk:go_default_library",
"@com_github_diskfs_go_diskfs//filesystem:go_default_library",
"@com_github_diskfs_go_diskfs//partition/gpt:go_default_library",
+ "@com_github_google_uuid//:go_default_library",
],
)
diff --git a/metropolis/node/build/mkimage/osimage/osimage.go b/metropolis/node/build/mkimage/osimage/osimage.go
index 2f000a6..5aeeccd 100644
--- a/metropolis/node/build/mkimage/osimage/osimage.go
+++ b/metropolis/node/build/mkimage/osimage/osimage.go
@@ -27,6 +27,7 @@
"github.com/diskfs/go-diskfs/disk"
"github.com/diskfs/go-diskfs/filesystem"
"github.com/diskfs/go-diskfs/partition/gpt"
+ "github.com/google/uuid"
"source.monogon.dev/metropolis/pkg/efivarfs"
)
@@ -372,10 +373,14 @@
t, err := diskImg.GetPartitionTable()
p := t.GetPartitions()
esp := (p[0]).(*gpt.Partition)
+ guid, err := uuid.Parse(esp.GUID)
+ if err != nil {
+ return nil, fmt.Errorf("couldn't parse the GPT GUID: %w", err)
+ }
be := efivarfs.BootEntry{
Description: "Metropolis",
Path: EFIPayloadPath,
- PartitionGUID: esp.GUID,
+ PartitionGUID: guid,
PartitionNumber: 1,
PartitionStart: esp.Start,
PartitionSize: esp.End - esp.Start + 1,