]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pkg_install/add/pkg_add.1
This commit was generated by cvs2svn to compensate for changes in r159285,
[FreeBSD/FreeBSD.git] / usr.sbin / pkg_install / add / pkg_add.1
1 .\"
2 .\" FreeBSD install - a package for the installation and maintainance
3 .\" of non-core utilities.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" Jordan K. Hubbard
15 .\"
16 .\" $FreeBSD$
17 .\"
18 .Dd January 9, 2006
19 .Dt PKG_ADD 1
20 .Os
21 .Sh NAME
22 .Nm pkg_add
23 .Nd a utility for installing software package distributions
24 .Sh SYNOPSIS
25 .Nm
26 .Op Fl vInfFrRMSK
27 .Op Fl t Ar template
28 .Op Fl p Ar prefix
29 .Op Fl P Ar prefix
30 .Op Fl C Ar chrootdir
31 .Ar pkg-name Op Ar pkg-name ...
32 .Sh DESCRIPTION
33 The
34 .Nm
35 command is used to extract packages that have been previously created
36 with the
37 .Xr pkg_create 1
38 command.
39 .Sh WARNING
40 .Bf -emphasis
41 Since the
42 .Nm
43 command may execute scripts or programs contained within a package file,
44 your system may be susceptible to
45 .Dq Em trojan horses
46 or other subtle
47 attacks from miscreants who create dangerous package files.
48 .Pp
49 You are advised to verify the competence and identity of those who
50 provide installable package files.
51 For extra protection, use the
52 .Fl M
53 flag to extract the package file, and inspect its contents and scripts to
54 ensure it poses no danger to your system's integrity.
55 Pay particular
56 attention to any +INSTALL, +POST-INSTALL, +DEINSTALL, +POST-DEINSTALL,
57 +REQUIRE or +MTREE_DIRS files, and inspect the +CONTENTS file for
58 .Cm @cwd ,
59 .Cm @mode
60 (check for setuid),
61 .Cm @dirrm ,
62 .Cm @exec ,
63 and
64 .Cm @unexec
65 directives, and/or use the
66 .Xr pkg_info 1
67 command to examine the package file.
68 .Ef
69 .Sh OPTIONS
70 The following command line arguments are supported:
71 .Bl -tag -width indent
72 .It Ar pkg-name Op Ar pkg-name ...
73 The named packages are installed.
74 A package name of
75 .Fl
76 will cause
77 .Nm
78 to read from stdin.
79 If the packages are not found in the current
80 working directory,
81 .Nm
82 will search them in each directory named by
83 .Ev PKG_PATH .
84 .It Fl v
85 Turn on verbose output.
86 .It Fl K
87 Keep any downloaded package in
88 .Ev PKGDIR
89 if it is defined or in current directory by default.
90 .It Fl I
91 If any installation scripts (pre-install or post-install) exist for a given
92 package, do not execute them.
93 .It Fl n
94 Do not actually install a package, just report the steps that
95 would be taken if it was.
96 .It Fl R
97 Do not record the installation of a package.
98 This means
99 that you cannot deinstall it later, so only use this option if
100 you know what you are doing!
101 .It Fl r
102 Use the remote fetching feature.
103 This will determine the appropriate
104 objformat and release and then fetch and install the package.
105 .It Fl f
106 Force installation to proceed even if prerequisite packages are not
107 installed or the requirements script fails.
108 Although
109 .Nm
110 will still try to find and auto-install missing prerequisite packages,
111 a failure to find one will not be fatal.
112 .It Fl F
113 Already installed packages are not an error.
114 .It Fl p Ar prefix
115 Set
116 .Ar prefix
117 as the directory in which to extract files from a package.
118 If a package has set its default directory, it will be overridden
119 by this flag.
120 Note that only the first
121 .Cm @cwd
122 directive will be replaced, since
123 .Nm
124 has no way of knowing which directory settings are relative and
125 which are absolute.
126 It is rare in any case to see more than one
127 directory transition made, but when such does happen and you wish
128 to have control over *all* directory transitions, then you
129 may then wish to look into the use of
130 .Cm MASTER
131 and
132 .Cm SLAVE
133 modes (see the
134 .Fl M
135 and
136 .Fl S
137 options).
138 If the
139 .Fl p
140 flag appears after any
141 .Fl P
142 flag on the command line, it overrides its effect, causing
143 .Nm
144 not to use the given
145 .Ar prefix
146 recursively.
147 .It Fl P Ar prefix
148 Does the same as the
149 .Fl p
150 option, except that the given
151 .Ar prefix
152 is also used recursively for the dependency packages, if any.
153 If the
154 .Fl P
155 flag appears after any
156 .Fl p
157 flag on the command line, it overrides its effect, causing
158 .Nm
159 to use the given
160 .Ar prefix
161 recursively.
162 .It Fl t Ar template
163 Use
164 .Ar template
165 as the input to
166 .Xr mktemp 3
167 when creating a
168 .Dq staging area .
169 By default, this is the string
170 .Pa /var/tmp/instmp.XXXXXX ,
171 but it may be necessary to override it in the situation where
172 space in your
173 .Pa /var/tmp
174 directory is limited.
175 Be sure to leave some number of `X' characters
176 for
177 .Xr mktemp 3
178 to fill in with a unique ID.
179 .Pp
180 You can get a performance boost by setting the staging area
181 .Ar template
182 to reside on the same disk partition as target directories for package
183 file installation; often this is
184 .Pa /usr .
185 .It Fl M
186 Run in
187 .Cm MASTER
188 mode.
189 This is a very specialized mode for running
190 .Nm
191 and is meant to be run in conjunction with
192 .Cm SLAVE
193 mode.
194 When run in this mode,
195 .Nm
196 does no work beyond extracting the package into a temporary staging
197 area (see the
198 .Fl t
199 option), reading in the packing list, and then dumping it (prefaced by
200 the current staging area) to stdout where it may be filtered by a
201 program such as
202 .Xr sed 1 .
203 When used in conjunction with
204 .Cm SLAVE
205 mode, it allows you to make radical changes to the package structure
206 before acting on its contents.
207 .It Fl S
208 Run in
209 .Cm SLAVE
210 mode.
211 This is a very specialized mode for running
212 .Nm
213 and is meant to be run in conjunction with
214 .Cm MASTER
215 mode.
216 When run in this mode,
217 .Nm
218 expects the release contents to be already extracted and waiting
219 in the staging area, the location of which is read as a string
220 from stdin.
221 The complete packing list is also read from stdin,
222 and the contents then acted on as normal.
223 .It Fl C Ar chrootdir
224 Before doing any operations,
225 .Xr chroot 2
226 to the
227 .Ar chrootdir
228 directory so that all package files, and the package database, are
229 installed to
230 .Ar chrootdir .
231 Note that
232 .Ar chrootdir
233 needs to be a fairly complete file system, including everything normally
234 needed by
235 .Nm
236 to run.
237 This flag was added to help support operations done by
238 .Xr sysinstall 8
239 and is not expected to be useful for much else.
240 Be careful that
241 .Ar chrootdir
242 is properly configured and cannot be modified by normal users,
243 versions of commands like
244 .Xr fetch 1
245 may be run inside
246 .Ar chrootdir
247 as a side effect.
248 .El
249 .Pp
250 One or more
251 .Ar pkg-name
252 arguments may be specified, each being either a file containing the
253 package (these usually end with a
254 .Dq .tbz
255 suffix) or a
256 URL pointing at a file available on an ftp site.
257 Thus you may
258 extract files directly from their anonymous ftp locations (e.g.\&
259 .Nm
260 .Li ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/shells/bash-1.14.7.tbz ) .
261 Note: If you wish to use
262 .Bf -emphasis
263 passive mode
264 .Ef
265 ftp in such transfers, set
266 the variable
267 .Bf -emphasis
268 FTP_PASSIVE_MODE
269 .Ef
270 to some value in your environment.
271 Otherwise, the more standard
272 ACTIVE mode may be used.
273 If
274 .Nm
275 consistently fails to fetch a package from a site known to work,
276 it may be because you have a firewall that demands the usage of
277 .Bf -emphasis
278 passive mode
279 .Ef
280 ftp.
281 .Sh TECHNICAL DETAILS
282 The
283 .Nm
284 utility extracts each package's "packing list" into a special staging
285 directory in /tmp (or $PKG_TMPDIR if set), parses it, and then runs
286 through the following sequence to fully extract the contents of the package:
287 .Bl -enum
288 .It
289 A check is made to determine if the package is already recorded as installed.
290 If it is, installation is terminated.
291 .It
292 A check is made to determine if the package conflicts (from
293 .Cm @conflicts
294 directives, see
295 .Xr pkg_create 1 )
296 with an already-installed package.
297 If it is, installation is terminated.
298 .It
299 Scan all the package dependencies (from
300 .Cm @pkgdep
301 directives, see
302 .Xr pkg_create 1 )
303 are read from the packing list.
304 If any of these required packages is not currently installed,
305 an attempt is made to find and install it;
306 if the missing package cannot be found or installed,
307 the installation is terminated.
308 .It
309 Search for any
310 .Cm @option
311 directives which control how the package is added to the system.
312 At the time of this writing, the only currently implemented option is
313 .Cm @option extract-in-place
314 which will cause the package to be extracted directly into its
315 prefix directory without moving through a staging area in
316 .Pa /tmp .
317 .It
318 If
319 .Cm @option extract-in-place
320 is enabled, the package is now extracted directly into its
321 final location, otherwise it is extracted into the staging area.
322 .It
323 If the package contains a
324 .Ar require
325 file (see
326 .Xr pkg_create 1 ) ,
327 then execute it with the following arguments:
328 .Bd -ragged -offset indent -compact
329 .Ar pkg-name
330 .Ar INSTALL
331 .Ed
332 where
333 .Ar pkg-name
334 is the name of the package in question and the
335 .Ar INSTALL
336 keyword denotes this as an installation requirements check (useful if
337 you want to have one script serving multiple functions).
338 .It
339 If a
340 .Ar pre-install
341 script exists for the package, it is then executed with the following
342 arguments:
343 .Bd -ragged -offset indent -compact
344 .Cm script
345 .Ar pkg-name
346 .Ar PRE-INSTALL
347 .Ed
348 .Pp
349 where
350 .Ar pkg-name
351 is the name of the package in question and
352 .Ar PRE-INSTALL
353 is a keyword denoting this as the preinstallation phase.
354 .Pp
355 .Sy Note :
356 The
357 .Ar PRE-INSTALL
358 keyword will not appear if separate scripts for pre-install and post-install
359 are given during package creation time (using the
360 .Fl i
361 and
362 .Fl I
363 flags to
364 .Xr pkg_create 1 ) .
365 .It
366 If
367 .Cm @option extract-in-place
368 is not used, then the packing list (this is the
369 .Pa +CONTENTS
370 file) is now used as a guide for moving (or copying, as necessary) files from
371 the staging area into their final locations.
372 .It
373 If the package contains an
374 .Ar mtreefile
375 file (see
376 .Xr pkg_create 1 ) ,
377 then mtree is invoked as:
378 .Bd -ragged -offset indent -compact
379 .Cm mtree
380 .Fl u
381 .Fl f
382 .Ar mtreefile
383 .Fl d
384 .Fl e
385 .Fl p
386 .Pa prefix
387 .Ed
388 where
389 .Pa prefix
390 is either the prefix specified with the
391 .Fl p
392 or
393 .Fl P
394 flag or,
395 if neither flag was specified, the name of the first directory named by a
396 .Cm @cwd
397 directive within this package.
398 .It
399 If a
400 .Ar post-install
401 script exists for the package, it is then executed as
402 .Bd -ragged -offset indent -compact
403 .Cm script
404 .Ar pkg-name
405 .Ar POST-INSTALL
406 .Ed
407 where
408 .Ar pkg-name
409 is the name of the package in question and
410 .Ar POST-INSTALL
411 is a keyword denoting this as the post-installation phase.
412 .Pp
413 .Sy Note :
414 The
415 .Ar POST-INSTALL
416 keyword will not appear if separate scripts for pre-install and post-install
417 are given during package creation time (using the
418 .Fl i
419 and
420 .Fl I
421 flags to
422 .Xr pkg_create 1 ) .
423 .Pp
424 Reasoning behind passing keywords such as
425 .Ar POST-INSTALL
426 and
427 .Ar PRE-INSTALL
428 is that this allows you to write a single
429 .Ar install
430 script that does both
431 .Dq before and after
432 actions.
433 But, separating the
434 functionality is more advantageous and easier from a maintenance viewpoint.
435 .It
436 After installation is complete, a copy of the packing list,
437 .Ar deinstall
438 script, description, and display files are copied into
439 .Pa /var/db/pkg/<pkg-name>
440 for subsequent possible use by
441 .Xr pkg_delete 1 .
442 Any package dependencies are recorded in the other packages'
443 .Pa /var/db/pkg/<other-pkg>/+REQUIRED_BY
444 file
445 (if the environment variable PKG_DBDIR is set, this overrides the
446 .Pa /var/db/pkg/
447 path shown above).
448 .It
449 Finally, the staging area is deleted and the program terminates.
450 .El
451 .Pp
452 All the scripts are called with the environment variable
453 .Ev PKG_PREFIX
454 set to the installation prefix (see the
455 .Fl p
456 and
457 .Fl P
458 options above).
459 This allows a package author to write a script
460 that reliably performs some action on the directory where the package
461 is installed, even if the user might change it with the
462 .Fl p
463 or
464 .Fl P
465 flags to
466 .Cm pkg_add .
467 .Sh ENVIRONMENT
468 The value of the
469 .Ev PKG_PATH
470 is used if a given package cannot be found.
471 The environment variable
472 should be a series of entries separated by colons.
473 Each entry
474 consists of a directory name.
475 The current directory may be indicated
476 implicitly by an empty directory name, or explicitly by a single
477 period.
478 .Pp
479 The environment variable
480 .Ev PKG_DBDIR
481 specifies an alternative location for the installed package database,
482 default location is
483 .Pa /var/db/pkg .
484 .Pp
485 The environment variables
486 .Ev PKG_TMPDIR
487 and
488 .Ev TMPDIR ,
489 in that order, are taken to name temporary directories where
490 .Nm
491 will attempt to create its staging area in.
492 If these variables are not present or if the directories named lack
493 sufficient space, then
494 .Nm
495 will use the first of
496 .Pa /var/tmp ,
497 .Pa /tmp
498 or
499 .Pa /usr/tmp
500 with sufficient space.
501 .Pp
502 The environment variable
503 .Ev PACKAGEROOT
504 specifies an alternate location for
505 .Nm
506 to fetch from.
507 The fetch URL is built using this environment variable and the automatic
508 directory logic that
509 .Nm
510 uses when the
511 .Fl r
512 option is invoked.
513 An example setting would be
514 .Qq Li ftp://ftp3.FreeBSD.org .
515 .Pp
516 The environment variable
517 .Ev PACKAGESITE
518 specifies an alternate location for
519 .Nm
520 to fetch from.
521 This variable subverts the automatic directory logic
522 that
523 .Nm
524 uses when the
525 .Fl r
526 option is invoked.
527 Thus it should be a complete URL to the remote package file(s).
528 .Pp
529 The environment variable
530 .Ev PKGDIR
531 specifies an alternative location to save downloaded packages to when
532 .Fl K
533 option is used.
534 .Sh FILES
535 .Bl -tag -width /var/db/pkg -compact
536 .It Pa /var/tmp
537 Temporary directory for creating the staging area, if environmental variables
538 .Ev PKG_TMPDIR
539 or
540 .Ev TMPDIR
541 do not point to a suitable directory.
542 .It Pa /tmp
543 Next choice if
544 .Pa /var/tmp
545 does not exist or has insufficient space.
546 .It Pa /usr/tmp
547 Last choice if
548 .Pa /var/tmp
549 and
550 .Pa /tmp
551 are not suitable for creating the staging area.
552 .It Pa /var/db/pkg
553 Default location of the installed package database.
554 .El
555 .Sh SEE ALSO
556 .Xr pkg_create 1 ,
557 .Xr pkg_delete 1 ,
558 .Xr pkg_info 1 ,
559 .Xr pkg_version 1 ,
560 .Xr mktemp 3 ,
561 .Xr sysconf 3 ,
562 .Xr mtree 8
563 .Sh AUTHORS
564 .An Jordan Hubbard
565 .Sh CONTRIBUTORS
566 .An John Kohl Aq jtk@rational.com
567 .Sh BUGS
568 Hard links between files in a distribution are only preserved if either
569 (1) the staging area is on the same file system as the target directory of
570 all the links to the file, or (2) all the links to the file are bracketed by
571 .Cm @cwd
572 directives in the contents file,
573 .Em and
574 the link names are extracted with a single
575 .Cm tar
576 command (not split between
577 invocations due to exec argument-space limitations--this depends on the
578 value returned by
579 .Fn sysconf _SC_ARG_MAX ) .
580 .Pp
581 Sure to be others.