treewide: use architecture-specific UEFI boot path

The default UEFI boot path depends on the architecture. This change is
needed for aarch64 support.

Change-Id: I69916ac5063e963b67ecdcdd814b0678c61da9fb
Reviewed-on: https://review.monogon.dev/c/monogon/+/4195
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/core/BUILD.bazel b/metropolis/cli/metroctl/core/BUILD.bazel
index cd95ac1..d785fad 100644
--- a/metropolis/cli/metroctl/core/BUILD.bazel
+++ b/metropolis/cli/metroctl/core/BUILD.bazel
@@ -19,9 +19,11 @@
         "//metropolis/node/core/rpc/resolver",
         "//metropolis/proto/api",
         "//osbase/blockdev",
+        "//osbase/build/mkimage/osimage",
         "//osbase/fat32",
         "//osbase/gpt",
         "//osbase/oci",
+        "//osbase/oci/osimage",
         "//osbase/structfs",
         "@io_k8s_client_go//pkg/apis/clientauthentication/v1:clientauthentication",
         "@io_k8s_client_go//tools/clientcmd",
diff --git a/metropolis/cli/metroctl/core/install.go b/metropolis/cli/metroctl/core/install.go
index 92e8303..0927ba1 100644
--- a/metropolis/cli/metroctl/core/install.go
+++ b/metropolis/cli/metroctl/core/install.go
@@ -13,9 +13,11 @@
 
 	"source.monogon.dev/metropolis/proto/api"
 	"source.monogon.dev/osbase/blockdev"
+	"source.monogon.dev/osbase/build/mkimage/osimage"
 	"source.monogon.dev/osbase/fat32"
 	"source.monogon.dev/osbase/gpt"
 	"source.monogon.dev/osbase/oci"
+	ociosimage "source.monogon.dev/osbase/oci/osimage"
 	"source.monogon.dev/osbase/structfs"
 )
 
@@ -29,7 +31,7 @@
 	// Optional NodeParameters to be embedded for use by the installer.
 	NodeParams *api.NodeParameters
 
-	// Optional OS image for use by the installer.
+	// OS image for use by the installer.
 	Image *oci.Image
 }
 
@@ -41,12 +43,18 @@
 		return errors.New("installer is mandatory")
 	}
 
+	osImage, err := ociosimage.Read(args.Image)
+	if err != nil {
+		return fmt.Errorf("failed to read OS image: %w", err)
+	}
+	bootPath, err := osimage.EFIBootPath(osImage.Config.ProductInfo.Architecture())
+	if err != nil {
+		return err
+	}
+
 	var espRoot structfs.Tree
 
-	// This needs to be a "Removable Media" according to the UEFI Specification
-	// V2.9 Section 3.5.1.1. This file is booted by any compliant UEFI firmware
-	// in absence of another bootable boot entry.
-	if err := espRoot.PlaceFile("EFI/BOOT/BOOTx64.EFI", args.Installer); err != nil {
+	if err := espRoot.PlaceFile(bootPath, args.Installer); err != nil {
 		return err
 	}
 
@@ -59,17 +67,14 @@
 			return err
 		}
 	}
-	if args.Image != nil {
-		imageLayout, err := oci.CreateLayout(args.Image)
-		if err != nil {
-			return err
-		}
-		if err := espRoot.PlaceDir("metropolis-installer/osimage", imageLayout); err != nil {
-			return err
-		}
+	imageLayout, err := oci.CreateLayout(args.Image)
+	if err != nil {
+		return err
+	}
+	if err := espRoot.PlaceDir("metropolis-installer/osimage", imageLayout); err != nil {
+		return err
 	}
 	var targetDev blockdev.BlockDev
-	var err error
 	targetDev, err = blockdev.Open(args.TargetPath)
 	if err != nil {
 		if errors.Is(err, os.ErrNotExist) {
diff --git a/metropolis/cli/takeover/install.go b/metropolis/cli/takeover/install.go
index 1bd00e6..37068ed 100644
--- a/metropolis/cli/takeover/install.go
+++ b/metropolis/cli/takeover/install.go
@@ -88,6 +88,7 @@
 			System: 4096,
 			Data:   128,
 		},
+		Architecture:   osImage.Config.ProductInfo.Architecture(),
 		SystemImage:    systemImage,
 		EFIPayload:     efiPayload,
 		ABLoader:       structfs.Bytes(abloader),