| PKG_ADD(1) | General Commands Manual | PKG_ADD(1) | 
pkg_add —
| pkg_add | [ -AfhInRUuVv] [-Cconfig] [-Kpkg_dbdir] [-mmachine] [-Pdestdir] [-pprefix] file ...
      [[ftp|http]://[user][:password]@]host[:port][/path/]pkg-name
      ... | 
pkg_add command is used to extract and upgrade
  packages that have been previously created with the
  pkg_create(1) command.
  Packages are prepared collections of pre-built binaries, documentation,
  configurations, installation instructions and/or other files.
  pkg_add can recursively install other packages that
  the current package depends on or requires from both local disk and via FTP or
  HTTP.
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 package files.
You are advised to verify the competence and identity of those who
    provide installable package files. For extra protection, use the digital
    signatures provided where possible (see the
    pkg_install.conf(5)),
    or, failing that, use tar(1) to
    extract the package file, and inspect its contents and scripts to ensure it
    poses no danger to your system's integrity. Pay particular attention to any
    +INSTALL or +DEINSTALL
    files, and inspect the +CONTENTS file for
    @cwd, @mode (check for
    setuid), @dirrm, @exec, and
    @unexec directives, and/or use the
    pkg_info(1) command to
    examine the package file.
pkg_add will
      first try to use pkg-name as full URL or path name
      without any wildcard processing. If that fails,
      pkg_add will try to match packages using wildcard
      processing. If that fails as well and pkg-name does
      not contain any /, the entries of the PKG_PATH
      variable are searched using the wildcard processing rules.-Apkg_admin set
      automatic=YESpkg_admin unset
      automaticpkg_add a package without
      specifying -A after it had already been
      automatically installed, the mark is removed.-C
    config-D-fpkg_add will still try to find and auto-install
      missing prerequisite packages, a failure to find one will not be fatal.
      This flag also overrides the fatal error when the operating system or
      architecture the package was built on differ from that of the host.-h-I-K
    pkg_dbdirPKG_DBDIR configuration
      option with the value pkg_dbdir.-m-n-P
    destdir-p
    prefix-R-I. This means that you cannot deinstall it later,
      so only use this option if you know what you are doing!-U-u.-u-V-vOne or more pkg-name arguments may be
    specified, each being either a file containing the package (these usually
    ending with the “.tgz” suffix) or a URL pointing at a file
    available on an ftp or web site. Thus you may extract files directly from
    their anonymous ftp or WWW locations (e.g., pkg_add
    http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/x86_64/9.0/All/bash-5.0.18.tgz
    or pkg_add
    http://www.example.org/packages/screen-4.0.tbz). Note: For ftp transfers, if
    you wish to use
pkg_add consistently fails to fetch a
  package from a site known to work, it may be because you have a firewall that
  demands the usage of
pkg_add extracts each package's meta data (including the
  “packing list”) to memory and then runs through the following
  sequence to fully extract the contents of the package:
-u or -U options are not
      given.
    If the same version is installed and
        -U is not given, it is marked as manually
        installed and process stops. If the -u option is
        given, it's assumed the package should be replaced by the new version
        instead. Before doing so, all packages that depend on the pkg being
        upgraded are checked if they also work with the new version. If that
        test is not successful, the dependent packages are updated first. The
        replacing is then prepared by moving an existing
        +REQUIRED_BY file aside (if it exists), and
        running pkg_delete(1)
        on the installed package. Installation then proceeds as if the package
        was not installed, and restores the +REQUIRED_BY
        file afterwards.
-f flag.USE_ABI_DEPENDS=NO (or
      IGNORE_RECOMMENDED). If the package was built with
      ABI dependency recommendations ignored, a warning will be issued.@pkgcfl directives, see
      pkg_create(1)) with an
      already recorded as installed package or if an installed package conflicts
      with the package. If it is, installation is terminated.@pkgdep directives,
      see pkg_create(1)) are
      read from the packing list. If any of these required packages are not
      currently installed, an attempt is made to find and install it; if the
      missing package cannot be found or installed, the installation is
      terminated.PRE-INSTALLIf the install script exits with a non-zero status code, the installation is terminated.
POST-INSTALLThe install script is called with the
    environment variable PKG_PREFIX set to the
    installation prefix (see the -p option above). This
    allows a package author to write a script that reliably performs some action
    on the directory where the package is installed, even if the user might
    change it with the -p flag to
    pkg_add. The scripts are also called with the
    PKG_METADATA_DIR environment variable set to the
    location of the +* meta-data files, and with the
    PKG_REFCOUNT_DBDIR environment variable set to the
    location of the package reference counts database directory. If the
    -P flag was given to
    pkg_add, PKG_DESTDIR will be
    set to destdir. Additionally,
    PKG_METADATA_DIR and
    PKG_REFCOUNT_DBDIR are prefixed with
    destdir.
pkg_add will try to install binary
  packages listed in dependencies list.
You can grab a compiled binary package from remote location by specifying a URL:
# pkg_add http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/x86_64/9.0/All/firefox-84.0.tgz
The base URL can also be provided by the configuration variable,
    PKG_PATH:
# export PKG_PATH=http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/x86_64/9.0/All # pkg_add firefox
You can also specify a compiled binary package by filesystem path:
# pkg_add /usr/pkgsrc/packages/All/tcsh-6.14.00.tgz
If you omit the version number, pkg_add
    will install the latest version available. With -v,
    pkg_add emits more messages to terminal:
# pkg_add -v /usr/pkgsrc/packages/All/unzip
Sure to be others.
| March 8, 2021 | NetBSD 10.1 |