Build core with separate initramfs
Build the initramfs separately and include it via mkimage. Also includes
a patch to the kernel which adds support for hardcoded cmdline
to the Linux efistub.
This lowers build times by a lot, for normal changes they are now
below 5s
Test Plan: Ran `bazel run //core/scripts:launch`
X-Origin-Diff: phab/D245
GitOrigin-RevId: 206c7c5c979c10ffd25c36dfefd8b9290a6a3f43
diff --git a/core/cmd/mkimage/main.go b/core/cmd/mkimage/main.go
index a727e8b..a356ca5 100644
--- a/core/cmd/mkimage/main.go
+++ b/core/cmd/mkimage/main.go
@@ -35,7 +35,7 @@
func main() {
if len(os.Args) < 3 {
- fmt.Println("Usage: mkimage <UEFI payload> <image path>")
+ fmt.Println("Usage: mkimage <UEFI payload> <output image path> <initramfs (optional)>")
os.Exit(2)
}
_ = os.Remove(os.Args[2])
@@ -55,12 +55,12 @@
Type: gpt.EFISystemPartition,
Name: "ESP",
Start: mibToSectors(1),
- End: mibToSectors(128) - 1,
+ End: mibToSectors(256) - 1,
},
{
Type: SmalltownDataPartition,
Name: "SIGNOS-DATA",
- Start: mibToSectors(128),
+ Start: mibToSectors(256),
End: mibToSectors(2560) - 1,
},
},
@@ -104,6 +104,28 @@
fmt.Printf("Failed to write EFI payload: %v", err)
os.Exit(1)
}
+ initramfs, err := fs.OpenFile("/EFI/smalltown/initramfs.cpio.lz4", os.O_CREATE|os.O_RDWR)
+ if err != nil {
+ fmt.Printf("Failed to open initramfs for writing: %v", err)
+ os.Exit(1)
+ }
+ // If we have more than two arguments, the second one is the initramfs
+ if len(os.Args) > 3 {
+ initramfsSrc, err := os.Open(os.Args[3])
+ if err != nil {
+ fmt.Printf("Failed to open initramfs for reading: %v", err)
+ os.Exit(1)
+ }
+ initramfsFull, err := ioutil.ReadAll(initramfsSrc)
+ if err != nil {
+ fmt.Printf("Failed to read initramfs: %v", err)
+ os.Exit(1)
+ }
+ if _, err := initramfs.Write(initramfsFull); err != nil {
+ fmt.Printf("Failed to write initramfs: %v", err)
+ os.Exit(1)
+ }
+ }
if err := diskImg.File.Close(); err != nil {
fmt.Printf("Failed to write image: %v", err)
os.Exit(1)