1.\" Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd December 31, 2020 28.Dt PKG 7 29.Os 30.Sh NAME 31.Nm pkg 32.Nd a utility for manipulating packages 33.Sh SYNOPSIS 34.Nm 35.Ao Ar command Ac 36.Nm 37add 38.Op Fl f 39.Op Fl y 40.Ao Pa pkg.txz Ac 41.Nm 42.Fl N 43.Nm 44.Op Fl 4 | Fl 6 45bootstrap 46.Op Fl f 47.Op Fl y 48.Sh DESCRIPTION 49.Nm 50is the package management tool. 51It is used to manage local packages installed from 52.Xr ports 7 53and install/upgrade packages from remote repositories. 54.Pp 55To avoid backwards incompatibility issues, the actual 56.Xr pkg 8 57tool is not installed in the base system. 58The first time invoked, 59.Nm 60will bootstrap the real 61.Xr pkg 8 62from a remote repository. 63.Bl -tag -width "pkg bootstrap" 64.It Nm Ao Ar command Ac 65If 66.Xr pkg 8 67is not installed yet, it will be fetched, have its signature verified, 68installed, and then have the original command forwarded to it. 69If already installed, the command requested will be forwarded to the real 70.Xr pkg 8 . 71.It Nm Li add Oo Fl f Oc Oo Fl y Oc Ao Pa pkg.txz Ac 72Install 73.Xr pkg 8 74from a local package instead of fetching from remote. 75If signature checking is enabled, then the correct signature file 76must exist and the signature valid before the package will be installed. 77If the 78.Fl f 79flag is specified, then 80.Xr pkg 8 81will be installed regardless if it is already installed. 82If the 83.Fl y 84flag is specified, no confirmation will be asked when bootstrapping 85.Xr pkg 8 . 86.It Nm Fl N 87Do not bootstrap, just determine if 88.Xr pkg 8 89is actually installed or not. 90Returns 0 and the number of packages installed 91if it is, otherwise 1. 92.It Nm Oo Fl 4 | Fl 6 Oc Li bootstrap Oo Fl f Oc Oo Fl y Oc 93Attempt to bootstrap and do not forward anything to 94.Xr pkg 8 95after it is installed. 96With 97.Fl 4 98and 99.Fl 6 , 100.Nm 101will force IPv4 or IPv6 respectively to fetch 102.Xr pkg 8 103and its signatures as needed. 104If the 105.Fl f 106flag is specified, then 107.Xr pkg 8 108will be fetched and installed regardless if it is already installed. 109If the 110.Fl y 111flag is specified, no confirmation will be asked when bootstrapping 112.Xr pkg 8 . 113.El 114.Sh CONFIGURATION 115Configuration varies in whether it is in a repository configuration file 116or the global configuration file. 117.Pp 118Repository configuration can be stored in 119.Pa /etc/pkg/FreeBSD.conf 120in the following format: 121.Bd -literal -offset indent 122FreeBSD: { 123 url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", 124 mirror_type: "srv", 125 signature_type: "none", 126 fingerprints: "/usr/share/keys/pkg", 127 enabled: yes 128} 129.Ed 130.Bl -tag -width signature_type -compact 131.It url 132Refer to 133.Dv PACKAGESITE 134in 135.Sx ENVIRONMENT 136.It mirror_type 137Refer to 138.Dv MIRROR_TYPE 139in 140.Sx ENVIRONMENT 141.It signature_type 142Refer to 143.Dv SIGNATURE_TYPE 144in 145.Sx ENVIRONMENT 146.It fingerprints 147Refer to 148.Dv FINGERPRINTS 149in 150.Sx ENVIRONMENT 151.It enabled 152Defines whether this repository should be used or not. 153Valid values are 154.Dv yes , 155.Dv true , 156.Dv 1 , 157.Dv no , 158.Dv false , 159.Dv 0 . 160.El 161.Pp 162Global configuration can be stored in 163.Pa /usr/local/etc/pkg.conf 164in the following format: 165.Bd -literal -offset indent 166PACKAGESITE: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", 167MIRROR_TYPE: "srv", 168SIGNATURE_TYPE: "none", 169FINGERPRINTS: "/usr/share/keys/pkg", 170ASSUME_ALWAYS_YES: "yes" 171REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"] 172.Ed 173.Pp 174Reference 175.Sx ENVIRONMENT 176for each variable. 177.Sh ENVIRONMENT 178The following environment variables can be set to override the settings 179from the 180.Pa pkg.conf 181file used. 182.Bl -tag -width "ASSUME_ALWAYS_YES" 183.It Ev MIRROR_TYPE 184This defines which mirror type should be used. 185Valid values are 186.Dv SRV , 187.Dv HTTP , 188.Dv NONE . 189.It Ev ABI 190This defines the ABI for the package to be installed. 191Default ABI is determined from 192.Pa /bin/sh . 193.It Ev ASSUME_ALWAYS_YES 194If set, no confirmation will be asked when bootstrapping 195.Xr pkg 8 . 196.It Ev SIGNATURE_TYPE 197If set to 198.Dv FINGERPRINTS 199then a signature will be required and validated against known 200certificate fingerprints when bootstrapping 201.Xr pkg 8 . 202.It Ev FINGERPRINTS 203If 204.Sy SIGNATURE_TYPE 205is set to 206.Dv FINGERPRINTS 207this value should be set to the directory path where known fingerprints are 208located. 209.It Ev PACKAGESITE 210The URL that 211.Xr pkg 8 212and other packages 213will be fetched from. 214.It Ev REPOS_DIR 215Comma-separated list of directories that should be searched for repository 216configuration files. 217.El 218.Sh FILES 219Configuration is read from the files in the listed order. 220This path can be changed by setting 221.Sy REPOS_DIR . 222The last enabled repository is the one used for bootstrapping 223.Xr pkg 8 . 224.Bl -tag -width "/usr/local/etc/pkg/repos/*.conf" 225.It Pa /usr/local/etc/pkg.conf 226.It Pa /etc/pkg/FreeBSD.conf 227.It Pa /usr/local/etc/pkg/repos/*.conf 228.El 229.Sh EXAMPLES 230Some examples are listed here. 231The full list of available commands are available in 232.Xr pkg 8 233once it is bootstrapped. 234.Pp 235Search for a package: 236.Dl $ pkg search perl 237.Pp 238Install a package: 239.Dl % pkg install perl 240.Pp 241List installed packages: 242.Dl $ pkg info 243.Pp 244Upgrade from remote repository: 245.Dl % pkg upgrade 246.Pp 247List non-automatic packages: 248.Dl $ pkg query -e '%a = 0' %o 249.Pp 250List automatic packages: 251.Dl $ pkg query -e '%a = 1' %o 252.Pp 253Delete an installed package: 254.Dl % pkg delete perl 255.Pp 256Remove unneeded dependencies: 257.Dl % pkg autoremove 258.Pp 259Change a package from automatic to non-automatic, which will prevent 260.Ic autoremove 261from removing it: 262.Dl % pkg set -A 0 perl 263.Pp 264Change a package from non-automatic to automatic, which will make 265.Ic autoremove 266allow it be removed once nothing depends on it: 267.Dl % pkg set -A 1 perl 268.Pp 269Create package file from an installed package: 270.Dl % pkg create -o /usr/ports/packages/All perl 271.Pp 272Determine which package installed a file: 273.Dl $ pkg which /usr/local/bin/perl 274.Pp 275Audit installed packages for security advisories: 276.Dl $ pkg audit 277.Pp 278Check installed packages for checksum mismatches: 279.Dl # pkg check -s -a 280.Pp 281Check for missing dependencies: 282.Dl # pkg check -d -a 283.Sh SEE ALSO 284.Xr ports 7 , 285.Xr pkg 8 286.Sh HISTORY 287The 288.Nm 289command first appeared in 290.Fx 9.1 . 291It became the default package tool in 292.Fx 10.0 , 293replacing the 294pkg_install suite of tools 295.Xr pkg_add 1 , 296.Xr pkg_info 1 and 297.Xr pkg_create 1 . 298