How to build dilos-illumos

Prepare Build Environment

This instruction based on page: "How To Build illumos"

To build dilos-illumos on DilOS you should follow the steps below.

NOTE:

You need to upgrade DilOS. This step is required only once and should be made only in the global zone before preparing the build environment. You need to have 'sudo' permissions for your build user for DEB packages generation process. Please update the /etc/sudoers file with the correct info. Instructions are based on updates and sources tree tag with update from 'dilos-unstable'. Add the repository below to the top of the /etc/apt/sources.list file:

deb http://apt.dilos.org/dilos dilos2-unstable main

and issue the following commands:

sudo apt-get update && sudo dilos-upgrade

You will be upgraded to new BE. Please reboot after successful upgrade.

It is not recommended to build DilOS in the global zone. It is suggested creating new zone for the building process. As an example refer to the following links for more details about zone and network configuration:

Zone creation: How to setup DPKG zone

Network configuration: How to configure NAT

It is recommended to have at least 2G of RAM and 2G of swap. To update swap size, use the steps below in a global zone, don't forget to reboot to enable swap:

Add swap:
$ sudo zfs set volsize=2g rpool/swap
$ sudo reboot

You can change the swap size on the fly. To do it do:

change the swap size on the fly
$ /usr/sbin/swap -lh
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 129,3        4K    2,00G    2,00G
$ sudo swap -d /dev/zvol/dsk/rpool/swap
$ sudo zfs set volsize=4g rpool/swap
$ sudo swap -a /dev/zvol/dsk/rpool/swap
$ /usr/sbin/swap -lh
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 129,3        4K    4,00G    4,00G

All the commands below are executed in newly created zone (not global). The build process should be run from the user with the sudo permissions (not root). Please note that the NOPASSWD option should be added to this user in the /etc/sudoers file.

Update permission for build user:
# /system/bin/usermod -P 'Primary Administrator' yournonrootuser


Install packages:
$ sudo apt-get install git ca-certificates
$ sudo update-ca-certificates -d # need it for first time

Prepare dilos-userland-gate clone: 

INFO

For clone dilos-illumos you have to create account on BitBucket and send it by BitBucket mail form to account 'dilos' - I'll add you to repo

$ git clone -b int2 https://bitbucket.org/dilos/dilos-illumos.git my-dilos-illumos
Install build dependencies:
$ cd <my-dilos-illumos>
$ tools/bld_pkgs.sh
Download and unpack closed binaries
$ cd my-dilos-illumos
$ sudo apt-get install wget
$ wget -c \
  https://download.joyent.com/pub/build/illumos/on-closed-bins.i386.tar.bz2 \
  https://download.joyent.com/pub/build/illumos/on-closed-bins-nd.i386.tar.bz2
$ tar xjvpf on-closed-bins.i386.tar.bz2
$ tar xjvpf on-closed-bins-nd.i386.tar.bz2

Prepare illumos.sh

Copy original illumos.sh:
$ cp usr/src/tools/env/illumos.sh .

The settings we are going to focus on for now are the following:

  • CODEMGR_WS - This should be the root of the directory with the code. If you followed the previous example, it will be /<your directory>/my-dilos-illumos.
  • STAFFER - Change this to the name of the non-privileged user you use on the system.
  • VERSION - Set this to illumos-gate or whatever version string you want for the build.
  • CLONE_WS - is the workspace nightly should do a bringover from. You can update it to: export CLONE_WS='https://bitbucket.org/dilos/dilos-illumos-gate'. This variable need for 'webrev' tool.

For GCC build only you have to add to your illumos.sh:

# on Intel and SPARC we use GCC6 that already defined on build system

export GNUC_ROOT="/usr/gcc/6"						# path to GCC binaries installed
export PRIMARY_CC=gcc6,/usr/lib/ccache/gcc-6,gnu
export PRIMARY_CCC=gcc6,/usr/lib/ccache/g++-6,gnu

# disable SMB_PRINTING
export ENABLE_SMB_PRINTING='#'

These variables are needed for the verstion identification and the DEB packages tools:

export GATE='2.0.2.40-dbg'							# it is variable will be updated on loading kernel screen.
export BLD_REVISION=$(git log -1 --pretty=format:%h)
export DEB_VERSION="2.0.2.40-1"					# DEB packages version, must be incremented for correct upgrade
export DEB_MAINTAINER="Igor Kozhukhov <ikozhukhov@gmail.com>"	# you can use your name here
export DPKG_BUILD_FLAGS="-b -d -uc"				# flags for dpkg-buildpackage. You can provide your flags.

Note:

Version in DEB_VERSION must be higher then current installed version of package 'libc-dev'
Check your version of libc using :  dpkg -l | grep libc
Example:
If you have installed libc-2.0.2.7 for your build you can use: 
DEB_VERSION="2.0.2.7-2"
or
DEB_VERSION="2.0.2.8"
or another higher version
Prepare build tools:
$ ln -s usr/src/tools/scripts/bldenv .
$ ksh93 bldenv -d illumos.sh -c "cd usr/src && dmake setup"	# -d - if you use DEBUG build. You have to remove it for non-DEBUG build
# on SPARC:
$ sudo rm -rf /opt/onbld && sudo cp -ax usr/src/tools/proto/root_sparc-nd/opt/onbld /opt/
# Or on Intel:
$ sudo rm -rf /opt/onbld && sudo cp -ax usr/src/tools/proto/root_i386-nd/opt/onbld /opt/

Start Build

INFO

Will be better to start build process on 'screen' terminal. You can install it by command: ($ sudo apt-get install screen)

If you modified profile to "Primary administrator" by usermod, you need to relogin to the build zone (or via ssh)

To run the full build procedure, please issue the commands below:

$ cp usr/src/tools/scripts/nightly .
$ time ./nightly illumos.sh

Note that the command does not give any progress output. You can instead follow the log file at log/nightly.log, which is updated (slowly) during the build process. In another terminal, run:

$ tail -f log/nightly.log

For the incremental build, the following command can be used (don't forget to increase the DEB_VERSION number):

$ time ./nightly -i illumos.sh

Update to New Build

Update Using apt-get

New build should be installed from the global zone. Add the build path to the apt repo list, for instance it could be something like:

$ cat /etc/apt/sources.list
# Main repository sources
deb [trusted=yes] file:///export/home/admin/my-dilos-illumos/packages/i386/apt unstable main
deb http://apt.dilos.org/dilos dilos-testing main contrib non-free

Issue an "apt-get update" command to check get new deb packets information. Check that there are no issues with new repo. Note that it is ok to get the warning message below:

$ sudo apt-get update
...
Reading package lists... Done                                                   
W: The repository 'file:/export/home/dim/my-dilos-illumos/packages/i386/apt unstable Release' is not signed. 
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. 
N: See apt-secure(8) manpage for repository creation and user configuration details.

Run upgrade procedure:

$ sudo os-upgrade
...
upgrade done

Updating bootarchive ...
Activating 'dilos_<version>' ...

Now you can reboot to new 'dilos_<version>'.

Update Using onu-deb ( unsupported, but can be updated by others and contributed )

Note that in this case the developer-build-onbld-deb packet should be installed on system:

$ sudo apt-get install developer-build-onbld-deb # if you want to use onu-deb

Install new DEB packages to newBE by using onu-deb:

$ /opt/onbld/bin/onu-deb -t nightly-`date +%Y-%m-%d` -d $PWD/packages/i386/apt

where newBE = nightly-`date +%Y-%m-%d`