IllumosBuildのソース

#freeze
[[Solarisのページに戻る>Solaris]]

目次
#contentsx

------
** OpenIndiana で illumos をbuild する方法 : [#k67fe3d5]

参考記事 [[Building illumos>https://illumos.org/docs/developers/build/]]

***準備 [#o1d22831]
お約束ですが、まずシステムを最新状態にアップデートします。
  $ sudo pkg update
Update には、けっこう時間がかかりますがアップデートがおわったら、リブートします。
  $ sudo reboot
リブート後は最新環境の BEで起動されています。 

OpenIndiana 上では build-essential パッケージを追加でインストールします。さらに最新 build に必要な GCC7 と Python 3.5 を追加でインストールします。
  $ sudo pkg install build-essential  runtime/python-35 developer/gcc-7
次に build のためのワークスペースを作成します。 OpenIndiana の build では  /code が使われているので /code  にします。
  $ sudo  zfs create -o mountpoint=/code rpool/code
/code はユーザでRW可能なプロパティに変更しておきます。

次に /code の下に illumos のソースコードを展開します。
  $ cd /code
  $ git clone https://github.com/illumos/illumos-gate.git
展開すると /code/illumos-gate ディレクトリが作成されます。これが実際の build workspace となります。
***クローズドバイナリの準備(オプション) [#e2e3c0b1]
最新の OpenIndiana もしくは OmniOS(r151016 or later)では、/opt/onbld/closed  に必要なクローズドバイナリはインストールされているので ON_CLOSED_BINS 環境変数の設定だけでインストールは必要ありません。

必要な場合は、以下の方法でダウンロードして build workspace に展開します。

  $ cd /code/illumos-gate
  $ 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

***Build の環境設定 [#v398324f]
Build の環境設定はソースにある illumos.sh を編集して行います。
  $ cd /code/illumos-gate
  $ cp usr/src/tools/env/illumos.sh .
  $ vi illumos.sh

OpenIdiana の場合は、下記を書き足します。
  #
  # Set a package version number which is greater than the current OpenIndiana
  # build number.  Note that ONNV_BUILDNUM is ignored if PKGVERS_BRANCH is set:
  #
  export PKGVERS_BRANCH=9999.99.0.0
  
  #
  # Set to current version of Perl shipped with OpenIndiana:
  #
  export PERL_VERSION="5.22"
  export PERL_PKGVERS="-522"
  export BUILDPERL64="#"
  
  #
  # If you are building on the latest OpenIndiana (2017-03-07 and later), use
  # OpenJDK 8:
  #
  export BLD_JAVA_8=
  
  #
  # IPS packages published at 2019-08-08 and later ship only Python 3.5 modules,
  # so you have to use this Python version to build illumos tools
  # if your pkg:/package/pkg version is 0.5.11-2019.0.0.5521 or later.
  #
  export BUILDPY2TOOLS="#"
   
  #
  # Use the copy of the closed binaries that comes with the "build-essential"
  # package:
  #
  export ON_CLOSED_BINS="/opt/onbld/closed"

あと .bashrc や .profile に 
export CODEMGR_WS=/code/illumos-gate
 入れておきます。

***Build の実行 [#i61bc4dd]
build する際は build command を screen や tmux から起動するといいでしょう。
フル build を開始するには

  $ cd /code/illumos-gate
  $ time ./usr/src/tools/scripts/nightly illumos.sh

ログは  log/nightly.log から確認できます。
  $ tail -F /code/illumos-gate/log/nightly.log
エラーやワーニングを確認するには
  $ tail -F /code/illumos-gate/log/nightly.log | grep -5 '(error|warning).*: '

build が完了すると log/latest/mail_msg にサマリーが書かれます。
もし mail_msg に submitting a patch の内容が書かれていれば  build は成功しています。

***Incremental build (差分 build)の実行 [#q9dc3cf2]
nightly build が成功したあと、コードの変更分だけの追加しての build を行うには -i オプションを付けます

  $ cd /code/illumos-gate
  $ time ./usr/src/tools/scripts/nightly -i illumos.sh

※なお、patch を当てる場合は、incremental build でなく  full build を行う必要があります。

***Build した環境のインストール [#fa42eab8]
 
Build 時にNIGHTLY_OPTIONS 環境変数で、 DEBUG Build か non-DEBUG build かと指定できます。

Build で作成されたパッケージはwotkspace の以下にあります。

packages/i386/nightly for a DEBUG build

packages/i386/nightly-nd for a non-DEBUG build

作成されたパッケージは、onu コマンドを使ってインストールします。

DEBUG build の例

  $ sudo /code/illumos-gate/usr/src/tools/proto/root_i386-nd/opt/onbld/bin/onu \
      -t "$(date -u +nightly-%Y%m%d-%H%MZ)" \
      -d "/code/illumos-gate/packages/i386/nightly"

**OmniOS で illumos-gate を build する方法 [#r1983420]

参考記事 [[Building illumos-gate on OmniOS>https://omniosce.org/dev/gate]]

OmniOS の build では  /build が使われているので /build  にします。

  $ pfexec pkg install illumos-tools
  $ pfexec zfs create -o mountpoint=/build rpool/build
  $ cd /build
  $ git clone https://github.com/illumos/illumos-gate
  $ cd illumos-gate
  $ ./usr/src/tools/scripts/nightly /opt/onbld/env/omnios-illumos-gate

illumos-gate の build だけでしたらこれで済むはずですが、まだ build が成功したことはありません。

omuni utility を使った build の方法が、下記で紹介されてますが
参考記事 [[Building OmniOS>https://omniosce.org/dev/build_instructions.html]]

現在は  illumos-omnios という illumos-gate から folk された github のソースが有効ではなくなったので

build スクリプト omuni の実行中に ソース展開で失敗してしまいます。 どうやら

参考記事 [[Building illumos>https://illumos.org/docs/developers/build/]]


の OmuniOS 用の方法で build するのが最新情報のようです。

***準備 [#b636c60e]

  $ sudo pkg update

の後、再起動後に以下を実行し、OmniOS 上の build で必要なツールをインストールします。

  $ sudo pkg install pkg:/developer/illumos-tools

***Build の環境設定 [#redf08f9]

OpenIndiana  上での build と違うのは、以下の内容を illumos.sh に追加します。

  # Set to the current perl version (this is correct for OmniOS r151028)
  export PERL_VERSION=5.28
  export PERL_ARCH=i86pc-solaris-thread-multi-64int
  export PERL_PKGVERS=
   
  # Set to current python3 version (this is correct for OmniOS r151028)
  export PYTHON3=/usr/bin/python3.5
  export TOOLS_PYTHON=$PYTHON3
  
  export SPRO_ROOT=/opt/sunstudio12.1
  export SPRO_VROOT="$SPRO_ROOT"
  export ONLY_LINT_DEFS="-I${SPRO_ROOT}/sunstudio12.1/prod/include/lint"
  export ON_CLOSED_BINS=/opt/onbld/closed
  
  export __GNUC=
  export GNUC_ROOT=/opt/gcc-7/
  export PRIMARY_CC=gcc7,/opt/gcc-7/bin/gcc,gnu
  export PRIMARY_CCC=gcc7,/opt/gcc-7/bin/g++,gnu
  export SHADOW_CCS=gcc4,/opt/gcc-4.4.4/bin/gcc,gnu
  export SHADOW_CCCS=gcc4,/opt/gcc-4.4.4/bin/g++,gnu
  
  SMATCHBIN=$CODEMGR_WS/usr/src/tools/proto/root_$MACH-nd/opt/onbld/bin/$MACH/smatch
  export SHADOW_CCS="$SHADOW_CCS smatch,$SMATCHBIN,smatch"
  
  # This will set ONNV_BUILDNUM to match the release on which you are building, allowing ONU.
  export ONNV_BUILDNUM=`grep '^VERSION=r' /etc/os-release | cut -c10-`
  export PKGVERS_BRANCH=$ONNV_BUILDNUM.0

追加で以下の IPPとSMB printing option を無効にしておきます。

  # export ENABLE_IPP_PRINTING=
  # export ENABLE_SMB_PRINTING=

このあとの build 方法は OpenIndiana と共通です。