| PKG(8) | System Manager's Manual | PKG(8) |
pkg — package
manager for rawnix.org
pkg |
[-bfNvy] [-r
root] command
[argument ...] |
pkg |
-h | -V |
pkg installs, upgrades and removes
packages together with their dependencies. It builds a package with
mkpkg -d in the port directory, or fetches it with
bulk(8), installs it with
addpkg(8) and removes it with
delpkg(8). For every installed
package it records whether it was installed on request or as a dependency,
so that autoremove can remove dependencies nothing
needs any more.
Options may also follow the command. The options are as follows:
-b,
--use-bulkadd,
update and sysup. A port
with a MAKEPKG.lock is never fetched: it is built
from the lock, and its build dependencies are fetched. If a fetch fails,
nothing is built in its place.-f,
--forcedel, remove a package even though installed
packages depend on it.-h,
--help-N,
--no-depsadd and update, build
or fetch and install only the named package, without resolving its
dependencies.-r
root, --root
root-V,
--version-v,
--verboseprepare, print the port's dependencies
first.-y,
--yesadd
port ...If ports named port-suffix declare a variant, the choices are listed and one is asked for; see PORTS.
del
package ...-f is not given. The other packages are still
removed. Afterwards the orphaned packages are listed.update
package ...add,
it keeps the reason the package was installed for. It stops at the first
failure.sysup-b, bulk -u runs
first. A package that fails is reported and skipped, and the others are
still updated.autoremovebuild
[port]prepare
[port]autoremove removes them once nothing needs them.
Without port, the port in the current directory is
used.bulk
port ...listisinst
packagediff[locked]. For a port with a
MAKEPKG.lock, the line is marked
[MAKEPKG.lock], and
upstream version is added
when the port's MAKEPKG has moved on.depends
portrdepends
packageorphanslock
packagepkg and
mkpkg(8) use
MAKEPKG.lock whenever it exists. Upstream
changes to the port are therefore ignored, while edits to
MAKEPKG.lock are built and installed by
add, update,
sysup and prepare.
If the package has no port, only the installed version is
pinned: it is never upgraded, and add refuses
it.
Locked packages are never removed by
del or autoremove.
unlock
packagelocked-> lock
version or, without a
MAKEPKG.lock, -> repo
version. [stale] marks a
package that is no longer installed, [no
MAKEPKG.lock] a port without the lock file.initdbpkg command run with an empty
database does this by itself.checkdbA port is a directory holding a MAKEPKG, or only a MAKEPKG.lock, in one of the port directories of pkg.conf(5). Its name is the directory's name, and the recipe's name must be the same: the package file is found by that name. A port where they differ is refused with an error. If two port directories have a port of the same name, the one listed later is used.
pkg reads the recipe that
mkpkg(8) builds:
MAKEPKG.lock if it exists, otherwise
MAKEPKG. Besides name,
version and release it uses
these arrays, described in
MAKEPKG(5):
-b.add.A package counts as built if the file
name#version-release.pkg.tar.ext
exists in the package directory MKPKG_PACKAGE_DIR of
/etc/mkpkg.conf, or in the port directory.
Installed dependencies whose version differs from their port are updated before the package that needs them. Packages without a port, such as a kernel built from /usr/src, and locked packages without a MAKEPKG.lock are used as they are.
When dependencies form a cycle, packages in it that are already installed are rebuilt against the installed versions of the others. A cycle through a package that is not installed is an error.
Commands that change the system or a database take the lock
/var/lib/pkg/pkg.lock and wait for another
pkg holding it. Queries do not.
MKPKG_PACKAGE_DIR and
MKPKG_COMPRESSION_MODE; see
mkpkg.conf(5).The pkg utility exits 0 on success,
and >0 if an error occurs. del,
sysup and autoremove fail if
any package failed.
Install with dependencies, then remove:
# pkg add firefox # pkg del firefox
Update the whole system from pre-built packages without asking:
# pkg -by sysupInstall the build dependencies of the port in the current directory:
# pkg prepareKeep rust at its current recipe:
# pkg lock rustMAKEPKG(5), mkpkg.conf(5), pkg.conf(5), addpkg(8), bulk(8), delpkg(8), infopkg(8), mkpkg(8), ports(8), revdep(8)
With -r, bulk -u
in sysup -b still compares
against the running system's package database.
| September 27, 2026 | pkg 1.4.0 |