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"]); +}