4.4.1. Getting Started with pkg
FreeBSD includes a bootstrap utility which can be used to download and install pkg, along with its manual pages.
To bootstrap the system, run:
# /usr/sbin/pkg
For earlier FreeBSD versions, pkg must instead be installed from the Ports Collection or as a binary package.
To install the port, run:
# cd /usr/ports/ports-mgmt/pkg
# make
# make install clean
When upgrading an existing system that originally used the older package system, the database must be converted to the new format, so that the new tools are aware of the already installed packages. Once pkg has been installed, the package database must be converted from the traditional format to the new format by running this command:
# pkg2ng
Note:
This step is not required for new installations that do not yet have any third-party software installed.
Important:
This step is not reversible. Once the package database has been converted to the pkg format, the traditional pkg_* tools should no longer be used.
Note:
The package database conversion may emit errors as the contents are converted to the new version. Generally, these errors can be safely ignored. However, a list of third-party software that was not successfully converted will be listed after pkg2ng has finished and these applications must be manually reinstalled.
To ensure that the FreeBSD Ports Collection registers new software with pkg, and not the traditional packages format, FreeBSD versions earlier than 10.X require this line in /etc/make.conf:
WITH_PKGNG= yes
By default pkg uses the FreeBSD package mirrors. For information about building a custom package repository, see Section 4.6, “Building Packages with Poudriere”
Additional pkg configuration options are described in pkg.conf(5).
Usage information for pkg is available in the pkg(8) manual page or by running pkg without additional arguments.
Each pkg command argument is documented in a command-specific manual page. To read the manual page for pkg install, for example, run either of these commands:
# pkg help install
# man pkg-install
The rest of this section demonstrates common binary package management tasks which can be performed using pkg. Each demonstrated command provides many switches to customize its use. Refer to a command's help or man page for details and more examples.