From 214e7342ae4e88fbc32b81e089ad5571e307ec1f Mon Sep 17 00:00:00 2001 From: Nulo Date: Mon, 23 Jan 2023 12:30:21 -0300 Subject: [PATCH] kernel --- index.ts | 17 ++++++++++++++--- kernel.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 kernel.ts diff --git a/index.ts b/index.ts index 09d61a6..f7b402a 100644 --- a/index.ts +++ b/index.ts @@ -1,15 +1,26 @@ import { mkdir, mkdtemp } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; +import { cwd } from "node:process"; import { Alpine } from "./alpine.js"; import { spawn } from "./helpers.js"; +import { setupKernel } from "./kernel.js"; import { Runit } from "./runit/index.js"; { + console.time("Building"); + const rootfsDir = await mkdtemp(path.join(tmpdir(), "define-alpine-")); console.debug(rootfsDir); const alpine = await Alpine.makeWorld({ dir: rootfsDir }); const runit = await Runit.setup(alpine); + await setupKernel(alpine); + + console.timeEnd("Building"); + + const artifactsDir = path.join(cwd(), "artifacts/"); + await mkdir(artifactsDir); + // await makeService({ // parentDir: rootfsDir, // name: "grafana", @@ -17,9 +28,9 @@ import { Runit } from "./runit/index.js"; // setup: async (dir) => {}, // initScript: async (dir) => {}, // }); - try { - await spawn("sudo", ["chroot", rootfsDir], { stdio: "inherit" }); - } catch {} + // try { + // await spawn("sudo", ["chroot", rootfsDir], { stdio: "inherit" }); + // } catch {} } // interface Service {} diff --git a/kernel.ts b/kernel.ts new file mode 100644 index 0000000..570524b --- /dev/null +++ b/kernel.ts @@ -0,0 +1,38 @@ +import { Alpine } from "./alpine"; + +export async function setupKernel(alpine: Alpine): Promise { + await alpine.writeFile( + "/etc/update-extlinux.conf", + `# configuration for extlinux config builder + +# Overwrite current /boot/extlinux.conf. +overwrite=1 + +# vesa_menu +# use fancy vesa menu (vesamenu.c32) menus, won't work with serial +vesa_menu=1 + +#default_kernel_opts=quiet +default_kernel_opts= +modules=loop,squashfs,sd-mod,usb-storage,ext4,vfat + +# root device - if not specified, will be guessed using +# blkid -o export /dev/root +root=/dev/sda + +# if set to non-zero, update-extlinux will be a lot more verbose. +verbose=0 + +hidden=0 +timeout=3 +default=lts +` + ); + + await alpine.writeFile( + "/etc/mkinitfs/mkinitfs.conf", + 'features="squashfs ata base cdrom ext4 keymap kms mmc nvme scsi usb virtio"' + ); + + await alpine.addPackages(["linux-virt"]); +}