Bottle hooks are a mechanism that lets you automatically customize the
bottles created by CrossOver. Because it relies on scripts, it is very
flexible. For instance it can modify drive letter assignments but also
registry settings, the contents of the C:
drive,
etc. This mechanism is especially useful when you want to customize a bottle
which you distribute to a range of machines, or to customize a published
bottle for each specific user.
ボトルフックで作成される3つのレベル:
System-wide hooks apply to all bottles on the system, including non-root
user bottles. Thus they are ideal to adapt the bottles to the configuration
or hardware of the machine. These hooks are located in the
$CX_ROOT/support/scripts.d
directory.
ユーザーフック -
システムワイドフックと同じですが、1ユーザーのボトルだけに適用されます。ユーザーフックはシステムワイドフックが動作した後に動作します。このボトルフックは
~/Library/Application Support/CrossOver/scripts.d
ディレクトリにあります。
Finally, each bottle can have its own set of hooks. These are especially
suited to configure a published bottle for use by each non-root user. This
is also the only kind of hook that is automatically packaged with the bottle
when it is archived, and are thus guaranteed to run when the bottle is
restored later, even if this is on another computer. These hooks are located
in the scripts.d
directory in the bottle.
それぞれのフックは所定のディレクトリに置かれるシェルスクリプトとしての実行可能ファイルです。フックの名前は
nn.name
の形式でなければいけません。nn
は2桁の十進数でフックが動作する順番を決定します。name
はドットとチルダを含まないフックの目的に沿った名前を付けなければいけません。
フックがコールされるイベントの解説:
ボトルが作成された時
フックの
テンプレート
作成
The template
parameter indicates the name of the
template the bottle is based on, for instance
'win98
'.
ボトルがリストアされた時
フック
復元
When a bottle is upgraded to a new CrossOver version
フック
の古いバージョンのボトル
がらのアップグレード
old-bottle-version
はボトルが使われていた元のCrossOverのバージョンです。
ボトルにスタブが作成された時
hook
create-stub
published-wineprefix
This case happens when a published bottle is used in a non-root account for
the first time. In this case the $WINEPREFIX
environment
variable points to the freshly created bottle stub, while
published-wineprefix
points to root's reference
copy in /Library/Application Support/CrossOver/Bottles
.
ボトルスタブがアップデートされた時
hook
update-stub
published-wineprefix
This case happens when the administrator has updated the published bottle's
reference copy in published-wineprefix
and the
user's bottle stub must not be updated to match.
全てのケースでフックはWineに関係して呼び出されます。それは以下の環境変数にセットされます:
CX_ROOT
CrossOverがインストールされるディレクトリへの絶対パス。
CX_BOTTLE
現在のボトル名。
WINEPREFIX
ボトルへの絶対パス。
Bottle hooks can also use the wine script to call WineLib or Windows applications to modify registry settings or other aspects of the bottle.
このボトルフックのサンプルはドライブレターがY:
にならないように修正しています。そしてユーザーの$HOME
ディレクトリをH:
にしています。
#!/bin/sh rm "$WINEPREFIX/dosdevices/y:" if [ ! -d "$WINEPREFIX/dosdevices/h:" ] then ln -s -f "$HOME" "$WINEPREFIX/dosdevices/h:" fi