Replace build system with a Bazel-based one
This pins our external dependencies and introduces a mostly-hermetic build where all dependencies are explicitly declared and rebuilt if needed.
Necessary prerequite for a proper CI workflow. Since Bazel can cache build artifacts, we can remove the hardcoded binary artifacts from the repo.
As suggested in our discussions, the genrule that builds mkfs.xfs is basically doing the same as the previous build_artifacts.sh script (see source code comments for rationale).
The main issue at this point is that the `build/linux_kernel:image` target rebuilds the kernel each time any of its inputs (like cmd/init)
change. This is very hard to fix without compromising on hermeticity, porting kbuild to Bazel (no thanks) or injecting the initramfs into the
kernel image in a separate rule (might just work, but the kernel build rule would either have custom code, or a massive set of outputs).
Perhaps we could use a separate initramfs for development? Or deliberately poke holes into Bazel's sandbox to reuse kernel build?
Test Plan:
Run this in a fresh container with empty Bazel cache:
bazelisk run scripts:launch
... and watch as Bazel rebuilds the world.
X-Origin-Diff: phab/D197
GitOrigin-RevId: 21eea0e213a50e1c4ad25b2ac2bb87c53e36ea6d
diff --git a/internal/storage/BUILD.bazel b/internal/storage/BUILD.bazel
new file mode 100644
index 0000000..2fe8f56
--- /dev/null
+++ b/internal/storage/BUILD.bazel
@@ -0,0 +1,22 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+
+go_library(
+ name = "go_default_library",
+ srcs = [
+ "blockdev.go",
+ "data.go",
+ "find.go",
+ "xfs.go",
+ ],
+ importpath = "git.monogon.dev/source/smalltown.git/internal/storage",
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//internal/common:go_default_library",
+ "//pkg/devicemapper:go_default_library",
+ "//pkg/sysfs:go_default_library",
+ "//pkg/tpm:go_default_library",
+ "@com_github_rekby_gpt//:go_default_library",
+ "@org_golang_x_sys//unix:go_default_library",
+ "@org_uber_go_zap//:go_default_library",
+ ],
+)