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