diff --git a/release/Makefile.vm b/release/Makefile.vm index cb44a34c4545..2ab5b4e373e3 100644 --- a/release/Makefile.vm +++ b/release/Makefile.vm @@ -1,181 +1,182 @@ # # $FreeBSD$ # # # Makefile for building virtual machine and cloud provider disk images. # VMTARGETS= vm-image VMFORMATS?= vhd vmdk qcow2 raw VMSIZE?= 5120m +VMFS?= ufs SWAPSIZE?= 1g VMBASE?= vm VHD_DESC= Azure, VirtualPC, Hyper-V, Xen disk image VMDK_DESC= VMWare, VirtualBox disk image QCOW2_DESC= Qemu, KVM disk image RAW_DESC= Unformatted raw disk image CLOUDWARE?= BASIC-CI \ EC2 \ GCE \ VAGRANT-VIRTUALBOX \ VAGRANT-VMWARE AZURE_FORMAT= vhdf AZURE_DESC= Microsoft Azure platform image AZURE_DISK= ${OSRELEASE}.${AZURE_FORMAT} BASIC-CI_FORMAT= raw BASIC-CI_DESC= Image for CI BASIC-CI_DISK= ${OSRELEASE}.${BASIC-CI_FORMAT} EC2_FORMAT= raw EC2_DESC= Amazon EC2 image EC2_DISK= ${OSRELEASE}.${EC2_FORMAT} GCE_FORMAT= raw GCE_DESC= Google Compute Engine image GCE_DISK= disk.${GCE_FORMAT} OPENSTACK_FORMAT=qcow2 OPENSTACK_DESC= OpenStack platform image OPENSTACK_DISK= ${OSRELEASE}.${OPENSTACK_FORMAT} VAGRANT-VIRTUALBOX_FORMAT= vmdk VAGRANT-VIRTUALBOX_DESC= Vagrant Image for VirtualBox VAGRANT-VIRTUALBOX_DISK= ${OSRELEASE}.vbox.${VAGRANT_FORMAT} VAGRANT-VMWARE_FORMAT= vmdk VAGRANT-VMWARE_DESC= Vagrant Image for VMWare VAGRANT-VMWARE_DISK= ${OSRELEASE}.vmware.${VAGRANT_FORMAT} .for _V in TYPE BRANCH REVISION . if !defined(${_V}) || empty(${_V}) ${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V} . endif .endfor emulator-portinstall: .if ${TARGET_ARCH} != ${MACHINE_ARCH} .if ( ${TARGET_ARCH} != "i386" ) || ( ${MACHINE_ARCH} != "amd64" ) .if !exists(/usr/local/bin/qemu-${TARGET_ARCH}-static) .if exists(${PORTSDIR}/emulators/qemu-user-static/Makefile) env - UNAME_r=${UNAME_r} PATH=$$PATH make -C ${PORTSDIR}/emulators/qemu-user-static BATCH=1 all install clean .else .if !exists(/usr/local/sbin/pkg-static) env ASSUME_ALWAYS_YES=yes pkg bootstrap -y .endif env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-user-static .endif .endif QEMUSTATIC=/usr/local/bin/qemu-${TARGET_ARCH}-static .endif .endif .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE) . for _CW in ${CLOUDWARE} CLOUDTARGETS+= cw-${_CW:tl} CLEANDIRS+= cw-${_CW:tl} CLEANFILES+= ${_CW:tl}.img \ ${_CW:tl}.${${_CW:tu}_FORMAT} \ ${_CW:tl}.${${_CW:tu}_FORMAT}.raw \ cw${_CW:tl}-package CLOUDPACKAGE+= cw${_CW:tl}-package ${_CW:tu}IMAGE= ${_CW:tl}.${${_CW:tu}_FORMAT} . if exists(${.CURDIR}/tools/${_CW:tl}.conf) && !defined(${_CW:tu}CONF) ${_CW:tu}CONF?= ${.CURDIR}/tools/${_CW:tl}.conf . endif cw-${_CW:tl}: emulator-portinstall mkdir -p ${.OBJDIR}/${.TARGET} env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \ QEMUSTATIC=${QEMUSTATIC} \ ${.CURDIR}/scripts/mk-vmimage.sh \ - -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \ + -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} -F ${VMFS} \ -i ${.OBJDIR}/${_CW:tl}.img -s ${VMSIZE} -f ${${_CW:tu}_FORMAT} \ -S ${WORLDDIR} -o ${.OBJDIR}/${${_CW:tu}IMAGE} -c ${${_CW:tu}CONF} touch ${.TARGET} cw${_CW:tl}-package: @# Special target to handle packaging cloud images in the formats @# specific to each hosting provider. .if exists(${.CURDIR}/tools/${_CW:tl}-package.sh) env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ ${.CURDIR}/tools/${_CW:tl}-package.sh \ -D ${DESTDIR} -I ${${_CW}_DISK} -S ${WORLDDIR} .endif touch ${.TARGET} . endfor .endif .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) CLEANDIRS+= ${VMTARGETS} . for FORMAT in ${VMFORMATS} CLEANFILES+= ${FORMAT}.img CLEANFILES+= ${VMBASE}.${FORMAT} . endfor .endif vm-base: vm-image vm-image: .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) . for FORMAT in ${VMFORMATS} mkdir -p ${.OBJDIR}/${.TARGET} env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \ ${.CURDIR}/scripts/mk-vmimage.sh \ - -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \ + -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} -F ${VMFS} \ -i ${.OBJDIR}/${FORMAT}.img -s ${VMSIZE} -f ${FORMAT} \ -S ${WORLDDIR} -o ${.OBJDIR}/${VMBASE}.${FORMAT} . endfor .endif touch ${.TARGET} vm-cloudware: ${CLOUDTARGETS} list-vmtargets: list-cloudware @${ECHO} @${ECHO} "Supported virtual machine disk image formats:" .for FORMAT in ${VMFORMATS:tu} @${ECHO} " ${FORMAT:tl}: ${${FORMAT}_DESC}" .endfor list-cloudware: .if !empty(CLOUDWARE) @${ECHO} @${ECHO} "Supported cloud hosting provider images:" . for _CW in ${CLOUDWARE} @${ECHO} " ${_CW:tu}: ${${_CW:tu}_DESC}" . endfor .endif vm-install: .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) mkdir -p ${DESTDIR}/vmimages . for FORMAT in ${VMFORMATS} cp -p ${VMBASE}.${FORMAT} \ ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} . endfor . if defined(WITH_COMPRESSED_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES) . for FORMAT in ${VMFORMATS} # Don't keep the originals. There is a copy in ${.OBJDIR} if needed. ${XZ_CMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} . endfor . endif cd ${DESTDIR}/vmimages && sha512 ${OSRELEASE}* > \ ${DESTDIR}/vmimages/CHECKSUM.SHA512 cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \ ${DESTDIR}/vmimages/CHECKSUM.SHA256 .endif vm-release: .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS} .endif cloudware-release: .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE) ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${CLOUDTARGETS} .endif .include "${.CURDIR}/Makefile.azure" .include "${.CURDIR}/Makefile.ec2" .include "${.CURDIR}/Makefile.gce" .include "${.CURDIR}/Makefile.vagrant" .include "${.CURDIR}/Makefile.inc1" diff --git a/release/scripts/mk-vmimage.sh b/release/scripts/mk-vmimage.sh index d5985ceb0d25..bcf77ffd8f0f 100755 --- a/release/scripts/mk-vmimage.sh +++ b/release/scripts/mk-vmimage.sh @@ -1,112 +1,116 @@ #!/bin/sh #- # Copyright (c) 2014, 2015 The FreeBSD Foundation # All rights reserved. # # This software was developed by Glen Barber under sponsorship # from the FreeBSD Foundation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # mk-vmimage.sh: Create virtual machine disk images in various formats. # # $FreeBSD$ # usage() { echo "${0} usage:" echo "${@}" return 1 } main() { local arg VMCONFIG="/dev/null" - while getopts "C:c:d:f:i:o:s:S:" arg; do + while getopts "C:c:d:F:f:i:o:s:S:" arg; do case "${arg}" in C) VMBUILDCONF="${OPTARG}" ;; c) VMCONFIG="${OPTARG}" ;; d) DESTDIR="${OPTARG}" ;; + F) + VMFS="${OPTARG}" + ;; f) VMFORMAT="${OPTARG}" ;; i) VMBASE="${OPTARG}" ;; o) VMIMAGE="${OPTARG}" ;; s) VMSIZE="${OPTARG}" ;; S) WORLDDIR="${OPTARG}" ;; *) ;; esac done shift $(( ${OPTIND} - 1)) if [ -z "${VMBASE}" -o \ -z "${WORLDDIR}" -o \ -z "${DESTDIR}" -o \ -z "${VMSIZE}" -o \ - -z "${VMIMAGE}" ]; + -z "${VMIMAGE}" -o \ + -z "${VMFS}" ]; then usage || exit 0 fi if [ -z "${VMBUILDCONF}" ] || [ ! -e "${VMBUILDCONF}" ]; then echo "Must provide the path to vmimage.subr." return 1 fi . "${VMBUILDCONF}" if [ ! -z "${VMCONFIG}" ] && [ ! -c "${VMCONFIG}" ]; then . "${VMCONFIG}" fi vm_create_base vm_install_base vm_extra_install_base vm_extra_install_packages vm_extra_install_ports vm_extra_enable_services vm_extra_pre_umount vm_extra_pkg_rmcache cleanup vm_copy_base vm_create_disk || return 0 vm_extra_create_disk return 0 } main "$@" diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf index a61b711c24ce..34b83fa627b6 100644 --- a/release/tools/ec2.conf +++ b/release/tools/ec2.conf @@ -1,178 +1,178 @@ #!/bin/sh # # $FreeBSD$ # # Packages to install into the image we're creating. This is a deliberately # minimalist set, providing only the packages necessary to bootstrap further # package installation as specified via EC2 user-data. export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \ firstboot-freebsd-update firstboot-pkgs isc-dhcp44-client \ ebsnvme-id" # Include the amazon-ssm-agent package in amd64 images, since some users want # to be able to use it on systems which are not connected to the Internet. # (It is not enabled by default, however.) This package does not exist for # aarch64, so we have to be selective about when we install it. if [ "${TARGET_ARCH}" = "amd64" ]; then export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} amazon-ssm-agent" fi # Set to a list of third-party software to enable in rc.conf(5). export VM_RC_LIST="ec2_configinit ec2_fetchkey ec2_loghostkey firstboot_freebsd_update firstboot_pkgs ntpd dev_aws_disk ec2_ephemeral_swap" -# Build with a 4.9 GB UFS partition; the growfs rc.d script will expand +# Build with a 4.9 GB partition; the growfs rc.d script will expand # the partition to fill the root disk after the EC2 instance is launched. # Note that if this is set to G, we will end up with an GB disk -# image since VMSIZE is the size of the UFS partition, not the disk which -# it resides within. +# image since VMSIZE is the size of the filesystem partition, not the disk +# which it resides within. export VMSIZE=5000m # No swap space; the ec2_ephemeralswap rc.d script will allocate swap # space on EC2 ephemeral disks. (If they exist -- the T2 low-cost instances # and the C4 compute-optimized instances don't have ephemeral disks. But # it would be silly to bloat the image and increase costs for every instance # just for those two families, especially since instances ranging in size # from 1 GB of RAM to 60 GB of RAM would need different sizes of swap space # anyway.) export NOSWAP=YES vm_extra_pre_umount() { # The firstboot_pkgs rc.d script will download the repository # catalogue and install or update pkg when the instance first # launches, so these files would just be replaced anyway; removing # them from the image allows it to boot faster. mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg delete -f -y pkg umount ${DESTDIR}/dev rm ${DESTDIR}/var/db/pkg/repo-*.sqlite # The size of the EC2 root disk can be configured at instance launch # time; expand our filesystem to fill the disk. echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf # EC2 instances use DHCP to get their network configuration. IPv6 # requires accept_rtadv. echo 'ifconfig_DEFAULT="SYNCDHCP accept_rtadv"' >> ${DESTDIR}/etc/rc.conf # Unless the system has been configured via EC2 user-data, the user # will need to SSH in to do anything. echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf # The AWS CLI tools are generally useful, and small enough that they # will download quickly; but users will often override this setting # via EC2 user-data. echo 'firstboot_pkgs_list="awscli"' >> ${DESTDIR}/etc/rc.conf # Enable IPv6 on all interfaces, and spawn DHCPv6 via rtsold echo 'ipv6_activate_all_interfaces="YES"' >> ${DESTDIR}/etc/rc.conf echo 'rtsold_enable="YES"' >> ${DESTDIR}/etc/rc.conf echo 'rtsold_flags="-M /usr/local/libexec/rtsold-M -a"' >> ${DESTDIR}/etc/rc.conf # Turn off IPv6 Duplicate Address Detection; the EC2 networking # configuration makes it unnecessary. echo 'net.inet6.ip6.dad_count=0' >> ${DESTDIR}/etc/sysctl.conf # Provide a script which rtsold can use to launch DHCPv6 mkdir -p ${DESTDIR}/usr/local/libexec cat > ${DESTDIR}/usr/local/libexec/rtsold-M <<'EOF' #!/bin/sh /usr/local/sbin/dhclient -6 -nw -N -cf /dev/null $1 EOF chmod 755 ${DESTDIR}/usr/local/libexec/rtsold-M # The EC2 console is output-only, so while printing a backtrace can # be useful, there's no point dropping into a debugger or waiting # for a keypress. echo 'debug.trace_on_panic=1' >> ${DESTDIR}/boot/loader.conf echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/boot/loader.conf echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/boot/loader.conf # The console is not interactive, so we might as well boot quickly. echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf # Tell gptboot not to wait 3 seconds for a keypress which won't # arrive either. printf -- "-n\n" > ${DESTDIR}/boot.config # The emulated keyboard attached to EC2 instances is inaccessible to # users, and there is no mouse attached at all; disable to keyboard # and the keyboard controller (to which the mouse would attach, if # one existed) in order to save time in device probing. echo 'hint.atkbd.0.disabled=1' >> ${DESTDIR}/boot/loader.conf echo 'hint.atkbdc.0.disabled=1' >> ${DESTDIR}/boot/loader.conf # EC2 has two consoles: An emulated serial port ("system log"), # which has been present since 2006; and a VGA console ("instance # screenshot") which was introduced in 2016. echo 'boot_multicons="YES"' >> ${DESTDIR}/boot/loader.conf # Some older EC2 hardware used a version of Xen with a bug in its # emulated serial port. It is not clear if EC2 still has any such # nodes, but apply the workaround just in case. echo 'hw.broken_txfifo="1"' >> ${DESTDIR}/boot/loader.conf # Load the kernel module for the Amazon "Elastic Network Adapter" echo 'if_ena_load="YES"' >> ${DESTDIR}/boot/loader.conf # Use the "nda" driver for accessing NVMe disks rather than the # historical "nvd" driver. echo 'hw.nvme.use_nvd="0"' >> ${DESTDIR}/boot/loader.conf # Disable KbdInteractiveAuthentication according to EC2 requirements. sed -i '' -e \ 's/^#KbdInteractiveAuthentication yes/KbdInteractiveAuthentication no/' \ ${DESTDIR}/etc/ssh/sshd_config # Use FreeBSD Update and Portsnap mirrors hosted in AWS sed -i '' -e 's/update.FreeBSD.org/aws.update.FreeBSD.org/' \ ${DESTDIR}/etc/freebsd-update.conf sed -i '' -e 's/portsnap.FreeBSD.org/aws.portsnap.FreeBSD.org/' \ ${DESTDIR}/etc/portsnap.conf # Use the NTP service provided by Amazon sed -i '' -e 's/^pool/#pool/' \ -e '1,/^#server/s/^#server.*/server 169.254.169.123 iburst/' \ ${DESTDIR}/etc/ntp.conf # Provide a map for accessing Elastic File System mounts cat > ${DESTDIR}/etc/autofs/special_efs <<'EOF' #!/bin/sh if [ $# -eq 0 ]; then # No way to know which EFS filesystems exist and are # accessible to this EC2 instance. exit 0 fi # Provide instructions on how to mount the requested filesystem. FS=$1 REGION=`fetch -qo- http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/[a-z]$//'` echo "-nfsv4,minorversion=1,oneopenown ${FS}.efs.${REGION}.amazonaws.com:/" EOF chmod 755 ${DESTDIR}/etc/autofs/special_efs # The first time the AMI boots, the installed "first boot" scripts # should be allowed to run: # * ec2_configinit (download and process EC2 user-data) # * ec2_fetchkey (arrange for SSH using the EC2-provided public key) # * growfs (expand the filesystem to fill the provided disk) # * firstboot_freebsd_update (install critical updates) # * firstboot_pkgs (install packages) touch ${DESTDIR}/firstboot # Any EC2 ephemeral disks seen when the system first boots will # be "new" disks; there is no "previous boot" when they might have # been seen and used already. touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen if ! [ -z "${QEMUSTATIC}" ]; then rm -f ${DESTDIR}/${EMULATOR} fi rm -f ${DESTDIR}/etc/resolv.conf return 0 } diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 0d9202431822..8982e768527a 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -1,272 +1,331 @@ #!/bin/sh # # $FreeBSD$ # # # Common functions for virtual machine image build scripts. # scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" trap "cleanup" INT QUIT TRAP ABRT TERM # Platform-specific large-scale setup # Most platforms use GPT, so put that as default, then special cases PARTSCHEME=gpt ROOTLABEL="gpt" case "${TARGET}:${TARGET_ARCH}" in powerpc:powerpc*) PARTSCHEME=mbr ROOTLABEL="ufs" NOSWAP=yes # Can't label swap partition with MBR, so no swap ;; esac err() { printf "${@}\n" cleanup return 1 } cleanup() { if [ -c "${DESTDIR}/dev/null" ]; then umount_loop ${DESTDIR}/dev 2>/dev/null fi return 0 } vm_create_base() { - # Creates the UFS root filesystem for the virtual machine disk, - # written to the formatted disk image with mkimg(1). mkdir -p ${DESTDIR} return 0 } vm_copy_base() { # Defunct } vm_install_base() { # Installs the FreeBSD userland/kernel to the virtual machine disk. cd ${WORLDDIR} && \ make DESTDIR=${DESTDIR} \ installworld installkernel distribution || \ err "\n\nCannot install the base system to ${DESTDIR}." # Bootstrap etcupdate(8) and mergemaster(8) databases. mkdir -p ${DESTDIR}/var/db/etcupdate etcupdate extract -B \ -M "TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" \ -s ${WORLDDIR} -d ${DESTDIR}/var/db/etcupdate sh ${WORLDDIR}/release/scripts/mm-mtree.sh -m ${WORLDDIR} \ -F "TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" \ -D ${DESTDIR} echo '# Custom /etc/fstab for FreeBSD VM images' \ > ${DESTDIR}/etc/fstab - echo "/dev/${ROOTLABEL}/rootfs / ufs rw 1 1" \ - >> ${DESTDIR}/etc/fstab + if [ "${VMFS}" != zfs ]; then + echo "/dev/${ROOTLABEL}/rootfs / ${VMFS} rw 1 1" \ + >> ${DESTDIR}/etc/fstab + fi if [ -z "${NOSWAP}" ]; then echo '/dev/gpt/swapfs none swap sw 0 0' \ >> ${DESTDIR}/etc/fstab fi local hostname hostname="$(echo $(uname -o) | tr '[:upper:]' '[:lower:]')" echo "hostname=\"${hostname}\"" >> ${DESTDIR}/etc/rc.conf + if [ "${VMFS}" = zfs ]; then + echo "zfs_enable=\"YES\"" >> ${DESTDIR}/etc/rc.conf + echo "zpool_reguid=\"zroot\"" >> ${DESTDIR}/etc/rc.conf + fi if ! [ -z "${QEMUSTATIC}" ]; then export EMULATOR=/qemu cp ${QEMUSTATIC} ${DESTDIR}/${EMULATOR} fi mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} ${EMULATOR} /usr/bin/newaliases chroot ${DESTDIR} ${EMULATOR} /bin/sh /etc/rc.d/ldconfig forcestart umount_loop ${DESTDIR}/dev cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf + if [ "${VMFS}" = zfs ]; then + echo "kern.geom.label.disk_ident.enable=0" >> ${DESTDIR}/boot/loader.conf + echo "zfs_load=YES" >> ${DESTDIR}/boot/loader.conf + fi + return 0 } vm_extra_install_base() { # Prototype. When overridden, runs extra post-installworld commands # as needed, based on the target virtual machine image or cloud # provider image target. return 0 } vm_extra_enable_services() { if [ ! -z "${VM_RC_LIST}" ]; then for _rcvar in ${VM_RC_LIST}; do echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf done fi if [ -z "${VMCONFIG}" -o -c "${VMCONFIG}" ]; then echo 'ifconfig_DEFAULT="DHCP inet6 accept_rtadv"' >> \ ${DESTDIR}/etc/rc.conf # Expand the filesystem to fill the disk. echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf touch ${DESTDIR}/firstboot fi return 0 } vm_extra_install_packages() { if [ -z "${VM_EXTRA_PACKAGES}" ]; then return 0 fi mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg bootstrap -y for p in ${VM_EXTRA_PACKAGES}; do chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg install -y ${p} done umount_loop ${DESTDIR}/dev return 0 } vm_extra_install_ports() { # Prototype. When overridden, installs additional ports within the # virtual machine environment. return 0 } vm_extra_pre_umount() { # Prototype. When overridden, performs additional tasks within the # virtual machine environment prior to unmounting the filesystem. # Note: When overriding this function, removing resolv.conf in the # disk image must be included. if ! [ -z "${QEMUSTATIC}" ]; then rm -f ${DESTDIR}/${EMULATOR} fi rm -f ${DESTDIR}/etc/resolv.conf return 0 } vm_extra_pkg_rmcache() { if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/local/sbin/pkg clean -y -a fi return 0 } +buildfs() { + local md tmppool + + case "${VMFS}" in + ufs) + makefs ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \ + ${VMBASE} ${DESTDIR} + ;; + zfs) + makefs -t zfs ${MAKEFSARGS} \ + -o poolname=zroot -o bootfs=zroot/ROOT/default -o rootpath=/ \ + -o fs=zroot\;mountpoint=none \ + -o fs=zroot/ROOT\;mountpoint=none \ + -o fs=zroot/ROOT/default\;mountpoint=/ \ + -o fs=zroot/tmp\;mountpoint=/tmp\;exec=on\;setuid=off \ + -o fs=zroot/usr\;mountpoint=/usr\;canmount=off \ + -o fs=zroot/usr/home \ + -o fs=zroot/usr/ports\;setuid=off \ + -o fs=zroot/usr/src \ + -o fs=zroot/usr/obj \ + -o fs=zroot/var\;mountpoint=/var\;canmount=off \ + -o fs=zroot/var/audit\;setuid=off\;exec=off \ + -o fs=zroot/var/log\;setuid=off\;exec=off \ + -o fs=zroot/var/mail\;atime=on \ + -o fs=zroot/var/tmp\;setuid=off \ + ${VMBASE} ${DESTDIR} + ;; + *) + echo "Unexpected VMFS value '${VMFS}'" + exit 1 + ;; + esac +} + umount_loop() { DIR=$1 i=0 sync while ! umount ${DIR}; do i=$(( $i + 1 )) if [ $i -ge 10 ]; then # This should never happen. But, it has happened. echo "Cannot umount(8) ${DIR}" echo "Something has gone horribly wrong." return 1 fi sleep 1 done return 0 } vm_create_disk() { - echo "Creating image... Please wait." - echo + local BOOTFILES BOOTPARTSOFFSET FSPARTTYPE X86GPTBOOTFILE if [ -z "${NOSWAP}" ]; then SWAPOPT="-p freebsd-swap/swapfs::${SWAPSIZE}" fi if [ -n "${VM_BOOTPARTSOFFSET}" ]; then BOOTPARTSOFFSET=":${VM_BOOTPARTSOFFSET}" fi + case "${VMFS}" in + ufs) + FSPARTTYPE=freebsd-ufs + X86GPTBOOTFILE=i386/gptboot/gptboot + ;; + zfs) + FSPARTTYPE=freebsd-zfs + X86GPTBOOTFILE=i386/gptzfsboot/gptzfsboot + ;; + *) + echo "Unexpected VMFS value '${VMFS}'" + return 1 + ;; + esac + + echo "Creating image... Please wait." + echo BOOTFILES="$(env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ WITH_UNIFIED_OBJDIR=yes \ make -C ${WORLDDIR}/stand -V .OBJDIR)" BOOTFILES="$(realpath ${BOOTFILES})" + MAKEFSARGS="-s ${VMSIZE}" case "${TARGET}:${TARGET_ARCH}" in amd64:amd64 | i386:i386) ESP=yes BOOTPARTS="-b ${BOOTFILES}/i386/pmbr/pmbr \ - -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot${BOOTPARTSOFFSET}" - ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}" - MAKEFSARGS="-B little" + -p freebsd-boot/bootfs:=${BOOTFILES}/${X86GPTBOOTFILE}${BOOTPARTSOFFSET}" + ROOTFSPART="-p ${FSPARTTYPE}/rootfs:=${VMBASE}" + MAKEFSARGS="$MAKEFSARGS -B little" ;; arm64:aarch64 | riscv:riscv64*) ESP=yes BOOTPARTS= - ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}" - MAKEFSARGS="-B little" + ROOTFSPART="-p ${FSPARTTYPE}/rootfs:=${VMBASE}" + MAKEFSARGS="$MAKEFSARGS -B little" ;; powerpc:powerpc*) ESP=no BOOTPARTS="-p prepboot:=${BOOTFILES}/powerpc/boot1.chrp/boot1.elf -a 1" ROOTFSPART="-p freebsd:=${VMBASE}" if [ ${TARGET_ARCH} = powerpc64le ]; then - MAKEFSARGS="-B little" + MAKEFSARGS="$MAKEFSARGS -B little" else - MAKEFSARGS="-B big" + MAKEFSARGS="$MAKEFSARGS -B big" fi ;; *) echo "vmimage.subr: unsupported target '${TARGET}:${TARGET_ARCH}'" >&2 exit 1 ;; esac if [ ${ESP} = "yes" ]; then # Create an ESP espfilename=$(mktemp /tmp/efiboot.XXXXXX) make_esp_file ${espfilename} ${fat32min} ${BOOTFILES}/efi/loader_lua/loader_lua.efi BOOTPARTS="${BOOTPARTS} -p efi/efiesp:=${espfilename}" # Add this to fstab mkdir -p ${DESTDIR}/boot/efi echo "/dev/${ROOTLABEL}/efiesp /boot/efi msdosfs rw 2 2" \ >> ${DESTDIR}/etc/fstab fi echo "Building filesystem... Please wait." - makefs ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \ - -s ${VMSIZE} ${VMBASE} ${DESTDIR} + buildfs echo "Building final disk image... Please wait." mkimg -s ${PARTSCHEME} -f ${VMFORMAT} \ ${BOOTPARTS} \ ${SWAPOPT} \ ${ROOTFSPART} \ -o ${VMIMAGE} if [ ${ESP} = "yes" ]; then rm ${espfilename} fi return 0 } vm_extra_create_disk() { return 0 } diff --git a/share/man/man7/release.7 b/share/man/man7/release.7 index be475979dd0f..855cf91697a1 100644 --- a/share/man/man7/release.7 +++ b/share/man/man7/release.7 @@ -1,761 +1,769 @@ .\" Copyright (c) 2002 Murray Stokely .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd July 21, 2022 +.Dd October 28, 2022 .Dt RELEASE 7 .Os .Sh NAME .Nm release .Nd "release building infrastructure" .Sh DESCRIPTION .Fx provides a complete build environment suitable for users to make full releases of the .Fx operating system. All of the tools necessary to build a release are available from the .Fx source code repository in .Pa src/release . A complete release can be built with only a single command, including the creation of ISO images suitable for burning to CD-ROM, memory stick images, and a network install directory. This command is aptly named .Dq Li "make release" . .Pp For some users, it may be desirable to provide an absolutely clean build environment, with no local modifications to the source tree or to .Xr make.conf 5 , and with clean checkouts of specific versions of the doc, src, and ports trees. For this purpose, a script .Pq Pa src/release/release.sh is provided to automate these checkouts and then execute .Dq Li "make release" in a clean .Xr chroot 8 . .Pp Before attempting to build a release, the user is expected to be familiar with the contents of .Xr build 7 , and should have experience upgrading systems from source. .Pp The release build process requires that .Pa /usr/obj be populated with the output of .Dq Li "make buildworld" and .Dq Li "make buildkernel" . This is necessary to provide the object files for the release or, when using .Pa release.sh , so that the object files for a complete system can be installed into a clean .Xr chroot 8 environment. .Pp If the target release build is for a different architecture or machine type, the .Va TARGET and .Va TARGET_ARCH variables must be used. See the supported .Fa release.conf variables for more information. .Pp The release procedure on some architectures may also require that the .Xr md 4 (memory disk) device driver be present in the kernel .Pq either by being compiled in or available as a module . .Pp This document does not cover source code management, quality assurance, or other aspects of the release engineering process. .Sh CLEAN RELEASE GENERATION Official releases of .Fx are produced in a clean environment to ensure consistency between the versions of the src, ports, and doc trees and to avoid contamination from the host system .Po such as local patches, changes to .Xr make.conf 5 , etc. .Pc . This is accomplished using the wrapper script .Pa src/release/release.sh . .Pp .Ic release.sh .Op Fl c Ar release.conf .Pp .Ic release.sh checks out the .Li src/ , .Li ports/ , and .Li doc/ trees to .Va CHROOTDIR , then calls .Dq Li "make buildworld" and .Dq Li "make installworld" to generate a .Xr chroot 8 environment. Next, .Dq Li "make release" is run within the .Xr chroot 8 environment and places the result in .Pa $CHROOTDIR/R . .Pp The optional .Fa release.conf configuration file supports the following variables: .Bl -tag -width Ev .It Va CHROOTDIR The directory within which the release will be built. .It Va CHROOT_MAKEENV Additional .Xr make 1 arguments to pass through, which directly affect the tuning of the build chroot. .It Va NOGIT Do not explicitly require the .Xr git 1 port to be installed. .It Va GITROOT The .Xr git 1 host used to check out the various trees. Defaults to .Pa https://git.FreeeBSD.org . .It Va SRCBRANCH The .Li src/ branch to use. Defaults to .Fl b Va main . .It Va PORTBRANCH The .Li ports/ branch to use. Defaults to .Va head/@rHEAD . .It Va TARGET The target machine type for cross-building a release. .It Va TARGET_ARCH The target machine architecture for cross-building a release. .Pp For the supported list of .Va TARGET and .Va TARGET_ARCH combinations, consult the output of .Dq make targets as documented in .Xr build 7 . .It Va KERNEL The target kernel configuration to use. Defaults to .Va GENERIC . Multiple .Va KERNEL entries may be specified. .It Va MAKE_CONF The .Xr make.conf 5 to use for the release build. Defaults to .Fa /dev/null to prevent polluting the release with local system changes. .It Va SRC_CONF The .Xr src.conf 5 to use for the release build. Defaults to .Fa /dev/null to prevent polluting the release with local system changes. .It Va MAKE_FLAGS Additional flags to pass to .Xr make 1 . .It Va WORLD_FLAGS Additional flags to pass to .Xr make 1 during the .Dq buildworld phase. Defaults to setting the number of .Xr make 1 jobs .Pq Ar -j to the number of CPUs available on a SMP-capable system. .It Va KERNEL_FLAGS Additional flags to pass to .Xr make 1 during the .Dq buildkernel phase. Defaults to setting the number of .Xr make 1 jobs .Pq Ar -j to half the number of CPUs available on a SMP-capable system. .It Va NOPORTS Set to a non-empty value to skip the .Li ports/ tree checkout. When set, .Va NOPORTS will prevent the .Fa ports.txz distribution package from being created. .It Va WITH_DVD Set to a non-empty value to include the .Cm dvdrom target. .It Va WITH_COMPRESSED_IMAGES Set to a non-empty value to compress the release images with .Xr xz 1 . The original .Pq uncompressed images are not removed. .It Va XZ_THREADS Pq Vt int Set to the number of threads .Xr xz 1 should use when compressing images. By default, .Va XZ_THREADS is set to .Va 0 , which uses all available cores on the system. .It Va VCSCMD The command run to obtain the source trees. Defaults to .Qq Cm git clone Fl q . .It Va CHROOTBUILD_SKIP If defined, the .Li buildworld , .Li installworld , and .Li distribution stages of the .Xr chroot 8 build environment setup are skipped. This is intended solely for cases where the .Xr chroot 8 userland are provided by alternate means. .It Va SRC_UPDATE_SKIP Set to a non-empty value to prevent checkout or update of .Fa /usr/src within the .Xr chroot 8 . This is intended for use only when .Fa /usr/src is expected to exist by alternative means. .It Va PORTS_UPDATE_SKIP Set to a non-empty value to prevent checkout or update of .Fa /usr/ports within the .Xr chroot 8 . This is intended for use only when .Fa /usr/ports is expected to exist by alternative means. .El .Sh EMBEDDED BUILDS The following .Fa release.conf variables are relevant only to release builds for embedded systems: .Bl -tag -width Ev .It Va EMBEDDEDBUILD Set to a non-null value to enable functionality for embedded device release builds. .Pp When set, .Va WITH_DVD is unset. Additionally, .Va EMBEDDED_TARGET and .Va EMBEDDED_TARGET_ARCH must also be defined. When the build environment is created, .Fa release.sh runs a separate build script located in an architecture-specific directory in .Pa src/release/${EMBEDDED_TARGET}/ . .It Va EMBEDDEDPORTS Set to the list of any ports that are required for the target device in the format of .Fa category/port . .It Va EMBEDDED_TARGET When set, its value is passed to .Xr make 1 to set the .Va TARGET .Pq value of Cm uname Fl m to cross build the target userland. .It Va EMBEDDED_TARGET_ARCH When set, its value is passed to .Xr make 1 to set the .Va TARGET_ARCH .Pq value of Cm uname Fl p to cross build the target userland. .El .Sh VIRTUAL MACHINE DISK IMAGES The following .Fa release.conf variables are relevant only to virtual machine disk image builds: .Bl -tag -width Ev .It Va WITH_VMIMAGES Set to a non-null value to build virtual machine disk images as part of the release build. .Va WITH_VMIMAGES may also be specified as an environment variable passed to .Xr make 1 . .It Va WITH_COMPRESSED_VMIMAGES Set to a non-null value to compress the virtual machine disk images with .Xr xz 1 as part of the .Cm install .Xr make 1 target. Note that compressing virtual machine disk images may take a very long time on some systems. .It Va VMBASE Set to change the name of the resulting virtual machine disk image file. The default value is .Va vm . .It Va VMSIZE Set to change the size of the virtual machine disk capacity. The default value is .Va 20g . See .Xr makefs 8 for valid values. .Pp Virtual machine disk images are, by default, created as sparse images. When .Va WITH_COMPRESSED_VMIMAGES is used, the resulting files compressed with .Xr xz 1 compress to roughly the same size, regardless of the specified disk image size. +.It Va VMFS +Set to specify the file system type to use. +Valid values are +.Va ufs +and +.Va zfs . +The default value is +.Va ufs . .It Va VMFORMATS Set to the target virtual disk image format(s) to create. By default, the .Va vhdf , Va vmdk , Va qcow2 , and .Va raw formats are created. See .Xr mkimg 1 for valid format values. .El .Pp For a list of supported .Va VMFORMATS values .Pq including cloud hosting provider formats along with a brief description, run: .Bd -literal -offset indent cd /usr/src make -C release list-vmtargets .Ed .Sh CLOUD HOSTING MACHINE IMAGES The .Fx release build tools support building virtual machine images for various cloud hosting providers, each with their own specific configuration to include support for each hosting provider by default. .Pp The following .Xr make 1 environment variables are supported: .Bl -tag -width Ev .It Va CLOUDWARE Set to a list of one or more cloud hosting providers, enclosed in quotes. Requires .Va WITH_CLOUDWARE to also be set. .It Va WITH_CLOUDWARE Set to a non-empty value to enable building virtual machine images for various cloud hosting providers. Requires .Va CLOUDWARE to also be set. .El .Pp Additionally, the .Va CLOUDWARE and .Va WITH_CLOUDWARE variables can be added to .Pa release.conf , and used in conjunction with .Pa release.sh . .Pp For a list of supported .Va CLOUDWARE values, run: .Bd -literal -offset indent cd /usr/src make -C release list-cloudware .Ed .Sh MAKEFILE TARGETS The release makefile .Pq Pa src/release/Makefile is fairly abstruse. Most developers will only be concerned with the .Cm release and .Cm install targets. .\" XXX: Some sort of introduction to this list? All the others have one. .Bl -tag -width ".Cm packagesystem" .It Cm release Meta-target to build all release media and distributions applicable to this platform. .It Cm install Copy all produced release media to .Pa ${DESTDIR} . .It Cm cdrom Builds installation CD-ROM images. This may require the .Xr md 4 (memory disk) device driver be present in the kernel (either by being compiled in or available as a module). This target produces files called .Pa disc1.iso and .Pa bootonly.iso as its output. .It Cm dvdrom Builds installation DVD-ROM images. This may require the .Xr md 4 (memory disk) device driver be present in the kernel (either by being compiled in or available as a module). This target produces the .Pa dvd1.iso file as its output. .It Cm memstick Builds an installation memory stick image named .Pa memstick.img . Not applicable on all platforms. Requires that the .Xr md 4 .Pq memory disk device driver be present in the kernel .Pq either by being compiled in or available as a module . .It Cm mini-memstick Similar to .Cm memstick , with the exception that the installation distribution sets are not included. .It Cm ftp Creates a directory named .Pa ftp containing the distribution files used in network installations and suitable for upload to an FTP mirror. .It Cm vm-image Creates virtual machine disk images in various formats. The .Cm vm-image target requires the .Va WITH_VMIMAGES .Xr make 1 environment variable to be set to a non-null value. .It Cm vm-cloudware Builds .Fx virtual machine images for various cloud hosting providers. See .Qq CLOUD HOSTING MACHINE IMAGES for implementation details. .It Cm list-cloudware Displays the list of valid .Va CLOUDWARE values. .It Cm list-vmtargets Displays the list of valid .Va VMFORMAT and .Va CLOUDWARE values. .El .Pp Major subtargets called by targets above: .Bl -tag -width ".Cm packagesystem" .It Cm packagesystem Generates all the distribution archives .Pq base, kernel, ports, doc applicable on this platform. .It Cm disc1 Builds a bootable installation system containing all the distribution files packaged by the .Cm packagesystem target, and suitable for imaging by the .Cm cdrom , .Cm dvdrom and .Cm memstick targets. .It Cm reldoc Builds the release documentation. This includes the release notes, hardware guide, and installation instructions. Other documentation, such as the Handbook, is built during the .Cm base.txz target invoked by .Cm packagesystem . .El .Sh ENVIRONMENT Optional variables: .Bl -tag -width ".Ev TARGET_ARCH" .It Ev OSRELEASE Optional base name for generated media images when invoking the .Cm install target .Pq e.g., FreeBSD-12.1-RELEASE-amd64 . Defaults to the output of .Ic `uname -s`-`uname -r`-`uname -p` within the chroot. .It Ev WORLDDIR Location of a directory containing the src tree. By default, the directory above the one containing the makefile .Pq Pa src . .It Ev PORTSDIR Location of a directory containing the ports tree. By default, .Pa /usr/ports . If it is unset or cannot be found, ports will not be included in the release. .It Ev NOPORTS If defined, the Ports Collection will be omitted from the release. .It Ev NOSRC If set, do not include system source code in the release. .It Ev TARGET The target hardware platform. This is analogous to the .Dq Nm uname Fl m output. This is necessary to cross-build some target architectures. For example, cross-building for ARM64 machines requires .Ev TARGET_ARCH Ns = Ns Li aarch64 and .Ev TARGET Ns = Ns Li arm64 . If not set, .Ev TARGET defaults to the current hardware platform. .It Ev TARGET_ARCH The target machine processor architecture. This is analogous to the .Dq Nm uname Fl p output. Set this to cross-build for a different architecture. If not set, .Ev TARGET_ARCH defaults to the current machine architecture, unless .Ev TARGET is also set, in which case it defaults to the appropriate value for that platform. Typically, one only needs to set .Ev TARGET . .El .Sh FILES .Bl -tag -compact -width Pa .It Pa /usr/doc/Makefile .It Pa /usr/doc/share/mk/doc.project.mk .It Pa /usr/ports/Mk/bsd.port.mk .It Pa /usr/ports/Mk/bsd.sites.mk .It Pa /usr/share/examples/etc/make.conf .It Pa /usr/src/Makefile .It Pa /usr/src/Makefile.inc1 .It Pa /usr/src/release/Makefile .It Pa /usr/src/release/Makefile.vm .It Pa /usr/src/release/release.sh .It Pa /usr/src/release/release.conf.sample .It Pa /usr/src/release/tools/*.conf .It Pa /usr/src/release/tools/vmimage.subr .El .Sh EXAMPLES The following sequence of commands can be used to build a .Dq "-CURRENT snapshot": .Bd -literal -offset indent cd /usr git clone -b main https://git.freebsd.org/src.git src cd src make buildworld buildkernel cd release make obj make release make install DESTDIR=/var/freebsd-snapshot .Ed .Pp After running these commands, all produced distribution files (tarballs for FTP, CD-ROM images, etc.) are available in the .Pa /var/freebsd-snapshot directory. .Pp The following sequence of commands can be used to build a .Dq "-CURRENT snapshot" in a clean environment, including ports and documentation: .Bd -literal -offset indent cd /usr/src/release sh release.sh .Ed .Pp Optionally, a configuration file can be used to customize the release build: .Bd -literal -offset indent cd /usr/src/release sh release.sh -c $HOME/release.conf .Ed .Pp Configuration files specific to various supported embedded systems, such as the Raspberry Pi, exist in the directory corresponding to the .Va TARGET .Xr make 1 variable. For example, to build an image for the Raspberry Pi: .Bd -literal -offset indent cd /usr/src/release sh release.sh -c arm/RPI-B.conf .Ed .Pp To build an image for the Raspberry Pi 3: .Bd -literal -offset indent cd /usr/src/release sh release.sh -c arm64/RPI3.conf .Ed .Pp After running these commands, all prepared release files are available in the .Pa /scratch directory. The target directory can be changed by specifying the .Va CHROOTDIR variable in .Li release.conf . .Sh COMPATIBILITY The reldoc target was removed in commit f61e92ca5a23, and .Ev DOCDIR , .Ev DOCBRANCH , .Ev DOC_UPDATE_SKIP , and .Ev NODOC are therefore no longer supported. .Sh SEE ALSO .Xr cc 1 , .Xr git 1 Pq Pa ports/devel/git , .Xr install 1 , .Xr make 1 , .Xr mkimg 1 , .Xr uname 1 , .Xr md 4 , .Xr make.conf 5 , .Xr build 7 , .Xr ports 7 , .Xr chroot 8 , .Xr mtree 8 , .Xr sysctl 8 .Rs .%T "FreeBSD Release Engineering" .%U https://docs.freebsd.org/en/articles/freebsd-releng/ .Re .Rs .%T "FreeBSD Developers' Handbook" .%U https://docs.freebsd.org/en/books/developers-handbook/ .Re .Sh HISTORY .Fx 1.x used a manual checklist, compiled by .An Rod Grimes , to produce a release. Apart from being incomplete, the list put a lot of specific demands on available file systems and was quite torturous to execute. .Pp As part of the .Fx 2.0 release engineering effort, significant effort was spent getting .Pa src/release/Makefile into a shape where it could at least automate most of the tediousness of building a release in a sterile environment. .Pp For the .Fx 9.0 release, .Pa src/release/Makefile was overhauled and the wrapper script .Pa src/release/generate-release.sh introduced to support the introduction of a new installer. .Pp For the .Fx 9.2 release, .Pa src/release/release.sh was introduced to support per-build configuration files. .Pa src/release/release.sh is heavily based on the .Pa src/release/generate-release.sh script. .Pp At near 1000 revisions spread over multiple branches, the .Xr git 1 log of .Pa src/release/Makefile contains a vivid historical record of some of the hardships release engineers go through. .Sh AUTHORS .Pa src/release/Makefile was originally written by .An -nosplit .An Rod Grimes , .An Jordan Hubbard , and .An Poul-Henning Kamp . .Pp This manual page was originally written by .An Murray Stokely Aq Mt murray@FreeBSD.org . .Pp It was updated by .An Nathan Whitehorn Aq Mt nwhitehorn@FreeBSD.org to include the .Fa generate-release.sh script used for the .Fx 9.0 release cycle. .Pp It was later updated by .An Glen Barber Aq Mt gjb@FreeBSD.org to include the .Fa release.sh script used for the .Fx 9.2 release cycle.