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