Contents |
An attempt at pulling the nanobsd development fragmentation back into a single place.
Sources can be checked out from subversion:
svn co http://svn.tomjudge.com/freebsd/nanobsd
Or viewed in ViewVC.
A target is a NanoBSD configuration that can build images for multiple hardware platforms. Each target has the following basic structure (relative to nanobsd installation base):
targets
target/{target name}
target/{target name}/nanobsd.conf
target/{target name}/make.conf.build
target/{target name}/make.conf.install
target/{target name}/Files
target/{target name}/{target arch}/nanobsd.conf
target/{target name}/{target arch}/make.conf.build
target/{target name}/{target arch}/make.conf.install
target/{target name}/{target arch}/Files
Each of the configuration files in the base of the target are processed first at the relevant stages. After these have been processed then the script will check to see if there is a config file in the target architecture sub directory and include it to override options on per platform basis.
You can add lines like those that follow to the nanobsd.conf in base of the target to restrict the supported architectures:
case ${NANO_ARCH} in i386) ;; *) echo "$0: Target ${NANO_TARGET} does not support the requested architecture ${NANO_ARCH}" >&2 exit 1 esac
This snippet will allow the target to built only on i386 systems.
In the original nanobsd there is a core set of functions embedded in the shell script and if you want to make changes to them you have to redefine them; also if you wanted to add extra functions you would normally end up defining them in the config file. Personally I find this solution rather ugly, so one of the main features of NanoBSD NG is to split each function into a separate file.
These functions setup the following variables based on the manufacturer/type and size of the media:
NanoBSD currently provides support for creating disk images for the following platforms:
Platform support is provided by create_{arch}_diskimage functions.
These functions are covered in detail in the customization section of usage.
This assumes we are creating a target called: tiny.
Check out a working copy of NanoBSD NG:
cd /usr/local svn co http://svn.tomjudge.com/freebsd/nanobsd nanobsd cd nanobsd
I would recommend you take a look at targets/default/nanobsd.conf, this file contains the default settings for the configuration options.
Now you need create the target directory and create some config files:
mkdir targets/tiny
We are going to put the following settings in targets/tiny/nanobsd.conf
NANO_NAME=TINY NANO_SRC=/usr/src NANO_KERNEL=GENERIC NANO_IMAGES=2 FlashDevice Sandisk 2g
If you want to make a bootable CD (you will need cdrtools installed) then you can replace the FlashDevice line with:
NANO_IMAGE_TYPE=cd
Now you can place tunable knobs (see src.conf(5) and make.conf(5)) to the the targets build configuration files:
We don't bind or games in our build so we add the following to targets/tiny/make.conf.build
WITHOUT_BIND=YES WITHOUT_GAMES=YES
We also don't want to install a tool chain into the image so we add the following to targets/tiny/make.conf.install
WITHOUT_TOOLCHAIN=YESNow we can generate the build:
./nanobsd.sh -t tiny
If we want to cross build an amd64 image we can do the following:
./nanobsd.sh -t tiny -a amd64
The nanobsd framework is very flexiable and will allow you to customize the created image in any way you want. The system ships with a number of functions out the box to help you customize you images.
You can register customization functions to run using one of the following configuration directives in your nanobsd.conf.
Example:
customize_cmd cust_pkg customize_cmd cust_console_serial
The variable NANO_SERIAL_SPEED is used by all of the console customization functions to set the speed of the serial ports. This variable should contain the port speed in bps. The default speed is 9600 baud.
The system includes two functions to help you install packages in your images. These functions are only compatible with image creation for the same target architecture as the host environment. The only notable exception to this is building i386 images on amd64 hosts, this should work but at the time of writing is untested.
Packages can have post customize functions associated with them that are called at the end of the standard customization phase of the build. These are useful for example to correct the permissions of files that have been copied into the image with cust_install_files. These functions live in functions/pacakges/pkg_{package_name}. Some example functions are included with nanobsd.
Incorporate the following PR's