Add some vagrantfiles for building on BSDs

This only builds, doesn't run tests. Use:

    ./build_fish_on_bsd.sh dragonflybsd_6_4 freebsd_14_0 netbsd_9_3 openbsd_7_4

To build on all of them.

Note they don't all build yet.
This commit is contained in:
Peter Ammon
2025-10-12 12:10:18 -07:00
parent 5f0d83d2f2
commit d72adc0124
7 changed files with 278 additions and 0 deletions

2
vagrants/bsds/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.vagrant/

18
vagrants/bsds/README.md Normal file
View File

@@ -0,0 +1,18 @@
# BSD Vagrant Test Environments
This directory contains Vagrant configurations for testing across multiple BSD operating systems.
Use the `build_fish_on_bsd.sh` script to automatically build fish-shell on multiple BSD VMs:
```bash
./build_fish_on_bsd.sh freebsd_14_0 openbsd_7_4 netbsd_9_3 dragonflybsd_6_4
```
The script will:
- Boot each VM
- Sync the latest files
- Run `cargo build` in `/sync/fish-shell`
- **Halt VMs that build successfully**
- **Leave VMs running if builds fail** (for debugging)
- Show a summary of successes and failures

View File

@@ -0,0 +1,100 @@
#!/bin/bash
# Build fish on BSD VMs
# Usage: ./build_fish.sh freebsd_14_0 openbsd_7_4 netbsd_9_3 dragonflybsd_6_4
set -e
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Default to "4.x.x" version if not set
FISH_BUILD_VERSION="${FISH_BUILD_VERSION:-4.x.x}"
if [ $# -eq 0 ]; then
echo "Usage: $0 <bsd_dir1> [bsd_dir2] ..."
echo "Example: $0 freebsd_14_0 openbsd_7_4"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FAILED_VMS=()
SUCCESS_VMS=()
for BSD_DIR in "$@"; do
if [ ! -d "$SCRIPT_DIR/$BSD_DIR" ]; then
echo -e "${RED}Error: Directory $BSD_DIR does not exist${NC}"
continue
fi
echo ""
echo "=========================================="
echo -e "${YELLOW}Processing: $BSD_DIR${NC}"
echo "=========================================="
cd "$SCRIPT_DIR/$BSD_DIR"
echo "Starting VM..."
vagrant up
echo "Syncing files..."
vagrant rsync
echo "Building fish..."
if vagrant ssh -c "cd /home/vagrant/fish-shell && FISH_BUILD_VERSION=$FISH_BUILD_VERSION cargo build" 2>&1; then
echo -e "${GREEN}✓ Build succeeded for $BSD_DIR${NC}"
SUCCESS_VMS+=("$BSD_DIR")
echo "Halting VM..."
vagrant halt
else
echo ""
echo -e "${RED}✗ Build FAILED for $BSD_DIR${NC}"
echo -e "${YELLOW}VM is still running. To investigate:${NC}"
echo -e " cd $SCRIPT_DIR/$BSD_DIR"
echo -e " vagrant ssh"
echo -e " cd /home/vagrant/fish-shell"
echo -e " cargo build"
echo ""
echo -e "${YELLOW}To halt the VM when done:${NC}"
echo -e " cd $SCRIPT_DIR/$BSD_DIR && vagrant halt"
echo ""
FAILED_VMS+=("$BSD_DIR")
fi
done
echo ""
echo "=========================================="
echo "Summary"
echo "=========================================="
if [ ${#SUCCESS_VMS[@]} -gt 0 ]; then
echo -e "${GREEN}Successful builds (${#SUCCESS_VMS[@]}):${NC}"
for vm in "${SUCCESS_VMS[@]}"; do
echo -e " ${GREEN}${NC} $vm"
done
fi
if [ ${#FAILED_VMS[@]} -gt 0 ]; then
echo ""
echo -e "${RED}Failed builds (${#FAILED_VMS[@]}):${NC}"
for vm in "${FAILED_VMS[@]}"; do
echo -e " ${RED}${NC} $vm (VM still running)"
done
echo ""
echo -e "${YELLOW}To halt all failed VMs:${NC}"
for vm in "${FAILED_VMS[@]}"; do
echo " cd $SCRIPT_DIR/$vm && vagrant halt"
done
fi
if [ ${#FAILED_VMS[@]} -eq 0 ]; then
echo -e "\n${GREEN}All builds completed successfully!${NC}"
exit 0
else
echo ""
exit 1
fi

View File

@@ -0,0 +1,39 @@
Vagrant.configure("2") do |config|
config.vm.box = "generic/dragonflybsd6"
config.vm.guest = :dragonflybsd
# Host-only network; not public
config.vm.network "private_network", ip: "192.168.121.13"
# Make /sync once as vagrant:vagrant so rsync doesn't need sudo
config.vm.provision "shell", inline: <<~'SH'
set -e
install -d -o vagrant -g vagrant /sync
# Packages (runs as root)
export PKG_PATH=http://avalon.dragonflybsd.org/dports/dragonfly:6.4:x86:64/LATEST/All/
pkg install -y git python3 rust
git --version
python3 --version
rustc --version
cargo --version
SH
# sync fish-shell to /vagrant/fish-shell
config.vm.synced_folder "../../..", "/home/vagrant/fish-shell",
type: "rsync",
rsync__rsync_path: "sudo rsync", # sudo in guest
rsync__exclude: [".git/", ".git", "fish-shell/target/", "fish-shell/build/"],
rsync__args: [
"--archive", "--delete",
"--no-owner", "--no-group",
"--omit-dir-times",
"--info=progress2", "--stats"
]
config.vm.provider :libvirt do |v|
v.cpus = 4
v.graphics_type = "none"
end
end

36
vagrants/bsds/freebsd_14_0/Vagrantfile vendored Normal file
View File

@@ -0,0 +1,36 @@
Vagrant.configure("2") do |config|
config.vm.box = "generic/freebsd14"
config.vm.guest = :freebsd
# Packages provision (runs once on first boot)
config.vm.provision "shell", inline: <<~'SH'
set -e
# Packages (runs as root)
pkg install -y git python3 rust
git --version
python3 --version
rustc --version
cargo --version
SH
# sync fish-shell to /vagrant/fish-shell
config.vm.synced_folder "../../..", "/home/vagrant/fish-shell",
type: "rsync",
rsync__rsync_path: "sudo rsync", # sudo in guest
rsync__exclude: [".git/", ".git", "fish-shell/target/", "fish-shell/build/"],
rsync__args: [
"--archive", "--delete",
"--no-owner", "--no-group",
"--omit-dir-times",
"--info=progress2", "--stats"
]
config.vm.provider :libvirt do |v|
v.cpus = 4
v.memory = 2048
# Max I/O for disposable builds. Remove if you need durability.
v.disk_driver :cache => 'unsafe'
v.graphics_type = "none"
end
end

40
vagrants/bsds/netbsd_9_3/Vagrantfile vendored Normal file
View File

@@ -0,0 +1,40 @@
Vagrant.configure("2") do |config|
config.vm.box = "generic/netbsd9"
config.vm.guest = :netbsd
# Make /sync once as vagrant:vagrant so rsync doesn't need sudo
config.vm.provision "shell", inline: <<~'SH'
set -e
install -d -o vagrant -g vagrant /sync
# Packages (runs as root)
pkgin -y install git python312 rust mozilla-rootcerts
# Update CA certificates
mozilla-rootcerts install
git --version
python3 --version
rustc --version
cargo --version
SH
# sync fish-shell to /vagrant/fish-shell
config.vm.synced_folder "../../..", "/home/vagrant/fish-shell",
type: "rsync",
rsync__rsync_path: "sudo rsync", # sudo in guest
rsync__exclude: [".git/", ".git", "fish-shell/target/", "fish-shell/build/"],
rsync__args: [
"--archive", "--delete",
"--no-owner", "--no-group",
"--omit-dir-times",
"--info=progress2", "--stats"
]
config.vm.provider :libvirt do |v|
v.cpus = 4
v.memory = 2048
# Max I/O for disposable builds. Remove if you need durability.
v.disk_driver :cache => 'unsafe'
# Note: NetBSD needs graphics on; leave default graphics enabled.
end
end

43
vagrants/bsds/openbsd_7_4/Vagrantfile vendored Normal file
View File

@@ -0,0 +1,43 @@
Vagrant.configure("2") do |config|
config.vm.box = "generic/openbsd7"
config.vm.guest = :openbsd
# Host-only network; not public
config.vm.network "private_network", ip: "192.168.121.11"
# Make /sync once as vagrant:vagrant so rsync doesn't need sudo
config.vm.provision "shell", inline: <<~'SH'
set -e
install -d -o vagrant -g vagrant /sync
# Packages (runs as root)
export PKG_PATH="https://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/packages/amd64/"
pkg_info -e git >/dev/null || pkg_add git
pkg_info -e python%3.11 >/dev/null || pkg_add python%3.11
pkg_info -e rust >/dev/null || pkg_add rust
git --version
python3.11 --version
rustc --version
SH
# sync fish-shell to /vagrant/fish-shell
config.vm.synced_folder "../../..", "/home/vagrant/fish-shell",
type: "rsync",
rsync__rsync_path: "sudo rsync", # sudo in guest
rsync__exclude: [".git/", ".git", "fish-shell/target/", "fish-shell/build/"],
rsync__args: [
"--archive", "--delete",
"--no-owner", "--no-group",
"--omit-dir-times",
"--info=progress2", "--stats"
]
config.vm.provider :libvirt do |v|
v.cpus = 4
v.memory = 2048
# Max I/O for disposable builds. Remove if you need durability.
v.disk_driver :cache => 'unsafe'
# Note: OpenBSD needs graphics on; leave default graphics enabled.
end
end