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 February 7, 2021 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 r Ar reponame 40.Op Fl y 41.Ao Pa pkg.txz Ac 42.Nm 43.Fl N 44.Nm 45.Op Fl 4 | Fl 6 46bootstrap 47.Op Fl f 48.Op Fl r Ar reponame 49.Op Fl y 50.Sh DESCRIPTION 51.Nm 52is the package management tool. 53It is used to manage local packages installed from 54.Xr ports 7 55and install/upgrade packages from remote repositories. 56.Pp 57To avoid backwards incompatibility issues, the actual 58.Xr pkg 8 59tool is not installed in the base system. 60The first time invoked, 61.Nm 62will bootstrap the real 63.Xr pkg 8 64from a remote repository. 65.Bl -tag -width "pkg bootstrap" 66.It Nm Ao Ar command Ac 67If 68.Xr pkg 8 69is not installed yet, it will be fetched, have its signature verified, 70installed, and then have the original command forwarded to it. 71If already installed, the command requested will be forwarded to the real 72.Xr pkg 8 . 73.It Nm Li add Oo Fl f Oc Oo Fl r Ar reponame Oc Oo Fl y Oc Ao Pa pkg.txz Ac 74Install 75.Xr pkg 8 76from a local package instead of fetching from remote. 77If signature checking is enabled, then the correct signature file 78must exist and the signature valid before the package will be installed. 79If the 80.Fl f 81flag is specified, then 82.Xr pkg 8 83will be installed regardless if it is already installed. 84If the 85.Fl y 86flag is specified, no confirmation will be asked when bootstrapping 87.Xr pkg 8 . 88.Pp 89If a 90.Ar reponame 91has been specified, then the signature configuration for that repository will be 92used. 93.It Nm Fl N 94Do not bootstrap, just determine if 95.Xr pkg 8 96is actually installed or not. 97Returns 0 and the number of packages installed 98if it is, otherwise 1. 99.It Nm Oo Fl 4 | Fl 6 Oc Li bootstrap Oo Fl f Oc \ 100Oo Fl r Ar reponame Oc Oo Fl y Oc 101Attempt to bootstrap and do not forward anything to 102.Xr pkg 8 103after it is installed. 104With 105.Fl 4 106and 107.Fl 6 , 108.Nm 109will force IPv4 or IPv6 respectively to fetch 110.Xr pkg 8 111and its signatures as needed. 112If the 113.Fl f 114flag is specified, then 115.Xr pkg 8 116will be fetched and installed regardless if it is already installed. 117If the 118.Fl y 119flag is specified, no confirmation will be asked when bootstrapping 120.Xr pkg 8 . 121.Pp 122If a 123.Ar reponame 124has been specified, then the configuration for that repository will be used. 125.El 126.Sh CONFIGURATION 127Configuration varies in whether it is in a repository configuration file 128or the global configuration file. 129The default repository configuration for 130.Fx 131is stored in 132.Pa /etc/pkg/FreeBSD.conf , 133and additional repository configuration files will be searched for in 134.Ev REPOS_DIR , 135or 136.Pa /usr/local/etc/pkg/repos 137if it is unset. 138.Pp 139For bootstrapping, 140.Nm 141will process all repositories that it finds and use the last enabled repository 142by default. 143.Pp 144Repository configuration is stored in the following format: 145.Bd -literal -offset indent 146FreeBSD: { 147 url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", 148 mirror_type: "srv", 149 signature_type: "none", 150 fingerprints: "/usr/share/keys/pkg", 151 enabled: yes 152} 153.Ed 154.Pp 155.Bl -tag -width signature_type -compact 156.It url 157Refer to 158.Dv PACKAGESITE 159in 160.Sx ENVIRONMENT 161.It mirror_type 162Refer to 163.Dv MIRROR_TYPE 164in 165.Sx ENVIRONMENT 166.It signature_type 167Refer to 168.Dv SIGNATURE_TYPE 169in 170.Sx ENVIRONMENT 171.It fingerprints 172Refer to 173.Dv FINGERPRINTS 174in 175.Sx ENVIRONMENT 176.It enabled 177Defines whether this repository should be used or not. 178Valid values are 179.Dv yes , 180.Dv true , 181.Dv 1 , 182.Dv no , 183.Dv false , 184.Dv 0 . 185.El 186.Pp 187Global configuration can be stored in 188.Pa /usr/local/etc/pkg.conf 189in the following format: 190.Bd -literal -offset indent 191PACKAGESITE: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", 192MIRROR_TYPE: "srv", 193SIGNATURE_TYPE: "none", 194FINGERPRINTS: "/usr/share/keys/pkg", 195ASSUME_ALWAYS_YES: "yes" 196REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"] 197.Ed 198.Pp 199Reference 200.Sx ENVIRONMENT 201for each variable. 202.Sh ENVIRONMENT 203The following environment variables can be set to override the settings 204from the 205.Pa pkg.conf 206file used. 207.Bl -tag -width "ASSUME_ALWAYS_YES" 208.It Ev MIRROR_TYPE 209This defines which mirror type should be used. 210Valid values are 211.Dv SRV , 212.Dv HTTP , 213.Dv NONE . 214.It Ev ABI 215This defines the ABI for the package to be installed. 216Default ABI is determined from 217.Pa /bin/sh . 218.It Ev ASSUME_ALWAYS_YES 219If set, no confirmation will be asked when bootstrapping 220.Xr pkg 8 . 221.It Ev SIGNATURE_TYPE 222If set to 223.Dv FINGERPRINTS 224then a signature will be required and validated against known 225certificate fingerprints when bootstrapping 226.Xr pkg 8 . 227.It Ev FINGERPRINTS 228If 229.Sy SIGNATURE_TYPE 230is set to 231.Dv FINGERPRINTS 232this value should be set to the directory path where known fingerprints are 233located. 234.It Ev PACKAGESITE 235The URL that 236.Xr pkg 8 237and other packages 238will be fetched from. 239.It Ev REPOS_DIR 240Comma-separated list of directories that should be searched for repository 241configuration files. 242.El 243.Sh FILES 244Configuration is read from the files in the listed order. 245This path can be changed by setting 246.Sy REPOS_DIR . 247The last enabled repository is the one used for bootstrapping 248.Xr pkg 8 . 249.Bl -tag -width "/usr/local/etc/pkg/repos/*.conf" 250.It Pa /usr/local/etc/pkg.conf 251.It Pa /etc/pkg/FreeBSD.conf 252.It Pa /usr/local/etc/pkg/repos/*.conf 253.El 254.Sh EXAMPLES 255Some examples are listed here. 256The full list of available commands are available in 257.Xr pkg 8 258once it is bootstrapped. 259.Pp 260Search for a package: 261.Dl $ pkg search perl 262.Pp 263Install a package: 264.Dl % pkg install perl 265.Pp 266List installed packages: 267.Dl $ pkg info 268.Pp 269Upgrade from remote repository: 270.Dl % pkg upgrade 271.Pp 272List non-automatic packages: 273.Dl $ pkg query -e '%a = 0' %o 274.Pp 275List automatic packages: 276.Dl $ pkg query -e '%a = 1' %o 277.Pp 278Delete an installed package: 279.Dl % pkg delete perl 280.Pp 281Remove unneeded dependencies: 282.Dl % pkg autoremove 283.Pp 284Change a package from automatic to non-automatic, which will prevent 285.Ic autoremove 286from removing it: 287.Dl % pkg set -A 0 perl 288.Pp 289Change a package from non-automatic to automatic, which will make 290.Ic autoremove 291allow it be removed once nothing depends on it: 292.Dl % pkg set -A 1 perl 293.Pp 294Create package file from an installed package: 295.Dl % pkg create -o /usr/ports/packages/All perl 296.Pp 297Determine which package installed a file: 298.Dl $ pkg which /usr/local/bin/perl 299.Pp 300Audit installed packages for security advisories: 301.Dl $ pkg audit 302.Pp 303Check installed packages for checksum mismatches: 304.Dl # pkg check -s -a 305.Pp 306Check for missing dependencies: 307.Dl # pkg check -d -a 308.Sh SEE ALSO 309.Xr ports 7 , 310.Xr pkg 8 311.Sh HISTORY 312The 313.Nm 314command first appeared in 315.Fx 9.1 . 316It became the default package tool in 317.Fx 10.0 , 318replacing the 319pkg_install suite of tools 320.Xr pkg_add 1 , 321.Xr pkg_info 1 and 322.Xr pkg_create 1 . 323