A convenient CLI tool to quickly spin up DragonflyBSD virtual machines using QEMU with sensible defaults.

Merge pull request #1 from tsirysndr/feat/macos-support

Enhance cross-platform support by adding ARM architecture targets and improve disk size checks using a constant for threshold

authored by tsiry-sandratraina.com and committed by

GitHub 9b6df59b 011a6547

+10 -7
+2
.github/workflows/release.yml
··· 11 11 matrix: 12 12 target: 13 13 - x86_64-unknown-linux-gnu 14 + - aarch64-unknown-linux-gnu 14 15 - x86_64-apple-darwin 16 + - aarch64-apple-darwin 15 17 steps: 16 18 - uses: actions/checkout@v3 17 19 - name: Setup Fluent CI
+1 -1
deno.json
··· 1 1 { 2 2 "name": "@tsiry/dflybsd-up", 3 - "version": "0.1.1", 3 + "version": "0.1.2", 4 4 "exports": "./main.ts", 5 5 "license": "MPL-2.0", 6 6 "tasks": {
+1
src/constants.ts
··· 1 1 export const CONFIG_DIR: string = `${Deno.env.get("HOME")}/.dflybsd-up`; 2 2 export const DB_PATH: string = `${CONFIG_DIR}/state.sqlite`; 3 3 export const LOGS_DIR: string = `${CONFIG_DIR}/logs`; 4 + export const EMPTY_DISK_THRESHOLD_KB = 100;
+1 -1
src/subcommands/restart.ts
··· 30 30 31 31 const qemuArgs = [ 32 32 ..._.compact([vm.bridge && "qemu-system-x86_64"]), 33 - "-enable-kvm", 33 + ..._.compact(Deno.build.os === "linux" && ["-enable-kvm"]), 34 34 "-cpu", 35 35 vm.cpu, 36 36 "-m",
+1 -1
src/subcommands/start.ts
··· 16 16 17 17 const qemuArgs = [ 18 18 ..._.compact([vm.bridge && "qemu-system-x86_64"]), 19 - "-enable-kvm", 19 + ..._.compact(Deno.build.os === "linux" && ["-enable-kvm"]), 20 20 "-cpu", 21 21 vm.cpu, 22 22 "-m",
+4 -4
src/utils.ts
··· 2 2 import chalk from "chalk"; 3 3 import _ from "lodash"; 4 4 import Moniker from "moniker"; 5 - import { LOGS_DIR } from "./constants.ts"; 5 + import { EMPTY_DISK_THRESHOLD_KB, LOGS_DIR } from "./constants.ts"; 6 6 import { generateRandomMacAddress } from "./network.ts"; 7 7 import { saveInstanceState, updateInstanceState } from "./state.ts"; 8 8 ··· 40 40 } 41 41 42 42 const size = await du(path); 43 - return size < 10; 43 + return size < EMPTY_DISK_THRESHOLD_KB; 44 44 } 45 45 46 46 export async function downloadIso( ··· 52 52 53 53 if (options.image && await Deno.stat(options.image).catch(() => false)) { 54 54 const driveSize = await du(options.image); 55 - if (driveSize > 10) { 55 + if (driveSize > EMPTY_DISK_THRESHOLD_KB) { 56 56 console.log( 57 57 chalk.yellowBright( 58 58 `Drive image ${options.image} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`, ··· 160 160 161 161 const qemuArgs = [ 162 162 ..._.compact([options.bridge && "qemu-system-x86_64"]), 163 - "-enable-kvm", 163 + ..._.compact(Deno.build.os === "linux" && ["-enable-kvm"]), 164 164 "-cpu", 165 165 options.cpu, 166 166 "-m",