PKG_ADD(1) | General Commands Manual | PKG_ADD(1) |
pkg_add
— install
or update software packages
pkg_add |
[-acIimnqrsUuVvxz ]
[-A arch]
[-B pkg-destdir]
[-D name[=value]]
[-L localbase]
[-l file]
[-P type] pkg-name
... |
The pkg_add
command is used to install
packages created with the
pkg_create(1) command.
Packages containing pre-compiled applications from the
/usr/ports tree can be found on the
OpenBSD FTP site or on the official
OpenBSD CD.
pkg_add
.pkg_add
can be used to install new
packages, to replace existing packages with other flavors (option
-r
) or to update packages to newer versions (option
-u
).
In a hurry, a new package can be installed using
‘pkg_add
-U
package’, which updates dependencies and then
installs the new package.
Details of packing-list internals are documented in pkg_create(1).
pkg_add
will
syslog(3) installations and
updates by default.
pkg_add
relies on the file system
information being consistent. In case of a system crash,
/var/db/pkg may become corrupted. Use
pkg_check(8) to repair
things.
If a package is digitally signed:
pkg_add
checks that its signature is valid and
that the compressed package data matches the signature.pkg_add
verifies that the signature was emitted by
a valid signing key, as stored in
/etc/signify/*-pkg.pubpkg_add
verifies that each file matches its sha256
checksum right after extraction, before doing anything with it.pkg_add
verifies that any dangerous mode or owner
is registered in the packing-list.By default, pkg_add
enforces signed
packages, except if they come from a trusted source
(TRUSTED_PKG_PATH
) or if
-D
unsigned is specified.
In normal mode, the package names given on the command lines are
names of new packages that pkg_add
should install,
without ever deinstalling existing packages.
In replacement mode, the package names given on the command lines
are names of new packages that pkg_add
should
install, possibly replacing existing installed packages.
In update mode, the package names given on the command lines are
names of installed packages, and pkg_add
should
figure out newer package names for these, then replace the old packages with
the new.
Each package name may be specified as a filename (which normally
consists of the package name itself plus the “.tgz” suffix) or
a URL referring to FTP, HTTP, HTTPS, or SCP locations. If the given package
names are not found in the current working directory,
pkg_add
will search for them in each directory
(local or remote) named by the TRUSTED_PKG_PATH
environment variable, then the PKG_PATH
environment
variable. If neither TRUSTED_PKG_PATH
nor
PKG_PATH
are defined,
pkg_add
will build its path based on the contents of
installurl(5). Specifying
‘-
’ as a package name causes
pkg_add
to read from the standard input.
pkg_add
also understands
‘stems’, that is, package names without any version
specification. For instance, with ‘pkg_add
kdelibs’, pkg_add
will
look in the current directory (or the PKG_PATH
) for
a kdelibs package.
pkg_add
may ask questions in interactive
mode, or error out otherwise. Interactive mode is the default on a tty, see
options -I/i
.
For instance ‘pkg_add
screen’ is ambiguous as it matches
screen-4.03p6 and
screen-4.03p6-shm.
To avoid ambiguities, pkg_add
supports
‘stems with flavors’, that is, a stem separated from flavors
with a double dash. For instance, the previous ambiguity could be resolved
by using ‘pkg_add
screen--’ (matches only the empty flavor) or
‘pkg_add
screen--shm’ (matches only the shm flavor).
There is also an ambiguity related to ports with multiple
branches. For instance ‘pkg_add
python’ is ambiguous, as there are several
versions of python in the ports tree. So is
‘pkg_add
postfix’. The special form
‘pkgname%branch’
can be used to restrict matches to a branch matching the
pkgpath(7).
The above ambiguities can be resolved using
‘pkg_add
postfix%stable’ and
‘pkg_add
python%3.4’,
respectively.
All paths recognize special sequences ‘%a’, ‘%m’, ‘%c’, ‘%v’, which will be expanded to ‘package architecture’, ‘OS version or snapshots’, ‘full mirror path’ and ‘OS version’ respectively.
The sequences ‘%c’ and ‘%m’ are
slightly more magical. One can force them to expand to
‘snapshots’ on a release kernel by using
-D
snap. Otherwise, on a
‘-stable’ system, they will expand ‘%c/packages’
into two directories:
<VERSION>/packages-stable and
<VERSION>/packages.
The following examples are valid:
pkg_add -v http://ftp.openbsd.org/%m/rsync-- pkg_add -v http://ftp.openbsd.org/%m/m4 pkg_add -v scp://login@host/usr/ports/packages/%a/all/tcl%8.5
If the environment variable PKG_CACHE
is
set to a directory name, every package retrieved from a distant location
will also be copied here.
Some packages may depend on other packages. When resolving
dependencies pkg_add
will first look at already
installed packages, then match dependencies with the list of packages left
to install, then ask the user's opinion in interactive mode, then install
default packages that satisfy the dependencies.
Warning:
Since the pkg_add
command may execute scripts or
programs contained within a package file, your system may be susceptible to
“trojan horses” or other subtle attacks from miscreants who
create dangerous packages. Be sure the specified package(s) are from trusted
sources.
The options are as follows:
-A
arch-a
-aa
-B
pkg-destdir-c
@extra file
-D
name[=value]pkg_add
will merge updates together to make
sure everything stays in sync.
-D
dontmerge disables
that behavior.pkg_add
will try to find new files
in old packages by comparing the stored sha256, and tie the entries
together to avoid extracting files needlessly.
-D
donttie disables that
behavior.-I
-i
pkg_add
may ask questions to the user if faced
with difficult decisions.-L
localbaseLOCALBASE
.-l
filepkg_info
-m >file
, to reproduce an installation from machine to machine.
With -z
and -l
pkg_add
will try its best to reproduce the
installation, even if the version numbers don't quite match and even if
some packages cannot be found.-m
pkg_add
to always display the progress
meter in cases it would not do so by default.-n
PKG_CACHE
if applicable.-P
type-qq
-r
pkg_add
will try to
take every precaution to make sure the replacement can proceed before
removing the old package and adding the new one, and it should also handle
shared libraries correctly. Among other things,
pkg_add
will refuse to replace packages as soon as
it needs to run scripts that might fail (use -D
update to force the replacement);
pkg_add
will also refuse to replace packages when
the dependencies don't quite match (use -D
updatedepends to force the replacement).-s
-n
, except it also skips fetching full packages
and stops at getting the information it needs.-U
-u
pkg_add
will update all installed packages. This
relies on PKG_PATH
to figure out the new package
names.-V
-V
will
turn on more statistics in the future.-v
-v
turn on more
verbose output. By default, pkg_add
is almost
completely silent, but it reacts to keyboard status requests (see
stty(1)).
-v
turns on basic messages,
-vv
adds relevant system operations,
-vvv
shows most internal computations apart from
individual file/directory additions, -vvvv
also
shows dependencies adjustments, and -vvvvv
shows
everything.-x
-z
pkg_add
should do its best
to match package names passed on the command line, even if the versions
don't match and it will proceed even if some packages can't be found.By default, when adding packages via FTP, the
ftp(1) program operates in
“passive” mode. If you wish to use active mode instead, set
the FTPMODE
environment variable to
“active”. If pkg_add
consistently
fails to fetch a package from a site known to work, it may be because the
site does not support passive mode FTP correctly. This is very rare since
pkg_add
will try active mode FTP if the server
refuses a passive mode connection.
pkg_add
differentiates between packages
specified on the command line, and packages installed automatically because
of inter-dependencies: the first kind will be tagged as ‘installed
manually’. The -a
option is used internally
by the ports(7) infrastructure
and dpb(1) to handle
dependencies.
It is also possible to tweak the ‘installed
manually’ status of a package after the fact. Running
pkg_add
on an already installed package will tag it
as ‘installed manually’, even if it was already there as a
dependency of something else, and doubling the -a
option will remove the ‘installed manually’ tag from installed
packages.
pkg_info(1) can be used to show only manually-installed packages, and pkg_delete(1) can be used to remove dependencies when they are no longer needed.
pkg_add
deals with
‘updatesets’ internally. An updateset is a collection of old
package(s) to delete, and new package(s) to install, as an atomic operation.
Under normal circumstances, an updateset contains at most one old package
and one new package, but some situations may require
pkg_add
to perform several installations/deletions
at once.
For each new package in an updateset,
pkg_add
extracts the package's “packing
information” (the packing-list, description, and
installation/deinstallation scripts) into a special staging directory in
/var/tmp (or PKG_TMPDIR
if
set) and then runs through the following sequence to fully extract the
contents of the package:
@conflict
directives; see
pkg_create(1)) with a
package already recorded as installed. In non-replacement mode, its
installation is terminated.pkg_add
verifies that the current machine
architecture agrees with the constraints.@depend
and
@wantlib
directives; see
pkg_create(1)) are read
from the packing-list. If any of these dependencies are not currently
fulfilled, an attempt is made to find a package that meets them and
install it, looking first in the current updateset, then in the list of
packages to install passed to pkg_add
; if no
adequate package can be found and installed, the installation is
terminated.pkg_add
checks for collisions with installed file
names, read-only file systems, and enough space to store files.PKG_DBDIR
is set,
this overrides the /var/db/pkg/ path shown
above).Note that it is safe to interrupt pkg_add
through SIGINT
, SIGHUP
, and
other signals, as it will safely record an interrupted install as
partial-<pkgname>[.n].
When replacing packages, the procedure is slightly different.
pkg_add
will attempt to
update those packages. If they update to the new package(s), nothing needs
to be done. If they're part of the list of updatesets to install, the
corresponding updatesets will be merged. Otherwise,
pkg_add
will add them to the current updateset,
and rerun update to find suitable update to those packages.@unexec-delete
commands are not executed.@exec-add
commands are not executed.To update packages in -u mode, pkg_add
performs the following steps.
PKG_PATH
is
considered as an update candidate.pkg_add
searches for a ‘quirks’
package first, which may contain exceptions to these rules. This special
package contains global information, such as packages that can be deleted
because they're now part of base, or stem changes.PKG_PATH
should point to
a snapshot of packages for a given version of
OpenBSD, similar to the organization on the FTP
sites.pkg_add
will ask
the user in interactive mode, and not perform the update in
non-interactive mode.pkg_add
checks the package dependencies. If
necessary, it will install or update them first. Once all dependencies are
up to date, pkg_add
will update the package.FTPMODE
FETCH_CMD
${FETCH_CMD} -o -
url
.PKG_CACHE
PKG_CHECKSUM
-D
checksum.PKG_DBDIR
PKG_DESTDIR
-B
option is specified.PKG_PATH
PKG_PATH
are searched. It should contain a series
of entries separated by colons. Each entry consists of a directory name.
URL schemes such as FTP, HTTP, HTTPS, or SCP are also appropriate. The
current directory may be indicated implicitly by an empty directory name,
or explicitly by a single period
(‘./
’). Special sequences
‘%a’, ‘%c’, ‘%m’,
‘%v’ will be expanded.PKG_TMPDIR
TRUSTED_PKG_PATH
PKG_PATH
, but it is searched
before PKG_PATH
and waves any kind of signature
checking.ftp(1), pkg_create(1), pkg_delete(1), pkg_info(1), OpenBSD::Intro(3p), bsd.port.mk(5), installurl(5), package(5), pkg_check(8)
March 26, 2017 | OpenBSD-6.1 |