diff --git a/kbuildx/scripts/freebsd-deps.sh b/kbuildx/scripts/freebsd-deps.sh index d53c38a..6d48b72 100755 --- a/kbuildx/scripts/freebsd-deps.sh +++ b/kbuildx/scripts/freebsd-deps.sh @@ -1,5 +1,13 @@ #!/bin/sh set -eu +data_disk=/dev/vtbd1 +if ! mount | grep -q ' /root/kbuildx '; then + if ! fsck -n "$data_disk" >/dev/null 2>&1; then + newfs "$data_disk" + fi + mkdir -p /root/kbuildx + mount "$data_disk" /root/kbuildx +fi marker=/var/db/kbuildx-root-grown if [ ! -e "$marker" ]; then diff --git a/kbuildx/scripts/netbsd-deps.sh b/kbuildx/scripts/netbsd-deps.sh index 00a66aa..27ac98c 100755 --- a/kbuildx/scripts/netbsd-deps.sh +++ b/kbuildx/scripts/netbsd-deps.sh @@ -2,6 +2,14 @@ set -eu export PATH=/usr/pkg/bin:/usr/pkg/sbin:/sbin:/usr/sbin:/bin:/usr/bin +data_disk=/dev/ld1a +if ! mount | grep -q ' /root/kbuildx '; then + if ! fsck_ffs -n "$data_disk" >/dev/null 2>&1; then + newfs "$data_disk" + fi + mkdir -p /root/kbuildx + mount "$data_disk" /root/kbuildx +fi package_release=${1:-} diff --git a/kbuildx/src/commands/bsd.rs b/kbuildx/src/commands/bsd.rs index 681f96b..9f25f11 100644 --- a/kbuildx/src/commands/bsd.rs +++ b/kbuildx/src/commands/bsd.rs @@ -19,6 +19,7 @@ use crate::{ const FREEBSD_REPO: &str = "https://git.FreeBSD.org/src.git"; const NETBSD_REPO: &str = "https://github.com/NetBSD/src.git"; const BSD_DISK_SIZE: &str = "40G"; +const BSD_BUILD_DISK_SIZE: u64 = 16 * 1024 * 1024 * 1024; const BSD_AGENT_TIMEOUT: Duration = Duration::from_secs(180); fn step(label: &str) -> String { @@ -172,6 +173,16 @@ fn start_bsd_sandbox(os: BuildOs, version: &str, cpus: u32, memory: u32) -> Resu // repository used by the bsdkrun workflows. The requested version // still selects the source ref and artifact label below. let mut command = Command::new(bsdkrun_binary()); + let build_disk = std::env::current_dir()?.join(format!(".{}-build.img", name)); + if !build_disk.exists() { + std::fs::OpenOptions::new() + .create(true) + .write(true) + .open(&build_disk) + .with_context(|| format!("creating {}", build_disk.display()))? + .set_len(BSD_BUILD_DISK_SIZE) + .with_context(|| format!("sizing {}", build_disk.display()))?; + } command .arg(os_name) .arg("-d") @@ -185,6 +196,8 @@ fn start_bsd_sandbox(os: BuildOs, version: &str, cpus: u32, memory: u32) -> Resu .arg(BSD_DISK_SIZE) .arg("--volume") .arg(&name) + .arg("--attach-disk") + .arg(&build_disk) .stdout(Stdio::piped()) .stderr(Stdio::inherit()); if !(os == BuildOs::Netbsd && version == "current") {