kernel: comprimir más rápido
This commit is contained in:
parent
3f9b11c76f
commit
2e9045f4c3
1 changed files with 30 additions and 3 deletions
33
kernel.ts
33
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 path from "node:path";
|
||||||
import { Alpine } from "./alpine.js";
|
import { Alpine } from "./alpine.js";
|
||||||
|
import { execFile } from "./helpers/better-api.js";
|
||||||
|
|
||||||
export type Kind = "lts" | "virt";
|
export type Kind = "lts" | "virt";
|
||||||
export type Kernel = {
|
export type Kernel = {
|
||||||
|
@ -60,10 +61,36 @@ default=lts
|
||||||
|
|
||||||
await alpine.writeFile(
|
await alpine.writeFile(
|
||||||
"/etc/mkinitfs/mkinitfs.conf",
|
"/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 initramfs = path.join(alpine.dir, `/boot/initramfs-${kind}`);
|
||||||
const vmlinuz = path.join(alpine.dir, `/boot/vmlinuz-${kind}`);
|
const vmlinuz = path.join(alpine.dir, `/boot/vmlinuz-${kind}`);
|
||||||
|
|
Loading…
Reference in a new issue