]> 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 r56101,
[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 .\"
17 .\"     @(#)pkg_add.1
18 .\" $FreeBSD$
19 .\"
20 .Dd November 25, 1994
21 .Dt PKG_ADD 1
22 .Os FreeBSD
23 .Sh NAME
24 .Nm pkg_add
25 .Nd a utility for installing software package distributions
26 .Sh SYNOPSIS
27 .Nm
28 .Op Fl vInfrRMS
29 .Op Fl t Ar template
30 .Op Fl p Ar prefix
31 .Ar pkg-name [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.  For extra protection, use the
51 .Fl M
52 flag to extract the package file, and inspect its contents and scripts to
53 insure it poses no danger to your system's integrity.  Pay particular
54 attention to any +INSTALL, +POST-INSTALL, +DEINSTALL, +POST-DEINSTALL,
55 +REQUIRE or +MTREE_DIRS files, and inspect the +CONTENTS file for
56 .Cm @cwd ,
57 .Cm @mode 
58 (check for setuid),
59 .Cm @dirrm ,
60 .Cm @exec ,
61 and
62 .Cm @unexec
63 directives, and/or use the
64 .Xr pkg_info 1
65 command to examine the package file.
66 .Ef
67
68 .Sh OPTIONS
69 The following command line arguments are supported:
70 .Bl -tag -width indent
71 .It Ar pkg-name [... pkg-name]
72 The named packages are installed.  A package name of - will cause
73 .Nm
74 to read from stdin. If the packages are not found in the current
75 working directory, 
76 .Nm
77 will search them in each directory named by
78 .Ev PKG_PATH .
79 .It Fl v
80 Turn on verbose output.
81 .It Fl I
82 If a installation scripts (pre-install or post-install) exist for a given
83 package, do not execute them.
84 .It Fl n
85 Don't actually install a package, just report the steps that
86 would be taken if it was.
87 .It Fl R
88 Do not record the installation of a package.  This means
89 that you cannot deinstall it later, so only use this option if
90 you know what you are doing!
91 .It Fl r
92 Use the remote fetching feature. This will determine the appropriate
93 objformat and release and then fetch and install the package. 
94 .It Fl f
95 Force installation to proceed even if prerequisite packages are not
96 installed or the requirements script fails.  Although
97 .Nm
98 will still try to find and auto-install missing prerequisite packages,
99 a failure to find one will not be fatal.
100 .It Fl p Ar prefix
101 Set
102 .Ar prefix
103 as the directory in which to extract files from a package.
104 If a package has set its default directory, it will be overridden
105 by this flag.  Note that only the first
106 .Cm @cwd
107 directive will be replaced, since
108 .Nm
109 has no way of knowing which directory settings are relative and
110 which are absolute.  It is rare in any case to see more than one
111 directory transition made, but when such does happen and you wish
112 to have control over *all* directory transitions, then you
113 may then wish to look into the use of
114 .Cm MASTER
115 and
116 .Cm SLAVE
117 modes (see the
118 .Fl M
119 and
120 .Fl S
121 options).
122 .It Fl t Ar template
123 Use
124 .Ar template
125 as the input to 
126 .Xr mktemp 3 
127 when creating a
128 .Dq staging area .
129 By default, this is the string
130 .Pa /var/tmp/instmp.XXXXXX ,
131 but it may be necessary to override it in the situation where
132 space in your
133 .Pa /var/tmp
134 directory is limited.  Be sure to leave some number of `X' characters
135 for
136 .Xr mktemp 3
137 to fill in with a unique ID.
138 .Pp
139 You can get a performance boost by setting the staging area
140 .Ar template
141 to reside on the same disk partition as target directories for package
142 file installation; often this is
143 .Pa /usr .
144 .It Fl M
145 Run in
146 .Cm MASTER
147 mode.  This is a very specialized mode for running
148 .Nm
149 and is meant to be run in conjunction with
150 .Cm SLAVE
151 mode.  When run in this mode,
152 .Nm
153 does no work beyond extracting the package into a temporary staging
154 area (see the
155 .Fl t
156 option), reading in the packing list, and then dumping it (prefaced by
157 the current staging area) to stdout where it may be filtered by a
158 program such as
159 .Xr sed 1 .
160 When used in conjunction with
161 .Cm SLAVE
162 mode, it allows you to make radical changes to the package structure
163 before acting on its contents.
164 .It Fl S
165 Run in
166 .Cm SLAVE
167 mode.  This is a very specialized mode for running
168 .Nm
169 and is meant to be run in conjunction with
170 .Cm MASTER
171 mode.  When run in this mode,
172 .Nm
173 expects the release contents to be already extracted and waiting
174 in the staging area, the location of which is read as a string
175 from stdin.  The complete packing list is also read from stdin,
176 and the contents then acted on as normal.
177 .El
178 .Pp
179 One or more
180 .Ar pkg-name
181 arguments may be specified, each being either a file containing the
182 package (these usually ending with the
183 .Dq .tgz
184 suffix) or a
185 URL pointing at a file available on an ftp site.  Thus you may
186 extract files directly from their anonymous ftp locations (e.g.
187 .Nm
188 ftp://ftp.freebsd.org/pub/FreeBSD/packages/shells/bash-1.14.4.tgz).
189 Note:  If you wish to use
190 .Bf -emphasis
191 passive mode
192 .Ef
193 ftp in such transfers, set
194 the variable
195 .Bf -emphasis
196 FTP_PASSIVE_MODE
197 .Ef
198 to some value in your environment.  Otherwise, the more standard
199 ACTIVE mode may be used.  If
200 .Nm
201 consistently fails to fetch a package from a site known to work,
202 it may be because you have a firewall that demands the usage of
203 .Bf -emphasis
204 passive mode
205 .Ef
206 ftp.
207 .Sh TECHNICAL DETAILS
208 .Nm pkg_add
209 is fairly simple.  It extracts each package's "packing list"
210 into a special staging directory, parses it,
211 and then runs through the following sequence to fully extract the contents:
212 .Bl -enum -indent indent
213 .It
214 Check if the package is already recorded as installed.  If so,
215 terminate installation.
216 .It
217 Scan all the package dependencies (from
218 .Cm @pkgdep
219 directives, see
220 .Xr pkg_create 1 )
221 and make sure each one is met.  If not, try and find the missing
222 dependencies' packages and auto-install them; if they can't be found
223 the installation is terminated.
224 .It
225 Search for any
226 .Cm @option
227 directives which control how the package is added to the system.
228 At the time of this writing, the only currently implemented option is
229 .Cm @option extract-in-place
230 which will cause the package to be extracted directly into its
231 prefix directory without moving through a staging area in
232 .Pa /tmp .
233 .It
234 If
235 .Cm @option extract-in-place
236 is enabled, the package is now extracted directly into its
237 final location, otherwise it is extracted into the staging area.
238 .It
239 If the package contains a
240 .Ar require
241 file (see 
242 .Xr pkg_create 1 ),
243 then execute it with the following arguments:
244 .Bd -filled -offset indent -compact
245 .Ar pkg-name
246 .Ar INSTALL
247 .Ed
248 where
249 .Ar pkg-name
250 is the name of the package in question and the
251 .Ar INSTALL
252 keyword denotes this as an installation requirements check (useful if
253 you want to have one script serving multiple functions).
254 .It
255 If a
256 .Ar pre-install
257 script exists for the package, it is then executed with the following
258 arguments:
259 .Bd -filled -offset indent -compact
260 .Cm script
261 .Ar pkg-name
262 .Ar PRE-INSTALL
263 .Ed
264
265 where
266 .Ar pkg-name
267 is the name of the package in question and
268 .Ar PRE-INSTALL
269 is a keyword denoting this as the preinstallation phase.
270
271 .Cm Note:
272 The
273 .Ar PRE-INSTALL
274 keyword will not appear if separate scripts for pre-install and post-install
275 are given during package creation time (using the
276 .Cm Fl i
277 and 
278 .Cm Fl I
279 flags to 
280 .Xr pkg_create 1 ).
281 .It
282 If
283 .Cm @option extract-in-place
284 is not used, then the packing list (this is the
285 .Pa +CONTENTS
286 file) is now used as a guide for moving (or copying, as necessary) files from
287 the staging area into their final locations.
288 .It
289 If the package contains an
290 .Ar mtreefile
291 file (see
292 .Xr pkg_create 1 ),
293 then mtree is invoked as:
294 .Bd -filled -offset indent -compact
295 .Cm mtree
296 .Fl u 
297 .Fl f 
298 .Ar mtreefile
299 .Fl d
300 .Fl e 
301 .Fl p 
302 .Pa prefix 
303 .Ed
304 where
305 .Pa prefix
306 is either the prefix specified with the
307 .Fl p
308 flag or, if no 
309 .Fl p
310 flag was specified, the name of the first directory named by a
311 .Cm @cwd
312 directive within this package.
313 .It
314 If a
315 .Ar post-install
316 script exists for the package, it is then executed as 
317 .Bd -filled -offset indent -compact
318 .Cm script
319 .Ar pkg-name
320 .Ar POST-INSTALL 
321 .Ed
322 where
323 .Ar pkg-name
324 is the name of the package in question and
325 .Ar POST-INSTALL
326 is a keyword denoting this as the post-installation phase.
327
328 .Cm Note:
329 The
330 .Ar POST-INSTALL
331 keyword will not appear if separate scripts for pre-install and post-install
332 are given during package creation time (using the
333 .Cm Fl i
334 and 
335 .Cm Fl I
336 flags to 
337 .Xr pkg_create 1 ).
338
339 Reasoning behind passing keywords such as
340 .Ar POST-INSTALL
341 and
342 .Ar PRE-INSTALL
343 is that this allows you to write a single
344 .Ar install
345 script that does both
346 .Dq before and after
347 actions. But, separating the
348 functionality is more advantageous and easier from a maintainence viewpoint.
349 .It
350 After installation is complete, a copy of the packing list,
351 .Ar deinstall
352 script, description, and display files are copied into
353 .Pa /var/db/pkg/<pkg-name>
354 for subsequent possible use by
355 .Xr pkg_delete 1 .
356 Any package dependencies are recorded in the other packages' 
357 .Pa /var/db/pkg/<other-pkg>/+REQUIRED_BY
358 file
359 (if the environment variable PKG_DBDIR is set, this overrides the
360 .Pa /var/db/pkg/
361 path shown above).
362 .It
363 Finally, the staging area is deleted and the program terminates.
364 .El
365 .Pp
366 All the scripts are called with the environment variable
367 .Ev PKG_PREFIX
368 set to the installation prefix (see the
369 .Fl p
370 option above).  This allows a package author to write a script
371 that reliably performs some action on the directory where the package
372 is installed, even if the user might change it with the
373 .Fl p
374 flag to
375 .Cm pkg_add .
376 .Sh ENVIRONMENT
377 The value of the
378 .Ev PKG_PATH
379 is used if a given package can't be found.  The environment variable
380 should be a series of entries seperated by colons.  Each entry
381 consists of a directory name. The current directory may be indicated
382 implicitly by an empty directory name, or explicitly by a single
383 period.
384 .Pp
385 The environment variable
386 .Ev PKG_DBDIR
387 specifies an alternative location for the installed package database.
388 .Pp
389 The environment variables
390 .Ev PKG_TMPDIR
391 and
392 .Ev TMPDIR ,
393 in that order, are taken to name temporary directories where
394 .Nm 
395 will attempt to create its staging area in.
396 If these variables are not present or if the directories named lack
397 sufficient space, then 
398 .Nm
399 will use the first of 
400 .Pa /var/tmp ,
401 .Pa /tmp 
402 or
403 .Pa /usr/tmp
404 with sufficient space.
405 .Pp
406 The environment variable
407 .Ev PACKAGESITE
408 specifies an alternate location for 
409 .Nm
410 to fetch from. This variable subverts the automatic directory logic
411 that
412 .Nm
413 uses when the 
414 .Fl r
415 option is invoked.
416 .Sh FILES
417 .Bl -tag -width /var/db/pkg -compact
418 .It Pa /var/tmp
419 Temporary directory for creating the staging area, if environmental variables
420 .Ev PKG_TMPDIR
421 or
422 .Ev TMPDIR
423 do not point to a suitable directory.
424 .It Pa /tmp
425 Next choice if
426 .Pa /var/tmp
427 does not exist or has insufficient space.
428 .It Pa /usr/tmp
429 Last choice if 
430 .Pa /var/tmp
431 and
432 .Pa /tmp
433 are not suitable for creating the staging area.
434 .It Pa /var/db/pkg
435 Default location of the installed package database.
436 .El
437 .Sh SEE ALSO
438 .Xr pkg_create 1 ,
439 .Xr pkg_delete 1 ,
440 .Xr pkg_info 1 ,
441 .Xr mktemp 3 ,
442 .Xr sysconf 3 ,
443 .Xr mtree 8
444 .Sh AUTHORS
445 .An Jordan Hubbard
446 for initial work and ongoing development.
447 .An John Kohl
448 for NetBSD refinements.
449 .Sh BUGS
450 Hard links between files in a distribution are only preserved if either
451 (1) the staging area is on the same file system as the target directory of
452 all the links to the file, or (2) all the links to the file are bracketed by
453 .Cm @cwd
454 directives in the contents file, 
455 .Em and
456 the link names are extracted with a single
457 .Cm tar
458 command (not split between
459 invocations due to exec argument-space limitations--this depends on the
460 value returned by
461 .Fn sysconf _SC_ARG_MAX ) .
462 .Pp
463 Sure to be others.