Move linux to //third_party.
Test Plan: refactor of build system, should be covered by existing tests
X-Origin-Diff: phab/D367
GitOrigin-RevId: 603c61bfadadfbd66c0ce31f05f6748251bea9f3
diff --git a/WORKSPACE b/WORKSPACE
index 13807dd..62796fb 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -95,19 +95,19 @@
# Linux kernel
-linux_kernel_version = "5.4.7"
+linux_version = "5.4.7"
http_archive(
- name = "linux_kernel",
- build_file = "//core/build/linux_kernel_repo:BUILD.repo",
+ name = "linux",
+ build_file = "//third_party/linux/external:BUILD.repo",
patch_args = ["-p1"],
patches = [
# Enable built-in cmdline for efistub
- "//core/build/linux_kernel_repo:0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch",
+ "//third_party/linux/external:0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch",
],
sha256 = "abc9b21d9146d95853dac35f4c4489a0199aff53ee6eee4b0563d1b37079fcc9",
- strip_prefix = "linux-" + linux_kernel_version,
- urls = ["https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-%s.tar.xz" % linux_kernel_version],
+ strip_prefix = "linux-" + linux_version,
+ urls = ["https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-%s.tar.xz" % linux_version],
)
# EDK2
diff --git a/core/BUILD b/core/BUILD
index d2d6e33..bd49753 100644
--- a/core/BUILD
+++ b/core/BUILD
@@ -1,16 +1,42 @@
genrule(
+ name = "initramfs",
+ srcs = [
+ "//core/cmd/init",
+ "//core/build/utils:mkfs.xfs",
+ "//core/cmd/kube-controlplane",
+ ],
+ outs = [
+ "initramfs.cpio.lz4",
+ ],
+ 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 //core/cmd/init) 0755 0 0
+dir /bin 0755 0 0
+file /bin/mkfs.xfs $(location //core/build/utils:mkfs.xfs) 0755 0 0
+file /bin/kube-controlplane $(location //core/cmd/kube-controlplane) 0755 0 0
+EOF
+ """,
+ tools = [
+ "@linux//:gen_init_cpio",
+ ],
+)
+
+genrule(
name = "image",
srcs = [
- "//core/build/linux_kernel:bzImage",
- "//core/build/linux_kernel:initramfs",
+ "//third_party/linux:bzImage",
+ ":initramfs",
],
outs = [
"smalltown.img",
],
cmd = """
$(location //core/cmd/mkimage) \
- -efi $(location //core/build/linux_kernel:bzImage) \
- -initramfs $(location //core/build/linux_kernel:initramfs) \
+ -efi $(location //third_party/linux:bzImage) \
+ -initramfs $(location :initramfs) \
-out $@
""",
tools = [
diff --git a/core/build/linux_kernel/BUILD b/core/build/linux_kernel/BUILD
deleted file mode 100644
index 625dd5c..0000000
--- a/core/build/linux_kernel/BUILD
+++ /dev/null
@@ -1,49 +0,0 @@
-genrule(
- name = "kernel",
- srcs = [
- "@linux_kernel//:all",
- "linux-smalltown.config",
- ],
- outs = [
- "bzImage",
- ],
- cmd = """
- DIR=external/linux_kernel
-
- mkdir $$DIR/.bin
-
- cp $(location linux-smalltown.config) $$DIR/.config
-
- (cd $$DIR && make -j $$(nproc)) >/dev/null
-
- cp $$DIR/arch/x86/boot/bzImage $(RULEDIR)
- """,
- visibility = ["//visibility:public"],
-)
-
-genrule(
- name = "initramfs",
- srcs = [
- "//core/cmd/init",
- "//core/build/utils:mkfs.xfs",
- "//core/cmd/kube-controlplane",
- ],
- outs = [
- "initramfs.cpio.lz4",
- ],
- cmd = """
- $(location @linux_kernel//: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 //core/cmd/init) 0755 0 0
-dir /bin 0755 0 0
-file /bin/mkfs.xfs $(location //core/build/utils:mkfs.xfs) 0755 0 0
-file /bin/kube-controlplane $(location //core/cmd/kube-controlplane) 0755 0 0
-EOF
- """,
- tools = [
- "@linux_kernel//:gen_init_cpio",
- ],
- visibility = ["//visibility:public"],
-)
diff --git a/core/build/utils/BUILD b/core/build/utils/BUILD
index d49359a..9a8dc68 100644
--- a/core/build/utils/BUILD
+++ b/core/build/utils/BUILD
@@ -27,7 +27,7 @@
"@xfsprogs_dev//:all",
"@musl//:all",
"@util_linux//:all",
- "@linux_kernel//:all",
+ "@linux//:all",
],
outs = [
"mkfs.xfs",
@@ -44,7 +44,7 @@
echo "Installing Linux kernel headers..."
(
- cd external/linux_kernel
+ cd external/linux
make headers_install ARCH=x86_64 INSTALL_HDR_PATH=$$MUSL
) > /dev/null
diff --git a/third_party/linux/BUILD.bazel b/third_party/linux/BUILD.bazel
new file mode 100644
index 0000000..3829f96
--- /dev/null
+++ b/third_party/linux/BUILD.bazel
@@ -0,0 +1,22 @@
+genrule(
+ name = "bzImage",
+ srcs = [
+ "@linux//:all",
+ "linux-smalltown.config",
+ ],
+ outs = [
+ "bzImage",
+ ],
+ cmd = """
+ DIR=external/linux
+
+ mkdir $$DIR/.bin
+
+ cp $(location linux-smalltown.config) $$DIR/.config
+
+ (cd $$DIR && make -j $$(nproc) >/dev/null)
+
+ cp $$DIR/arch/x86/boot/bzImage $(RULEDIR)
+ """,
+ visibility = ["//visibility:public"],
+)
diff --git a/core/build/linux_kernel_repo/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch b/third_party/linux/external/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
similarity index 95%
rename from core/build/linux_kernel_repo/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
rename to third_party/linux/external/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
index 6225591..2fe5284 100644
--- a/core/build/linux_kernel_repo/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
+++ b/third_party/linux/external/0001-x86-Allow-built-in-command-line-to-work-in-early-ker.patch
@@ -1,18 +1,3 @@
-Copyright 2020 The Monogon Project Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-
From 73025c3f822aa19077abe4ece53b03b211faaf52 Mon Sep 17 00:00:00 2001
From: Matthew Garrett <mjg59@coreos.com>
Date: Thu, 9 Apr 2015 13:25:00 -0700
diff --git a/core/build/linux_kernel_repo/BUILD b/third_party/linux/external/BUILD.bazel
similarity index 100%
rename from core/build/linux_kernel_repo/BUILD
rename to third_party/linux/external/BUILD.bazel
diff --git a/core/build/linux_kernel_repo/BUILD.repo b/third_party/linux/external/BUILD.repo
similarity index 100%
rename from core/build/linux_kernel_repo/BUILD.repo
rename to third_party/linux/external/BUILD.repo
diff --git a/core/build/linux_kernel/linux-signos.config b/third_party/linux/linux-smalltown.config
similarity index 100%
rename from core/build/linux_kernel/linux-signos.config
rename to third_party/linux/linux-smalltown.config