wpkg --add-hooks

Options Comments
--admindir Define the administration directory, where the database of the installed packages resides.
--quiet Request for warning messages to not be displayed.
--root Define the installation root path.
--verbose Display log information of level INFO.

The --add-hooks command lets you add one or more global hooks to a target. The command expect a list of filenames: the actual hooks.

The name of a hook must be a unique name followed by the name of the hook function:

<unique name>_<function>[.sh|.bat]

The name can be preceeded by a path if not in the current working directory.

<unique name> is often the name of the package dynamically attaching a hook to the environment, however, packages are expected to manage their hooks from within their package environment. Any name, as long as it can be made unique, will do though.

<function> is one of the following:

  • validate -- used for validation
  • preinst -- run before the package preinst script
  • postinst -- run after the package postinst script
  • prerm -- run before the package prerm script
  • postrm -- run after the package postrm script

These files are saved in the database installation directory (see --admindir) under the core special package in the hooks directory with the added prefix "core_". For instance, let's say you have a tool adding the script named: foo_postrm.sh to your installation system. It will be saved under the installation directory as (assuming the default for the installation directory):


To remove a hook, use wpkg --remove-hooks with the name of the hook you want to remove without any path. In our example, the name would be foo_postrm.sh:

wpkg --remove-hooks foo_postrm.sh

Note that packages can also add such hooks along their control file, in that case they  automatically get installed by wpkg when unpacking that package and removed when a package files get deleted. This is the best way to manage hooks because trying to run wpkg from a script (i.e. preinst or postinst) fails since the database is still locked at that point. Note that hooks found in a package WPKG directory must use the following naming convention:

<package name>_<function>[.sh|.bat]

The installation of package hooks does not include the "core_" prefix.

To see the list of currently installed hooks, use the --list-hooks command.

Syndicate content