diff --git a/kernel.ts b/kernel.ts index 4797742..84bcd21 100644 --- a/kernel.ts +++ b/kernel.ts @@ -1,6 +1,7 @@ -import { copyFile, rm } from "node:fs/promises"; +import { copyFile, readFile, rm, writeFile } from "node:fs/promises"; import path from "node:path"; import { Alpine } from "./alpine.js"; +import { execFile } from "./helpers/better-api.js"; export type Kind = "lts" | "virt"; export type Kernel = { @@ -60,10 +61,36 @@ default=lts await alpine.writeFile( "/etc/mkinitfs/mkinitfs.conf", - `features="${features.join(" ")}"` + `features="${features.join(" ")}" +disable_trigger=yes` ); - await alpine.installPackages([`linux-${kind}`]); + await alpine.installPackages([`linux-${kind}`, "zstd"]); + + // patch mkinitfs to use faster zstd + const mkinitfs = alpine.path("/sbin/mkinitfs"); + const newMkinitfs = (await readFile(mkinitfs, "utf-8")).replace( + 'comp="zstd -19"', + 'comp="zstd -3"' + ); + await writeFile(mkinitfs, newMkinitfs); + + const kernelRelease = ( + await readFile( + alpine.path(`/usr/share/kernel/${kind}/kernel.release`), + "utf-8" + ) + ).trim(); + // run mkinitfs manually as trigger was diabled + await execFile("chroot", [ + alpine.dir, + "mkinitfs", + "-C", + "zstd", + "-o", + `/boot/initramfs-${kind}`, + kernelRelease, + ]); const initramfs = path.join(alpine.dir, `/boot/initramfs-${kind}`); const vmlinuz = path.join(alpine.dir, `/boot/vmlinuz-${kind}`);