osbase/build/mkimage/osimage: remove initial slash in EFI paths
Many places where these paths are used don't need the initial slash, and
it's easier to add it than to remove it.
Change-Id: Iec189628556c9aa1c022fdd46a2c9fe57692e0aa
Reviewed-on: https://review.monogon.dev/c/monogon/+/4194
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/metropolis/installer/test/run_test.go b/metropolis/installer/test/run_test.go
index 925e758..3c8f1a6 100644
--- a/metropolis/installer/test/run_test.go
+++ b/metropolis/installer/test/run_test.go
@@ -124,7 +124,7 @@
return fmt.Errorf("couldn't read the installer ESP: %w", err)
}
// Make sure the EFI payload exists by attempting to open it.
- efiPayload, err := fs.OpenFile(osimage.EFIPayloadPath, os.O_RDONLY)
+ efiPayload, err := fs.OpenFile("/"+osimage.EFIPayloadPath, os.O_RDONLY)
if err != nil {
return fmt.Errorf("couldn't open the installer's EFI Payload at %q: %w", osimage.EFIPayloadPath, err)
}
diff --git a/metropolis/node/core/update/update.go b/metropolis/node/core/update/update.go
index 3d3060d..53bcb96 100644
--- a/metropolis/node/core/update/update.go
+++ b/metropolis/node/core/update/update.go
@@ -505,7 +505,7 @@
}
switch p := e.FilePath[1].(type) {
case efivarfs.FilePath:
- if string(p) == osimage.EFIPayloadPath {
+ if string(p) == "/"+osimage.EFIPayloadPath {
if validBootEntryIdx == -1 {
validBootEntryIdx = int(idx)
} else {
@@ -541,7 +541,7 @@
PartitionUUID: s.ESPPart.ID,
},
},
- efivarfs.FilePath(osimage.EFIPayloadPath),
+ efivarfs.FilePath("/" + osimage.EFIPayloadPath),
},
})
if err == nil {
diff --git a/osbase/build/mkimage/osimage/osimage.go b/osbase/build/mkimage/osimage/osimage.go
index 4cd3952..4edb077 100644
--- a/osbase/build/mkimage/osimage/osimage.go
+++ b/osbase/build/mkimage/osimage/osimage.go
@@ -8,7 +8,6 @@
import (
"fmt"
"io"
- "strings"
"github.com/google/uuid"
@@ -32,9 +31,9 @@
DataLabel = "METROPOLIS-NODE-DATA"
ESPLabel = "ESP"
- EFIPayloadPath = "/EFI/BOOT/BOOTx64.EFI"
- EFIBootAPath = "/EFI/metropolis/boot-a.efi"
- EFIBootBPath = "/EFI/metropolis/boot-b.efi"
+ EFIPayloadPath = "EFI/BOOT/BOOTx64.EFI"
+ EFIBootAPath = "EFI/metropolis/boot-a.efi"
+ EFIBootBPath = "EFI/metropolis/boot-b.efi"
nodeParamsPath = "metropolis/parameters.pb"
)
@@ -135,7 +134,7 @@
PartitionUUID: i.efiPartition.ID,
},
},
- efivarfs.FilePath(EFIPayloadPath),
+ efivarfs.FilePath("/" + EFIPayloadPath),
},
}, nil
}
@@ -162,11 +161,11 @@
return nil, fmt.Errorf("failed to allocate ESP: %w", err)
}
- if err := params.efiRoot.PlaceFile(strings.TrimPrefix(EFIBootAPath, "/"), params.EFIPayload); err != nil {
+ if err := params.efiRoot.PlaceFile(EFIBootAPath, params.EFIPayload); err != nil {
return nil, err
}
// Place the A/B loader at the EFI bootloader autodiscovery path.
- if err := params.efiRoot.PlaceFile(strings.TrimPrefix(EFIPayloadPath, "/"), params.ABLoader); err != nil {
+ if err := params.efiRoot.PlaceFile(EFIPayloadPath, params.ABLoader); err != nil {
return nil, err
}
if params.NodeParameters != nil {