#
Details of building process.

For those of you who really want to know what's going on behind the scene, and can't quite deduce it from scripts themselves, here's short description of the build process:

- The './build' script sets the basic parameters of the floppy, such as:
  - LANGUAGE: language of the various system messages, and C locale. Available choices are: "en" (English) and "pl" (Polish).
  - SIZE: size of the memory filesystem (MFS), which will contain all the binaries (except the kernel). Make it big enough for all the pieces to fit, but keep it as small as possible (remember that running system needs some space in /var and /tmp!). Presently, "dial" type of floppy requires at least SIZE=1700, and others require ca. 2800 (numbers are in kB).
  - TYPE: determines which set of programs and which trees will be installed on the floppies. This simply acts as a selector to dive into respective subdirectories in ../. Presently, the TYPE can be one of: "dial" (dialup floppy), "net" (networking floppy), "router" (router floppy) or "isp" (work in progress - not really usable yet).
- Then the './build' scripts checks if there is a kernel built on basis of previously set parameters. The check is error prone, but is simple: the target config file is called PICOBSD-${TYPE}.${SIZE}, and if there exists a file called /sys/compile/PICOBSD-${TYPE}.${SIZE}/kernel, then it is assumed it's the right one.

  If there is no such file, the script starts compilation of the kernel, using template in ../${YTPE}/conf/PICOBSD, and adding parameters which determine the built-in MFS size.

- Then the './build' script starts the consecutive stages of the build process, which are performed by scripts (in the following order): stage1, populate, stage2, stage3.
- 'stage1' prepares the file called fs.PICOBSD with given size - it's a placeholder for the future MFS. Next, it turns it into device (using vnconfig), and then performs some tricks :-) which allow for doing 'disklabel'. I use the 'auto' option to disklabel(8), which behaves strangely in 2.2.x - what it's supposed to do is to automagically determine the disk parameters from the underlying device (in this case, /dev/rvn0). This works ok in 3.0-current, and allows for using arbitrary (>1024kB) MFS sizes.

  One notable exception here is with the "router" floppy - I use one of extended floppy formats (820kB).

  After the file is labelled, the newfs(8) is run. Here you can adjust the parameter -i, which can gain you some space on the MFS (sacrificing available number of inodes, so be careful).

  Such prepared blank filesystem is mounted on /mnt. Here the stage1 ends.

- 'populate', as its name suggests, transfers all the pieces which will reside in MFS, to the filesystem mounted on /mnt. This includes:
  - copying language dependent files from ../${TYPE}/lang/
  - making the MFS hierarchy according to informations in ../${TYPE}/mfs.tree/ subdir.

    The MFS tree includes the /etc, which will contain the startup file /etc/rc. This file in turn doesn't do anything useful except copying the real /etc hierarchy from the floppy filesystem. (There's one possible improvement which comes to my mind - to have the whole /etc on the floppy in tar.gz - this would require only one inode to store the whole /etc, and we could gain some kB on the floppy)

  - making and installing the set of crunched programs, basing on the description in ../${TYPE}/crunch1/crunch.conf. This involves making the 'crunch', copying it to /mnt and making hard links to the names of all the programs contained therein.
  - preparing a short list of kernel symbols, which will be used by various utilities at runtime. In case of "net" and "isp" floppy, it also prepares the kvm_kernel.db database, which will be used by such programs as ps, netstat and others
  - preparing the list of "virgin" configuration of devices in kernel - this list will be used by kget(8) program to save the changes to /kernel.config file.
- 'stage2' prepares the target kernel. It takes the filesystem contained in fs.PICOBSD (which has all the above pieces inside), and writes it into the target kernel. Then it kzip(8)'s such construed kernel. This process also strips the symbols from the kernel (that's why we prepared the symbol list earlier).
- 'stage3' does almost the same as 'stage1', but this time it prepares the filesystem of the target floppy. Default size for the floppy is set at 1440kB.

  After preparing the filesystem (which again involves doing disklabel(8) and newfs(8) - here you can notice that the resulting FS has very small number of inodes in order to save space), the script transfers the floppy hierarchy (which is taken from ../${TYPE}/floppy.tree). Notice that it also contains the /etc directory - its contents is copied right after bootup to the real /etc in MFS. This allows for changing the system behaviour (because you can't change the MFS contents without recompiling).

  The script finally copies previously prepared kernel to the floppy filesystem. The filesystem is unmounted, and here the build process ends.

###### Last modified: @DATE@