pkg module manages packages on BSD systems (FreeBSD, OpenBSD, NetBSD) using either pkg or pkg_* commands.
BSD package names are case-sensitive.
Functions
packages
Install, remove, or update BSD packages.str | list[str]
List of packages to ensure.
bool
default:true
Whether the packages should be installed.
str
The PKG_PATH environment variable to set for package installation.
This operation will use
pkg ... where available (FreeBSD) and the pkg_* variants elsewhere (OpenBSD, NetBSD).pkg_path Configuration
By default,pkg_path is autogenerated as follows (tested/working for OpenBSD):
NetBSD and FreeBSD use their own directory structures, so the default won’t work. You’ll need to specify
pkg_path manually.Example
Common Use Cases
FreeBSD Package Installation
OpenBSD Package Installation
OpenBSD with Custom PKG_PATH
NetBSD Package Installation
Development Environment
Web Server Stack
BSD-Specific Tips
Package Flavors (OpenBSD)
Package Flavors (OpenBSD)
OpenBSD packages can have different flavors (build options):
Finding the Right PKG_PATH
Finding the Right PKG_PATH
To find the correct PKG_PATH for your system:OpenBSD:NetBSD:FreeBSD:
Checking Package Info
Checking Package Info
Get information about installed packages:
Updating Package Database
Updating Package Database
Update package repositories:
Searching for Packages
Searching for Packages
Search for available packages:
Platform Detection
Thepkg operation automatically detects the platform and uses the appropriate command:
Important Notes
OpenBSD does not have a
latest flag equivalent - packages are always installed at the version available in the repository for your OS version.