#!/usr/local/bin/cbsd
CBSDMODULE=
MYARG=""
MYOPTARG="arch basename ccache clean distcc qemu maxjobs nice notify target_arch target_cputype ver"
MYDESC="Run 'cbsd buildworld' and 'cbsd installworld' atomic"
ADDHELP="

${H3_COLOR}Description${N0_COLOR}:

Build/compile basejail from source tree. This is a wrapper script for 
build/installworld: 'cbsd world' = 'cbsd buildworld' + 'cbsd installworld'.

As a result of the work, you will get a copy of the FreeBSD "rootfs" (base for jail) 
in the ~cbsd/basejail/ directory.

${H3_COLOR}Options${N0_COLOR}:

 ${N2_COLOR}arch=${N0_COLOR}              - <name>, use non-native architectures.
 ${N2_COLOR}basename=${N0_COLOR}          - Prefix for directory name, can be used for jail as alternative base.
 ${N2_COLOR}destdir=${N0_COLOR}           - <path> - alternative DESTDIR= path instead of ~cbsd/basejail/.
 ${N2_COLOR}qemu=${N0_COLOR}              - '0' - copy (default) or '1' - do not copy the
                     qemu emulator into base /bin;
 ${N2_COLOR}register_basename=${N0_COLOR} - <name> register with alternative/custom basename.
 ${N2_COLOR}target_arch=${N0_COLOR}       - <name>, build non-native target arch.
 ${N2_COLOR}ver=${N0_COLOR}               - set version: '14.2', '15.1';
                      when version without minor version: e.g:
                     '14' or '15' - you will receive RELENG (stable=1), not release.

${H3_COLOR}Examples${N0_COLOR}:

 # cbsd world
 # cbsd world destdir=/tmp/testbase
 # cbsd world ver=14.2 arch=arm64 target_arch=aarch64
 # cbsd world ver=14.3 arch=riscv target_arch=riscv64

${H3_COLOR}See also${N0_COLOR}:

  cbsd buildworld --help
  cbsd installworld --help
  cbsd srcup --help
  cbsd bases --help
  cbsd sources --help
  cbsd mkdistribution --help
  cbsd baseupdate --help

"

ARGS="${*}"
. ${subrdir}/nc.subr
. ${cbsdinit}

buildworld ${ARGS} && installworld ${ARGS}

exit $?
