このケーススタディーで使用するパッケージには、3 種類のオブジェクトがあります。インストールするオブジェクトの種類と、インストール先マシン内でオブジェクトを配置する場所は、管理者が選択できます。
このケーススタディーでは、次の手法の実例を示します。
パラメータ型パス名 (オブジェクトのパス名に変数を含めたもの) を使用し、複数のベースディレクトリを確立する
パラメータ型パス名については、「パラメータ型パス名」を参照してください。
request スクリプトを使用して、管理者による入力を要求する
request スクリプトについては、「request スクリプトの書き込み」を参照してください。
インストールパラメータの条件値を設定する。
このケーススタディーで選択的インストールを設定するには、次の作業を完了する必要があります。
インストール可能な各タイプのオブジェクトについてクラスを定義します。
このケーススタディーの場合、オブジェクトのタイプには、パッケージ実行可能ファイル、マニュアルページ、および emacs 実行可能ファイルの 3 種類があります。各タイプには、それぞれ bin、man、および emacs というクラスが定義されています。prototype ファイルでは、すべてのオブジェクトファイルは、これら 3 つのクラスのいずれかに属しています。
pkginfo ファイル内の CLASSES パラメータを null に初期化します。
通常、クラスを定義する場合は、そのクラスを pkginfo ファイルの CLASSES パラメータにリストします。リストしない場合、そのクラスのオブジェクトはインストールされません。このケーススタディーでは、このパラメータは初期値として null に設定されているため、オブジェクトはインストールされません。CLASSES パラメータは、管理者の選択に基づいて、request スクリプトによって変更されます。そうすることで、CLASSES パラメータには、管理者がインストールするように選択したオブジェクトタイプだけが設定されます。
通常は、各パラメータはデフォルト値に設定することをお勧めします。3 つすべてのオブジェクトタイプに共通のコンポーネントがこのパッケージに含まれている場合は、それらのコンポーネントを none クラスに割り当て、CLASSES パラメータを none に設定します。
prototype ファイルにパラメータ型パス名を挿入します。
これらの環境変数は、request スクリプトによって、管理者が指定した値に設定されます。次に、pkgadd コマンドによって、インストール時にこれらの環境変数が解釈処理され、パッケージのインストール先が決定されます。
この例で使用される 3 つの環境変数は、pkginfo ファイルでそれぞれのデフォルト値に設定されます。これらの環境変数の用途は次のとおりです。
$NCMPBIN は、オブジェクト実行可能ファイルの場所を定義します。
$NCMPMAN は、マニュアルページの場所を定義します。
$EMACS は、emacs 実行可能ファイルの場所を定義します。
サンプルの prototype ファイルに、変数を使用してオブジェクトパス名を定義する方法を示します。
管理者に、パッケージのどの部分をインストールし、どこに配置するかを質問する request スクリプトを作成します。
このパッケージ用の request スクリプトは、管理者に対して次の 2 つの質問をします。
パッケージのこの部分をインストールするかどうか
管理者が「y (はい)」 と答えた場合には、適切なクラス名が CLASSES パラメータに追加されます。たとえば、管理者がこのパッケージに関連するマニュアルページをインストールするように選択した場合は、クラス man が CLASSES パラメータに追加されます。
インストールする場合、パッケージのこの部分をどこに配置するか
この質問に対する応答として指定した場所が、該当する環境変数に設定されます。マニュアルページの例では、変数 $NCMPMAN が、応答として指定した値に設定されています。
これら 2 つの質問は、3 つのオブジェクトタイプのそれぞれについて繰り返されます。
request スクリプトの実行が終了すると、これらのパラメータはインストール環境で pkgadd コマンドやその他のパッケージ作成スクリプトを実行する際に使用できるようになります。request スクリプトは、これらの定義を呼び出しユーティリティから指定されたファイルに書き込むことで、パラメータを使用可能にします。このケーススタディーでは、これ以外のスクリプトは使用しません。
このケーススタディーで使用する request スクリプトでは、質問はデータ検証ツールの ckyorn および ckpath によって生成されています。これらのツールについては、ckyorn(1)およびckpath(1)を参照してください。
PKG=ncmp NAME=NCMP Utilities CATEGORY=application, tools BASEDIR=/ ARCH=SPARC VERSION=RELEASE 1.0, Issue 1.0 CLASSES="" NCMPBIN=/bin NCMPMAN=/usr/man EMACS=/usr/emacs |
i pkginfo i request x bin $NCMPBIN 0755 root other f bin $NCMPBIN/dired=/usr/ncmp/bin/dired 0755 root other f bin $NCMPBIN/less=/usr/ncmp/bin/less 0755 root other f bin $NCMPBIN/ttype=/usr/ncmp/bin/ttype 0755 root other f emacs $NCMPBIN/emacs=/usr/ncmp/bin/emacs 0755 root other x emacs $EMACS 0755 root other f emacs $EMACS/ansii=/usr/ncmp/lib/emacs/macros/ansii 0644 root other f emacs $EMACS/box=/usr/ncmp/lib/emacs/macros/box 0644 root other f emacs $EMACS/crypt=/usr/ncmp/lib/emacs/macros/crypt 0644 root other f emacs $EMACS/draw=/usr/ncmp/lib/emacs/macros/draw 0644 root other f emacs $EMACS/mail=/usr/ncmp/lib/emacs/macros/mail 0644 root other f emacs $NCMPMAN/man1/emacs.1=/usr/ncmp/man/man1/emacs.1 0644 root other d man $NCMPMAN 0755 root other d man $NCMPMAN/man1 0755 root other f man $NCMPMAN/man1/dired.1=/usr/ncmp/man/man1/dired.1 0644 root other f man $NCMPMAN/man1/ttype.1=/usr/ncmp/man/man1/ttype.1 0644 root other f man $NCMPMAN/man1/less.1=/usr/ncmp/man/man1/less.1 0644 inixmr other |
trap 'exit 3' 15 # determine if and where general executables should be placed ans=`ckyorn -d y \ -p "Should executables included in this package be installed" ` || exit $? if [ "$ans" = y ] then CLASSES="$CLASSES bin" NCMPBIN=`ckpath -d /usr/ncmp/bin -aoy \ -p "Where should executables be installed" ` || exit $? fi # determine if emacs editor should be installed, and if it should # where should the associated macros be placed ans=`ckyorn -d y \ -p "Should emacs editor included in this package be installed" ` || exit $? if [ "$ans" = y ] then CLASSES="$CLASSES emacs" EMACS=`ckpath -d /usr/ncmp/lib/emacs -aoy \ -p "Where should emacs macros be installed" ` || exit $? fi |
request スクリプトは、ファイルシステム上にファイルを残さずに終了できます。Solaris バージョン 2.5 よりも前のバージョンおよび互換バージョンでインストールを行う場合、checkinstall スクリプトが使用されていない可能性があるので、request スクリプトを使用してファイルシステムのテストを行い、インストールの成功を確認することをお勧めします。request スクリプトがコード 1 で終了すると、インストールはクリーンに終了します。
これらのファイル例では、パラメータ型パスを使用して複数のベースディレクトリを確立する方法が示されています。しかし、pkgadd コマンドによって管理および検証される BASEDIR パラメータを使用する必要が生じる場合もあります。複数のベースディレクトリを使用する際には、同じプラットフォームに複数のバージョンやアーキテクチャーをインストールする場合に備えて、特別な注意を払う必要があります。