osbase/build/mkimage: delete package

We no longer use pre-build disk images for cluster launch, and it also
doesn't make sense to distribute these as release artifacts. This means
we no longer need mkimage.

Change-Id: I72aa376561c91e114a80367f814b03434c82355f
Reviewed-on: https://review.monogon.dev/c/monogon/+/4295
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/BUILD.bazel b/metropolis/node/BUILD.bazel
index ff24cca..fd6dbcc 100644
--- a/metropolis/node/BUILD.bazel
+++ b/metropolis/node/BUILD.bazel
@@ -2,7 +2,6 @@
 load("@rules_pkg//:pkg.bzl", "pkg_zip")
 load("//osbase/build/genproductinfo:defs.bzl", "product_info")
 load("//osbase/build/mkerofs:def.bzl", "erofs_image")
-load("//osbase/build/mkimage:def.bzl", "node_image")
 load("//osbase/build/mkoci:def.bzl", "oci_os_image")
 load("//osbase/build/mkpayload:def.bzl", "efi_unified_kernel_image")
 load("//osbase/build/mkverity:def.bzl", "verity_image")
@@ -163,19 +162,6 @@
     visibility = ["//visibility:public"],
 )
 
-node_image(
-    name = "image",
-    abloader = "//metropolis/node/abloader",
-    bios_bootcode = "//metropolis/node/bios_bootcode",
-    kernel = ":kernel_efi",
-    system = ":verity_rootfs",
-    visibility = [
-        "//metropolis/cli/metroctl/test:__subpackages__",
-        "//metropolis/test/e2e:__subpackages__",
-        "//metropolis/test/launch:__subpackages__",
-    ],
-)
-
 product_info(
     name = "product_info",
     components = [
diff --git a/osbase/build/mkimage/BUILD.bazel b/osbase/build/mkimage/BUILD.bazel
deleted file mode 100644
index aba561e..0000000
--- a/osbase/build/mkimage/BUILD.bazel
+++ /dev/null
@@ -1,19 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
-
-go_library(
-    name = "mkimage_lib",
-    srcs = ["main.go"],
-    importpath = "source.monogon.dev/osbase/build/mkimage",
-    visibility = ["//visibility:private"],
-    deps = [
-        "//osbase/blockdev",
-        "//osbase/build/mkimage/osimage",
-        "//osbase/structfs",
-    ],
-)
-
-go_binary(
-    name = "mkimage",
-    embed = [":mkimage_lib"],
-    visibility = ["//metropolis/node:__pkg__"],
-)
diff --git a/osbase/build/mkimage/def.bzl b/osbase/build/mkimage/def.bzl
deleted file mode 100644
index b8239f5..0000000
--- a/osbase/build/mkimage/def.bzl
+++ /dev/null
@@ -1,90 +0,0 @@
-def _node_image_impl(ctx):
-    img_file = ctx.actions.declare_file(ctx.label.name + ".img")
-
-    arguments = ctx.actions.args()
-    arguments.add_all([
-        "-architecture",
-        ctx.attr.architecture,
-        "-efi",
-        ctx.file.kernel.path,
-        "-system",
-        ctx.file.system.path,
-        "-abloader",
-        ctx.file.abloader.path,
-        "-out",
-        img_file.path,
-    ])
-
-    if len(ctx.files.bios_bootcode) != 0:
-        arguments.add_all(["-bios_bootcode", ctx.file.bios_bootcode.path])
-
-    ctx.actions.run(
-        mnemonic = "MkImage",
-        executable = ctx.executable._mkimage,
-        arguments = [arguments],
-        inputs = [
-            ctx.file.kernel,
-            ctx.file.system,
-            ctx.file.abloader,
-            ctx.file.bios_bootcode,
-        ],
-        outputs = [img_file],
-    )
-
-    return [DefaultInfo(files = depset([img_file]), runfiles = ctx.runfiles(files = [img_file]))]
-
-_node_image = rule(
-    implementation = _node_image_impl,
-    doc = """
-        Build a disk image from an EFI kernel payload, ABLoader and system partition
-        contents. See //osbase/build/mkimage for more information.
-    """,
-    attrs = {
-        "architecture": attr.string(mandatory = True),
-        "kernel": attr.label(
-            doc = "EFI binary containing a kernel.",
-            mandatory = True,
-            allow_single_file = True,
-        ),
-        "system": attr.label(
-            doc = "Contents of the system partition.",
-            mandatory = True,
-            allow_single_file = True,
-        ),
-        "abloader": attr.label(
-            doc = "ABLoader binary",
-            mandatory = True,
-            allow_single_file = True,
-        ),
-        "bios_bootcode": attr.label(
-            doc = """
-            Optional label to the BIOS bootcode which gets placed at the start of the first block of the image.
-            Limited to 440 bytes, padding is not required. It is only used by legacy BIOS boot.
-        """,
-            mandatory = False,
-            allow_single_file = True,
-        ),
-        "_mkimage": attr.label(
-            doc = "The mkimage executable.",
-            default = "//osbase/build/mkimage",
-            allow_single_file = True,
-            executable = True,
-            cfg = "exec",
-        ),
-    },
-)
-
-def _node_image_macro_impl(**kwargs):
-    _node_image(
-        architecture = select({
-            "@platforms//cpu:x86_64": "x86_64",
-            "@platforms//cpu:aarch64": "aarch64",
-        }),
-        **kwargs
-    )
-
-node_image = macro(
-    inherit_attrs = _node_image,
-    attrs = {"architecture": None},
-    implementation = _node_image_macro_impl,
-)
diff --git a/osbase/build/mkimage/main.go b/osbase/build/mkimage/main.go
deleted file mode 100644
index 3e8d740..0000000
--- a/osbase/build/mkimage/main.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright The Monogon Project Authors.
-// SPDX-License-Identifier: Apache-2.0
-
-// mkimage is a tool to generate node disk images.
-// It can be used both to initialize block devices and to create image
-// files.
-//
-// 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 (
-	_ "embed"
-	"flag"
-	"log"
-	"os"
-
-	"source.monogon.dev/osbase/blockdev"
-	"source.monogon.dev/osbase/build/mkimage/osimage"
-	"source.monogon.dev/osbase/structfs"
-)
-
-func main() {
-	// Fill in the image parameters based on flags.
-	var (
-		efiPayload          string
-		systemImage         string
-		abLoaderPayload     string
-		biosBootCodePayload 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(&biosBootCodePayload, "bios_bootcode", "", "Optional path to the BIOS bootcode which gets placed at the start of the first block of the image. Limited to 440 bytes, padding is not required. It is only used by legacy BIOS boot.")
-	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.StringVar(&cfg.Architecture, "architecture", "", "CPU architecture")
-	flag.Int64Var(&cfg.PartitionSize.Data, "data_partition_size", 2048, "Override the data partition size (default 2048 MiB). Used only when generating image files.")
-	flag.Int64Var(&cfg.PartitionSize.ESP, "esp_partition_size", 128, "Override the ESP partition size (default: 128MiB)")
-	flag.Int64Var(&cfg.PartitionSize.System, "system_partition_size", 1024, "Override the System partition size (default: 1024MiB)")
-	flag.StringVar(&diskUUID, "GUID", "", "Disk GUID marked in the resulting image's partition table (default: randomly generated)")
-	flag.Parse()
-
-	// Open the input files for osimage.Create, fill in reader objects and
-	// metadata in osimage.Params.
-	// Start with the EFI Payload the OS will boot from.
-	var err error
-	cfg.EFIPayload, err = structfs.OSPathBlob(efiPayload)
-	if err != nil {
-		log.Fatalf("while opening the EFI payload at %q: %v", efiPayload, err)
-	}
-
-	cfg.ABLoader, err = structfs.OSPathBlob(abLoaderPayload)
-	if err != nil {
-		log.Fatalf("while opening the abloader payload at %q: %v", abLoaderPayload, err)
-	}
-
-	// 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.
-	if systemImage != "" {
-		cfg.SystemImage, err = structfs.OSPathBlob(systemImage)
-		if err != nil {
-			log.Fatalf("while opening the system image at %q: %v", systemImage, err)
-		}
-	}
-
-	// Attempt to open the node parameters file if its path is set.
-	if nodeParams != "" {
-		np, err := structfs.OSPathBlob(nodeParams)
-		if err != nil {
-			log.Fatalf("while opening node parameters at %q: %v", nodeParams, err)
-		}
-		cfg.NodeParameters = np
-	}
-
-	if biosBootCodePayload != "" {
-		bp, err := os.ReadFile(biosBootCodePayload)
-		if err != nil {
-			log.Fatalf("while opening BIOS bootcode at %q: %v", biosBootCodePayload, err)
-		}
-		cfg.BIOSBootCode = bp
-	}
-
-	// TODO(#254): Build and use dynamically-grown block devices
-	cfg.Output, err = blockdev.CreateFile(outputPath, 512, 10*1024*1024)
-	if err != nil {
-		panic(err)
-	}
-
-	// Write the parametrized OS image.
-	if _, err := osimage.Write(&cfg); err != nil {
-		log.Fatalf("while creating a Metropolis OS image: %v", err)
-	}
-}