osbase/build/mkimage: replace embedsrc abloader reference with argument
rules_rust things that our abloader target itself is an exec target
because it is included as embedsrc inside mkimage. To prevent this wrong
detection we provide it as runfile like the kernel and rootfs. This is
a preparation for updating rust to the current stable version, as it
requires specific overrides to work correctly with our efi toolchain.
Change-Id: I78de6a15570a81d9f673702ec4e50954d604117d
Reviewed-on: https://review.monogon.dev/c/monogon/+/3598
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/osbase/build/mkimage/BUILD.bazel b/osbase/build/mkimage/BUILD.bazel
index 30ba81f..a822c62 100644
--- a/osbase/build/mkimage/BUILD.bazel
+++ b/osbase/build/mkimage/BUILD.bazel
@@ -3,9 +3,6 @@
go_library(
name = "mkimage_lib",
srcs = ["main.go"],
- embedsrcs = [
- "//metropolis/node/core/abloader", #keep
- ],
importpath = "source.monogon.dev/osbase/build/mkimage",
visibility = ["//visibility:private"],
deps = [
diff --git a/osbase/build/mkimage/def.bzl b/osbase/build/mkimage/def.bzl
index 1663e3d..3f9327b 100644
--- a/osbase/build/mkimage/def.bzl
+++ b/osbase/build/mkimage/def.bzl
@@ -8,12 +8,15 @@
ctx.file.kernel.path,
"-system",
ctx.file.system.path,
+ "-abloader",
+ ctx.file.abloader.path,
"-out",
img_file.path,
],
inputs = [
ctx.file.kernel,
ctx.file.system,
+ ctx.file.abloader,
],
outputs = [img_file],
)
@@ -23,7 +26,7 @@
node_image = rule(
implementation = _node_image_impl,
doc = """
- Build a disk image from an EFI kernel payload and system partition
+ Build a disk image from an EFI kernel payload, ABLoader and system partition
contents. See //osbase/build/mkimage for more information.
""",
attrs = {
@@ -37,6 +40,11 @@
mandatory = True,
allow_single_file = True,
),
+ "abloader": attr.label(
+ doc = "ABLoader binary",
+ mandatory = True,
+ allow_single_file = True,
+ ),
"_mkimage": attr.label(
doc = "The mkimage executable.",
default = "//osbase/build/mkimage",
diff --git a/osbase/build/mkimage/main.go b/osbase/build/mkimage/main.go
index e6398cf..37691a9 100644
--- a/osbase/build/mkimage/main.go
+++ b/osbase/build/mkimage/main.go
@@ -18,16 +18,15 @@
// It can be used both to initialize block devices and to create image
// files.
//
-// The tool takes a path to an EFI payload (--efi), and a path to a
-// system image (--system) as its only required inputs. In
-// addition, an output path must be supplied (--out).
+// The tool takes a path to an EFI payload (--efi), a path to a abloader
+// payload (--abloader) and a path to a system image (--system) as its only
+// required inputs. In addition, an output path must be supplied (--out).
// Node parameters file path (--node_parameters) may also be supplied, in
// which case the file will be copied to the EFI system partition.
// Partition sizes are fixed and may be overridden by command line flags.
package main
import (
- "bytes"
_ "embed"
"flag"
"log"
@@ -38,21 +37,20 @@
"source.monogon.dev/osbase/build/mkimage/osimage"
)
-//go:embed metropolis/node/core/abloader/abloader.efi
-var abloader []byte
-
func main() {
// Fill in the image parameters based on flags.
var (
- efiPayload string
- systemImage string
- nodeParams string
- outputPath string
- diskUUID string
- cfg osimage.Params
+ efiPayload string
+ systemImage string
+ abLoaderPayload string
+ nodeParams string
+ outputPath string
+ diskUUID string
+ cfg osimage.Params
)
flag.StringVar(&efiPayload, "efi", "", "Path to the UEFI payload used")
flag.StringVar(&systemImage, "system", "", "Path to the system partition image used")
+ flag.StringVar(&abLoaderPayload, "abloader", "", "Path to the abloader payload used")
flag.StringVar(&nodeParams, "node_parameters", "", "Path to Node Parameters to be written to the ESP (default: don't write Node Parameters)")
flag.StringVar(&outputPath, "out", "", "Path to the resulting disk image or block device")
flag.Int64Var(&cfg.PartitionSize.Data, "data_partition_size", 2048, "Override the data partition size (default 2048 MiB). Used only when generating image files.")
@@ -70,6 +68,12 @@
}
cfg.EFIPayload = p
+ ab, err := blkio.NewFileReader(abLoaderPayload)
+ if err != nil {
+ log.Fatalf("while opening the abloader payload at %q: %v", abLoaderPayload, err)
+ }
+ cfg.ABLoader = ab
+
// Attempt to open the system image if its path is set. In case the path
// isn't set, the system partition will still be created, but no
// contents will be written into it.
@@ -97,8 +101,6 @@
panic(err)
}
- cfg.ABLoader = bytes.NewReader(abloader)
-
// Write the parametrized OS image.
if _, err := osimage.Write(&cfg); err != nil {
log.Fatalf("while creating a Metropolis OS image: %v", err)