Split up linux_kernel build folder to separate repo changes

This separates the kernel build steps (that happen in our main repo)
and the things we inject into @linux_kernel.

Test Plan: Covered by CI

X-Origin-Diff: phab/D249
GitOrigin-RevId: 98982d005ba582f9f08783915ee0603ff8634f55
diff --git a/WORKSPACE b/WORKSPACE
index 7abd0c6..9401162 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -94,22 +94,16 @@
 
 linux_kernel_version = "4.19.72"
 
-# If we don't do this we're double-building Linux, once for the toolchain and once for the target
-make_gen_init_cpio_available = """
-load("@rules_cc//cc:defs.bzl", "cc_binary")
-cc_binary(name = "gen_init_cpio", srcs = ["usr/gen_init_cpio.c"], visibility = ["//visibility:public"])
-"""
-
 http_archive(
     name = "linux_kernel",
-    build_file_content = all_content + "\n" + make_gen_init_cpio_available,
+    build_file = "@//core/build/linux_kernel_repo:BUILD",
     patch_args = ["-p1"],
     patches = [
         # Fix is in mainline, but upstream hasn't backported it to 4.19.
         # Will go away when we switch to 5.4 LTS
-        "@//core/build/linux_kernel:kbuild-add--fcf-protection-none-to-retpoline-flags.patch",
+        "@//core/build/linux_kernel_repo:0002-kbuild-add--fcf-protection-none-to-retpoline-flags.patch",
         # Enable built-in cmdline for efistub
-        "@//core/build/linux_kernel:0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch",
+        "@//core/build/linux_kernel_repo:0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch",
     ],
     sha256 = "f9fcb6b3bd29115ac55fc154e300c3dce2044502732f6842ad6c25e6f9f51f6d",
     strip_prefix = "linux-" + linux_kernel_version,
diff --git a/core/build/linux_kernel/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch b/core/build/linux_kernel_repo/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
similarity index 100%
rename from core/build/linux_kernel/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
rename to core/build/linux_kernel_repo/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
diff --git a/core/build/linux_kernel/kbuild-add--fcf-protection-none-to-retpoline-flags.patch b/core/build/linux_kernel_repo/0002-kbuild-add--fcf-protection-none-to-retpoline-flags.patch
similarity index 100%
rename from core/build/linux_kernel/kbuild-add--fcf-protection-none-to-retpoline-flags.patch
rename to core/build/linux_kernel_repo/0002-kbuild-add--fcf-protection-none-to-retpoline-flags.patch
diff --git a/core/build/linux_kernel_repo/BUILD b/core/build/linux_kernel_repo/BUILD
new file mode 100644
index 0000000..ed035ee
--- /dev/null
+++ b/core/build/linux_kernel_repo/BUILD
@@ -0,0 +1,14 @@
+filegroup(
+    name = "all",
+    srcs = glob(["**"]),
+    visibility = ["//visibility:public"],
+)
+
+load("@rules_cc//cc:defs.bzl", "cc_binary")
+
+# Build gen_init_cpio separately for the initramfs generation stage
+cc_binary(
+    name = "gen_init_cpio",
+    srcs = ["usr/gen_init_cpio.c"],
+    visibility = ["//visibility:public"],
+)