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