Build mkfs.xfs using rules_cc

This drops the old big genrule for mkfs.xfs and replaces it with a nice rules_cc build system
with the help of bazel_cc_fix generated patches and our musl-based toolchain.
While we're at it I bumped the versions of all related dependencies to their latest stable release.
This also means pulling in ini.h which is a dependency of the new xfstools version.

Instructions to regenerate the patches are included in the spec files.

Toolchain selection is done by the existing transition in our rootfs rule so we automatically get a musl-built
static binary when building for the rootfs.

Test Plan: Tested with E2E tests, should fail fairly catastrophically if something were wrong.

X-Origin-Diff: phab/D708
GitOrigin-RevId: 648a05cdd08cfa84a8a9f4c057c52446e7005631
diff --git a/metropolis/node/BUILD.bazel b/metropolis/node/BUILD.bazel
index 9d6957e..f037cf6 100644
--- a/metropolis/node/BUILD.bazel
+++ b/metropolis/node/BUILD.bazel
@@ -32,7 +32,6 @@
     ],
     files = {
         "//metropolis/node/core": "/init",
-        "//third_party/xfsprogs:mkfs.xfs": "/bin/mkfs.xfs",
 
         # CA Certificate bundle & os-release & resolv.conf
         # These should not be explicitly used by Metropolis code and are only here for compatibility with
@@ -77,6 +76,7 @@
     files_cc = {
         # runc runtime, with cgo
         "@com_github_opencontainers_runc//:runc": "/containerd/bin/runc",
+        "@xfsprogs//:mkfs": "/bin/mkfs.xfs",
     },
     symlinks = {
         "/ephemeral/machine-id": "/etc/machine-id",
diff --git a/metropolis/node/build/def.bzl b/metropolis/node/build/def.bzl
index 39af192..d28280b 100644
--- a/metropolis/node/build/def.bzl
+++ b/metropolis/node/build/def.bzl
@@ -195,7 +195,8 @@
         arguments = ["-l", initramfs_raw.path, initramfs.path],
     )
 
-    return [DefaultInfo(files = depset([initramfs]))]
+    # TODO(q3k): Document why this is needed
+    return [DefaultInfo(runfiles = ctx.runfiles(files = [initramfs]), files = depset([initramfs]))]
 
 node_initramfs = rule(
     implementation = _node_initramfs_impl,
diff --git a/metropolis/node/core/network/dhcp4c/callback/BUILD.bazel b/metropolis/node/core/network/dhcp4c/callback/BUILD.bazel
index 6d81e6e..622fb48 100644
--- a/metropolis/node/core/network/dhcp4c/callback/BUILD.bazel
+++ b/metropolis/node/core/network/dhcp4c/callback/BUILD.bazel
@@ -33,8 +33,5 @@
 )
 
 ktest(
-    cmdline = "",
-    initramfs_extra = "",
     tester = ":go_default_test",
-    deps = [],
 )
diff --git a/metropolis/pkg/erofs/BUILD.bazel b/metropolis/pkg/erofs/BUILD.bazel
index 7014e87..af484a8 100644
--- a/metropolis/pkg/erofs/BUILD.bazel
+++ b/metropolis/pkg/erofs/BUILD.bazel
@@ -33,7 +33,5 @@
 
 ktest(
     cmdline = "ramdisk_size=128",
-    initramfs_extra = "",
     tester = ":go_default_test",
-    deps = [],
 )
diff --git a/metropolis/pkg/fsquota/BUILD.bazel b/metropolis/pkg/fsquota/BUILD.bazel
index f4e11d3..dbeb19b 100644
--- a/metropolis/pkg/fsquota/BUILD.bazel
+++ b/metropolis/pkg/fsquota/BUILD.bazel
@@ -29,11 +29,8 @@
 
 ktest(
     cmdline = "ramdisk_size=51200",
-    initramfs_extra = """
-file /mkfs.xfs $(location //third_party/xfsprogs:mkfs.xfs) 0755 0 0
-    """,
+    files_cc = {
+        "@xfsprogs//:mkfs": "/mkfs.xfs",
+    },
     tester = ":go_default_test",
-    deps = [
-        "//third_party/xfsprogs:mkfs.xfs",
-    ],
 )
diff --git a/metropolis/test/ktest/ktest.bzl b/metropolis/test/ktest/ktest.bzl
index de8dc1e..2462603 100644
--- a/metropolis/test/ktest/ktest.bzl
+++ b/metropolis/test/ktest/ktest.bzl
@@ -18,29 +18,23 @@
 Ktest provides a macro to run tests under a normal Metropolis node kernel
 """
 
-def ktest(deps, tester, initramfs_extra, cmdline):
-    native.genrule(
+load("//metropolis/node/build:def.bzl", "node_initramfs")
+
+def _dict_union(x, y):
+    z = {}
+    z.update(x)
+    z.update(y)
+    return z
+
+def ktest(tester, cmdline = "", files = {}, files_cc = {}):
+    node_initramfs(
         name = "test_initramfs",
-        srcs = [
-            "//metropolis/test/ktest/init",
-        ] + deps + [tester],
-        outs = [
-            "initramfs.cpio.lz4",
-        ],
+        files = _dict_union({
+            "//metropolis/test/ktest/init": "/init",
+            tester: "/tester",
+        }, files),
+        files_cc = files_cc,
         testonly = True,
-        cmd = """
-        $(location @linux//:gen_init_cpio) - <<- 'EOF' | lz4 -l > \"$@\" 
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-nod /dev/null 0644 0 0 c 1 3
-file /init $(location //metropolis/test/ktest/init) 0755 0 0
-file /tester $(location """ + tester + """) 0755 0 0
-""" + initramfs_extra + """
-EOF
-        """,
-        tools = [
-            "@linux//:gen_init_cpio",
-        ],
     )
 
     native.sh_test(