The Ur Project

Documenting the craft of stacking things so they remain stacked. For a very long time.

pkg-query(1)

NAME

pkg-query - print details of an installed package

SYNOPSIS

pkg query [options] name

pkg show [options] name

DESCRIPTION

Tells you what this machine has: which subpackages of a name are installed, at which build, and, if you ask, the files and capabilities that came with them.

It reads the installed manifest out of the local state database, and never touches a repository. So it answers "what's on this machine", not "what's on offer". For that one, use pkg-info(1).

name can be a bare name, which prints every installed subpackage of it, or name/subpkg, which prints just that one. Nothing is filtered out: if a debug subpackage is installed, you'll see it. Hiding it would be lying. A name that isn't installed is an error.

With no flags you get one header line per subpackage. Each flag adds a section under it.

OPTIONS

--files
List the files the package ships, one per line, with type and mode.
--provides
List the package's provides capabilities.
--requires
List the package's requires capabilities.
--conflicts
List the package's conflicts capabilities.

All global options apply; see pkg(1).

OUTPUT

gzip/bin 1.13-4 x86_64 requires soname:libc.so.6 provides file:/usr/bin/gzip f 0755 /usr/bin/gzip l 0777 /usr/bin/gunzip -> gzip d 0755 /usr/share/doc/gzip

File lines are type mode path. The type is f (regular file), l (symlink) or d (directory). The mode is four-digit octal. A symlink always says 0777, because that's its fixed permission on disk anyway, and it ends with -> target.

A multi-installable package, like a kernel, gets its discriminator on the end:

linux-kernel-stable/mod 6.12.4-1 x86_64 (variant 6.12.4-1)

JSON

{ "ok": true, "hits": [ { "name":..., "subpkg":..., "variant":..., "version":..., "release":..., "arch":..., "provides": [...], "requires": [...], "conflicts": [...], "files": [...] } ] }

The provides, requires, conflicts and files keys are only there when you passed the matching flag. Capabilities are strings. A file entry is one of:

{ "type": "file", "path":..., "mode": "0755", "size":..., "sha256":... } { "type": "symlink", "path":..., "target":... } { "type": "dir", "path":..., "mode": "0755" }

EXAMPLES

What's installed under this name?

pkg query gzip

Everything about one subpackage

pkg query gzip/bin --files --provides --requires --conflicts

Which files does this package own?

pkg query coreutils --files pkg query coreutils --files | grep '^ f'

Just the paths

pkg --json query coreutils --files | jq -r '.hits[].files[].path'

Executables only

pkg query coreutils --files | awk '$1 == "f" && $2 ~ /7..$/ {print $3}'

pkg query gzip --files | grep ' -> '

What does this package need?

pkg query curl --requires

And who could satisfy one of those:

pkg search --provides soname:libssl.so.3

What does this package offer?

pkg query openssl/lib --provides

Before removing something, who needs it?

pkg query libfoo/lib --provides pkg search --requires soname:libfoo.so.1

Which kernel variants are installed?

pkg query linux-kernel-stable

Is the disk still what the manifest says?

query prints what should be there. pkg-verify(1) checks whether it is:

pkg query gzip --files pkg verify gzip

How much a package claims to take up

pkg --json query coreutils --files \ | jq '[.hits[].files[] | select(.type == "file") | .size] | add'

Querying a mounted image

pkg --state-root /mnt/image/var/lib/pkg query coreutils --files

EXIT STATUS

0 on success. 1 when the name isn't installed, or the installed state can't be read.

SEE ALSO

pkg(1), pkg-info(1), pkg-list(1), pkg-search(1), pkg-verify(1), pkg-repair(1), pkg-state(5), pkg-subpkgs(7)

docs/design/format.md, docs/design/dependency-kinds.md