import { mkdir, mkdtemp } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import { Alpine } from "./alpine.js"; import { spawn } from "./helpers.js"; import { Runit } from "./runit/index.js"; { 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 makeService({ // parentDir: rootfsDir, // name: "grafana", // packages: ["grafana"], // setup: async (dir) => {}, // initScript: async (dir) => {}, // }); try { await spawn("sudo", ["chroot", rootfsDir], { stdio: "inherit" }); } catch {} } // interface Service {} // async function makeService({ // parentDir, // name, // packages, // setup, // initScript: _initScript, // }: { // parentDir: string; // name: string; // packages?: string[]; // setup: (dir: string) => Promise; // initScript: (dir: string) => Promise; // }) { // const rootsDir = path.join(parentDir, "/nulo/roots/"); // await mkdir(rootsDir, { recursive: true }); // const alpine = await Alpine.makeWorld({ // dir: path.join(rootsDir, name), // packages, // }); // await setup(alpine.dir); // // const initScript = await _initScript(rootfsDir); // }