pkg_delete does pretty much what it says. It examines installed package records in
<PKG_DBDIR>/<pkg-name>, deletes the package contents, and finally removes the package records.
If a package is required by other installed packages,
pkg_delete will list those dependent packages and refuse to delete the package (unless the
-f option is given).
If a package has been marked as a
preserved package, it will not be able to be deleted (unless more than one occurrence of the
-f option is given).
If a filename is given instead of a package name, the package of which the given file belongs to can be deleted if the
-F flag is given. The filename needs to be absolute, see the output produced by the
pkg_info(1) -aF command.
If a
deinstall script exists for the package, it is executed before and after any files are removed. It is this script's responsibility to clean up any additional messy details around the package's installation, since all
pkg_delete knows how to do is delete the files created in the original distribution. The
deinstall script is called as:
deinstall <pkg-name> VIEW-DEINSTALL
before removing the package from a view, and as:
deinstall <pkg-name> DEINSTALL
before deleting all files and as:
deinstall <pkg-name> POST-DEINSTALL
after deleting them. Passing the keywords
VIEW-DEINSTALL,
DEINSTALL, and
POST-DEINSTALL lets you potentially write only one program/script that handles all aspects of installation and deletion.
All scripts are called with the environment variable
PKG_PREFIX set to the installation prefix (see the
-p option above). This allows a package author to write a script that reliably performs some action on the directory where the package is installed, even if the user might have changed it by specifying the
-p option when running
pkg_delete or
pkg_add(1). The scripts are also called with the
PKG_METADATA_DIR environment variable set to the location of the
+* meta-data files, and with the
PKG_REFCOUNT_DBDIR environment variable set to the location of the package reference counts database directory. If the
-P flag was given to
pkg_delete,
PKG_DESTDIR will be set to
destdir.