This commit is contained in:
Cat /dev/Nulo 2023-01-23 12:30:21 -03:00
parent 8d4e6db7d2
commit 214e7342ae
2 changed files with 52 additions and 3 deletions

View file

@ -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 {}

38
kernel.ts Normal file
View file

@ -0,0 +1,38 @@
import { Alpine } from "./alpine";
export async function setupKernel(alpine: Alpine): Promise<void> {
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"]);
}