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