Build a FreeBSD VM Image Release
release(7)
documents a set of shell scripts for creating FreeBSD release
files in same manner as the release engineering team. The script creates a new
chroot
environment, checks out a fresh tree, doing the release builds in a
clean environment.
That might be what you want.
I want to write some scripts that take in a specified network, some git commit
ids and generates a set of virtual machine images running in
bhyve
to
reproduce a test environment. Building in a clean environment isn't what
I need.
The Makefiles in
release
expect to be run from a tree that already has a
built kernel and world. They make building the VM images really easy, but apart
from comments in the files aren't documented.
I am going to use a directory for all of the stuff:
freebsd/
-> src # freebsd src tree
-> obj # object directory
-> destdir # freebsd destination direcory
$ cd freebsd
$ git clone https://github.com/freebsd/freebsd.git src
$ cd src
Build the kernel and world, setting the object directory to the one in our tree.
$ env MAKEOBJDIRPREFIX=/home/user/freebsd/obj time make -j4 -DKERNFAST buildkernel
$ env MAKEOBJDIRPREFIX=/home/user/freebsd/obj make -j4 buildworld -DWITH_META_MODE=yes -DWITH_CCACHE_BUILD -DNO_CLEAN
Move to the release directory to build our VM images:
$ cd release
# env MAKEOBJDIRPREFIX=/home/user/freebsd/obj make vm-release -j4 DESTDIR=/home/user/freebsd/destdir WITH_VMIMAGES=yes VMFORMATS=raw NOPKG=yes NOPORTS=yes NOSRC=yes
# env MAKEOBJDIRPREFIX=/home/user/freebsd/obj make vm-install -j4 DESTDIR=/home/user/freebsd/destdir WITH_VMIMAGES=yes VMFORMATS=raw NOPKG=yes NOPORTS=yes NOSRC=yes
I exclude, packages, ports and the
src
distribution in the images.
As a test launch a
bhyve
VM with our created disk image:
# sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 1024M -t tap0 -d ../../destdir/vmimages/FreeBSD-12.0-CURRENT-amd64.raw test
Reading: The Moon is a Harsh Mistress, The Difference Engine