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.
I ganci di bottiglia possono essere creati a tre livelli:
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.
User hooks are the same as system-wide hooks but apply only to one specific
user's bottles. They are run after all the system-wide hooks have been
run. They are located in the ~/Library/Application Support/CrossOver/scripts.d
directory.
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.
Each hook is an executable file, usually a shell script, and must be placed
in one of the above hook directories. The name of the hook must be of the
form nn.name
, where nn
are two
decimal digits that dictate the order in which the hooks are run, and
name
must not contain any dot or tilde usually
indicates the hook's purpose.
I ganci vengono quindi chiamati come descritto nei seguenti eventi:
Quando si crea una bottiglia
gancio
create modello
The template
parameter indicates the name of the
template the bottle is based on, for instance
'win98
'.
Quando viene ripristinata una bottiglia
gancio
restore
When a bottle is upgraded to a new CrossOver version
gancio
upgrade-from
vecchia-versione-bottiglia
Dove vecchia-versione-bottiglia
è la versione di
CrossOver con cui è stata usata la bottiglia l'ultima volta. Ciò può aiutarvi
a stabilire quanto sia datata la bottiglia, ma notate che i ganci vengono
chiamati solo dopo che CrossOver ha aggiornato la bottiglia.
Quando si è creato un frammento di bottiglia
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
.
Quando un frammento di bottiglia viene aggiornato
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.
In all cases the hooks are called in the Wine context. This means they don't need to use the '--bottle' option and that they can count on the following environment variables being set:
CX_ROOT
Contiene il percorso assoluto alla directory in cui CrossOver è installato.
CX_BOTTLE
Contiene il nome della bottiglia corrente.
WINEPREFIX
Contiene il percorso assoluto alla directory della bottiglia.
Bottle hooks can also use the wine script to call WineLib or Windows applications to modify registry settings or other aspects of the bottle.
Ecco un esempio di gancio di bottiglia che modifica l'assegnazione della
lettera al drive in modo che non ci sia drive Y:
e che
il drive H:
punti alla directory $HOME
dell'utente.
#!/bin/sh rm "$WINEPREFIX/dosdevices/y:" if [ ! -d "$WINEPREFIX/dosdevices/h:" ] then ln -s -f "$HOME" "$WINEPREFIX/dosdevices/h:" fi