OpenBSD pkg tools

ID

pkg-tools

Home page

https://man.openbsd.org/pkg_add

Platforms

🅱️ BSD (OpenBSD only)

Operations

installed · orphans · search · install · upgrade · upgrade_all · remove · cleanup

purl types

pkg:pkg-tools

CLI name

pkg_info

Extra search paths

/usr/sbin

Issues and PRs

📦 manager: pkg-tools

Source

meta_package_manager/managers/pkg_tools.toml

OpenBSD’s pkg tools are the base system’s package suite, spanning three binaries: pkg_info (queries), pkg_add (install/upgrade) and pkg_delete (remove/cleanup).

Parsing notes, verified against the pkg_add/pkg_info/pkg_delete man pages (man.openbsd.org), the OpenBSD FAQ 15, and the OpenBSD::PkgInfo/Update Perl source:

  • None of the three binaries has a version flag (-V and -v mean progress/verbose): the suite ships with the base system and is versioned with the OS, so the version probe runs uname -r instead (like “7.7”).

  • Package names fuse “stem-version” with OpenBSD’s pN patch suffix and optional flavor tails (unzip-6.0p17, unzip-6.0p17-iconv): the version capture starts at the last dash before a digit and absorbs any flavor tail.

  • Packages are located through /etc/installurl, configured by default on modern OpenBSD: there is no local index to refresh, hence no sync operation. Outdated is omitted too: pkg_add -u -n -v interleaves progress meters and can list several candidates per package, which defeats per-line parsing.

  • -I forces non-interactive mode on every mutating call (the default is interactive on a terminal). Mutations need root: OpenBSD’s base convention is doas, but mpm’s escalation runs through sudo (available as a package).

What mpm adds to pkg-tools

Through mpm, pkg-tools gains --exact and --extended search, to narrow to exact names or match descriptions.

Bigger still, mpm reaches across every manager at once: mpm installed and mpm outdated cover pkg-tools alongside every other manager you run in one table, mpm upgrade --all updates them together, and mpm sbom exports the whole machine as one bill of materials.

Every mpm command also gains --dry-run and --plan previews, cross-scheme version comparison and purl identifiers. See manager augmentations for how each one is built.

Your pkg-tools commands, in mpm

You already know pkg-tools: each operation maps one-to-one onto mpm, in an interface shared by every manager.

To…

With pkg-tools

With mpm

List what’s installed

pkg_info -I -a

mpm --pkg-tools installed

Search for a package

pkg_info -Q <query>

mpm --pkg-tools search <query>

Install a package

pkg_add -I <package_id>

mpm install pkg:pkg-tools/<package_id>

Upgrade one package

pkg_add -u -I <package_id>

mpm --pkg-tools upgrade <package_id>

Upgrade everything

pkg_add -u -I

mpm --pkg-tools upgrade --all

Remove a package

pkg_delete -I <package_id>

mpm remove pkg:pkg-tools/<package_id>

List orphaned dependencies

pkg_delete -a -I -n

mpm --pkg-tools orphans

Prefix any command above with --dry-run to simulate the underlying manager calls without touching the system: the safe way to watch what mpm would do before trusting it.

Operations

Operation

Supported

Notes

installed

outdated

orphans

search

exact and extended search backfilled by mpm

install

upgrade

upgrade_all

remove

sync

cleanup

--orphans runs the system-wide orphan sweep

doctor

Selecting and configuring pkg-tools

Deselect pkg-tools for a single run with --no-pkg-tools, or persist the choice in your configuration:

[mpm]
pkg-tools = false

Keep it enabled but tune how mpm drives it with a per-manager override:

[mpm.managers.pkg-tools]
timeout = 900

mpm config-template pkg-tools prints every overridable attribute as a ready-to-paste block.

Recipes

A few jobs you would otherwise script around pkg-tools, one mpm command each:

  • Snapshot and clone a machine: mpm --pkg-tools dump pkg-tools.toml, then mpm restore pkg-tools.toml on the next one.

  • Export a compliance SBOM: mpm --pkg-tools sbom (CycloneDX by default, --spdx for SPDX).

Privilege escalation

System-wide manager: mpm wraps its privileged operations in sudo out of the box. Instead of letting the tool prompt mid-run, mpm primes the credential cache up-front, with a single branded password prompt at most. Turn escalation off for rootless setups with --no-sudo or the per-manager sudo override.

Root is required for its cleanup_orphan, install, remove, upgrade, upgrade_all operations.

See privilege escalation for the full policy.

Cooldown

State of OpenBSD pkg tools’s release-age gating, from the cooldown support table:

Status: ❌ None (OpenBSD, per-release curated)

A cooldown only pays off where a compromised release can be withdrawn while the clock runs, and can only be emulated where the registry dates its releases. From the retraction table:

  • Registry: Distro binary archives (pkg:deb, pkg:rpm, pkg:alpm, pkg:apk)

  • Retraction: Index revert: removal is an archive operation and the mirror is rebuilt without the package. Debian, for one, requires filing an RM: bug against ftp.debian.org (developers-reference)

  • Publish date: ❌ the version string is the distro maintainer’s build, carrying no upstream publication date

With --cooldown set, mpm skips this manager’s install and upgrade operations rather than run them unguarded (fail-closed); --allow-unsupported-managers opts back in.

Version probe

The version is probed by running:

$ uname -r
7.7

and extracted with:

r"^(?P<version>[\d.]+)"

Reference traces

Raw native outputs captured in the bundled definition: the reference mpm’s parsers were written against. If you know OpenBSD pkg tools well and a transcript below looks wrong, or a newer release changed its output format, report it.

$ pkg_info -I -a
unzip-6.0p17        Extract files from ZIP archives
lunzip-1.14p0       Lzip decompressor
$ pkg_delete -a -I -n
autoconf-2.71p2: ok
automake-1.16.5: ok
$ pkg_info -Q {query}
lunzip-1.14p0
unzip-6.0p17 (installed)
unzip-6.0p17-iconv

Feed any of these through mpm and the raw output becomes one uniform table, the same shape for every manager: filter it, project columns, or export it (mpm --pkg-tools installed --output json, or csv, toml, yaml), each package carrying a purl and a version comparable across managers.

Changelog

  • 7.4.0 (2026-07-25)

    • Their cleanup commands, both orphan sweeps (cave purge, pkg_delete -a), are re-declared as cleanup_orphan: cleanup --orphans now reaches them and cleanup --cache leaves them alone.

    • Plain cleanup no longer removes orphaned packages: their native sweeps moved behind cleanup --orphans. This also stops emerge’s cleanup from triggering its pre-depclean world upgrade unless --orphans is given.

  • 7.2.0 (2026-07-09)

    • Add OpenBSD’s pkg tools (pkg_add/pkg_info/pkg_delete) with installed, search, install, upgrade, remove and cleanup support; a bundled configuration-defined manager.