Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / pkg_install / create / pkg_create.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_create.1
18 .\" $FreeBSD: src/usr.sbin/pkg_install/create/pkg_create.1,v 1.35.2.16 2002/12/29 16:35:43 schweikh Exp $
19 .\"
20 .\" hacked up by John Kohl for NetBSD--fixed a few bugs, extended keywords,
21 .\" added dependency tracking, etc.
22 .\"
23 .\" [jkh] Took John's changes back and made some additional extensions for
24 .\" better integration with FreeBSD's new ports collection.
25 .\"
26 .Dd April 21, 1995
27 .Dt PKG_CREATE 1
28 .Os
29 .Sh NAME
30 .Nm pkg_create
31 .Nd a utility for creating software package distributions
32 .Sh SYNOPSIS
33 .Nm
34 .Op Fl YNOhjvyz
35 .Op Fl P Ar pkgs
36 .Op Fl p Ar prefix
37 .Op Fl f Ar contents
38 .Op Fl i Ar iscript
39 .Op Fl I Ar piscript
40 .Op Fl k Ar dscript
41 .Op Fl K Ar pdscript
42 .Op Fl r Ar rscript
43 .Op Fl s Ar srcdir
44 .Op Fl t Ar template
45 .Op Fl X Ar excludefile
46 .Op Fl D Ar displayfile
47 .Op Fl m Ar mtreefile
48 .Op Fl o Ar originpath
49 .Fl c Ar comment
50 .Fl d Ar description
51 .Fl f Ar packlist
52 .Ar pkg-filename
53 .Nm
54 .Op Fl YNhvy
55 .Fl b Ar pkg-name
56 .Op Ar pkg-filename
57 .Sh DESCRIPTION
58 The
59 .Nm
60 command is used to create packages that will subsequently be fed to
61 one of the package extraction/info utilities.  The input description
62 and command line arguments for the creation of a package are not
63 really meant to be human-generated, though it is easy enough to
64 do so.  It is more expected that you will use a front-end tool for
65 the job rather than muddling through it yourself.  Nonetheless, a short
66 description of the input syntax is included in this document.
67 .Sh OPTIONS
68 The following command line options are supported:
69 .Bl -tag -width indent
70 .It Fl f Ar packinglist
71 Fetch
72 .Dq packing list
73 for package from the file
74 .Ar packinglist
75 or
76 .Cm stdin
77 if
78 .Ar packinglist
79 is a
80 .Cm -
81 (dash).
82 .It Fl c Xo
83 .Oo Fl Oc Ns Ar desc
84 .Xc
85 Fetch package
86 .Dq one line description
87 from file
88 .Ar desc
89 or, if preceded by
90 .Cm - ,
91 the argument itself.  This string should also
92 give some idea of which version of the product (if any) the package
93 represents.
94 .It Fl d Xo
95 .Oo Fl Oc Ns Ar desc
96 .Xc
97 Fetch long description for package from file
98 .Ar desc
99 or, if preceded by
100 .Cm - ,
101 the argument itself.
102 .It Fl Y
103 Assume a default answer of `Yes' for any questions asked.
104 .It Fl N
105 Assume a default answer of `No' for any questions asked.
106 .It Fl O
107 Go into a `packing list Only' mode.  This is a custom hack for the
108 .Fx
109 .Em "Ports Collection"
110 and is used to do `fake pkg_add' operations when a port is installed.
111 In such cases, it is necessary to know what the final, adjusted packing
112 list will look like.
113 .It Fl v
114 Turn on verbose output.
115 .It Fl h
116 Force tar to follow symbolic links, so that the files they point to
117 are dumped, rather than the links themselves.
118 .It Fl i Ar iscript
119 Set
120 .Ar iscript
121 to be the pre-install procedure for the package.  This can be any executable
122 program (or shell script).  It will be invoked automatically when the
123 package is later installed.
124 It will be passed the package's name as the
125 first argument.
126 .Pp
127 .Sy Note :
128 if the
129 .Fl I
130 option is not given, this script will serve as both the pre-install and the
131 post-install script for the package, differentiating between the
132 functionality by passing the keywords
133 .Ar PRE-INSTALL
134 and
135 .Ar POST-INSTALL
136 respectively, along with the package's name.
137 .It Fl I Ar piscript
138 Set
139 .Ar piscript
140 to be the post-install procedure for the package.  This can be any
141 executable program (or shell script).  It will be invoked automatically
142 when the package is later installed.
143 It will be passed the package's name as
144 the first argument.
145 .It Fl P Ar pkgs
146 Set the initial package dependency list to
147 .Ar pkgs .
148 This is assumed to be a whitespace separated list of package names
149 and is meant as a convenient shorthand for specifying multiple
150 .Cm @pkgdep
151 directives in the packing list (see
152 .Sx "PACKING LIST DETAILS"
153 section below).
154 Each argument from the
155 .Ar pkgs
156 list could be in the form
157 .Ar pkgname Ns Op : Ns Ar pkgorigin ,
158 where optional
159 .Ar pkgorigin
160 element denotes origin of each dependency from the list and it is
161 recorded into the packing list along with the
162 .Ar pkgname
163 using
164 .Cm @comment
165 directive.
166 .It Fl p Ar prefix
167 Set
168 .Ar prefix
169 as the initial directory
170 .Dq base
171 to start from in selecting files for
172 the package.
173 .It Fl k Ar dscript
174 Set
175 .Ar dscript
176 to be the de-install procedure for the package.  This can be any executable
177 program (or shell script).  It will be invoked automatically when the
178 package is later (if ever) de-installed.
179 It will be passed the package's
180 name as the first argument.
181 .Pp
182 .Sy Note :
183 if the
184 .Fl K
185 option is not given, this script will serve as both the de-install and the
186 post-deinstall script for the package, differentiating between the
187 functionality by passing the keywords
188 .Ar DEINSTALL
189 and
190 .Ar POST-DEINSTALL
191 respectively, along with the package's name.
192 .It Fl K Ar pdscript
193 Set
194 .Ar pdscript
195 to be the post-deinstall procedure for the package.  This can be any
196 executable program (or shell script).  It will be invoked automatically when
197 the package is later de-installed.
198 It will be passed the package's name as
199 the first argument.
200 .It Fl r Ar rscript
201 Set
202 .Ar rscript
203 to be the
204 .Dq requirements
205 procedure for the package.  This can be any
206 executable program (or shell script).  It will be invoked automatically
207 at installation/deinstallation time to determine whether or not
208 installation/deinstallation should proceed.
209 To differentiate between installation and deinstallation, the keywords
210 .Ar INSTALL
211 and
212 .Ar DEINSTALL
213 are passed respectively, along with the package's name.
214 .It Fl s Ar srcdir
215 .Ar srcdir
216 will override the value of
217 .Cm @cwd
218 during package creation.
219 .It Fl t Ar template
220 Use
221 .Ar template
222 as the input to
223 .Xr mktemp 3 .
224 By default, this is the string
225 .Pa /tmp/instmp.XXXXXX ,
226 but it may be necessary to override it in the situation where
227 space in your
228 .Pa /tmp
229 directory is limited.  Be sure to leave some number of `X' characters
230 for
231 .Xr mktemp 3
232 to fill in with a unique ID.
233 .It Fl X Ar excludefile
234 Pass
235 .Ar excludefile
236 as a
237 .Fl exclude-from
238 argument to
239 .Cm tar
240 when creating final package.  See
241 .Cm tar
242 man page (or run
243 .Cm tar
244 with
245 .Fl -help
246 flag) for further information on using this flag.
247 .It Fl D Ar displayfile
248 Display the file (by concatenating it to stdout)
249 after installing the package.  Useful for things like
250 legal notices on almost-free software, etc.
251 .It Fl m Ar mtreefile
252 Run
253 .Xr mtree 8
254 with input from mtreefile before the package is installed.
255 Mtree is invoked as
256 .Cm mtree
257 .Fl u
258 .Fl f
259 .Ar mtreefile
260 .Fl d
261 .Fl e
262 .Fl p
263 .Pa prefix ,
264 where
265 .Pa prefix
266 is the name of the first directory named by a
267 .Cm @cwd
268 directive.
269 .It Fl o Ar originpath
270 Record an
271 .Ar originpath ,
272 as location of the port from which package has been created in the
273 .Fx
274 .Em "Ports Collection" .
275 It should be in the form
276 .Pa MASTERCATEGORY/PORTDIR .
277 .It Fl j
278 Use
279 .Xr bzip2 1
280 utility to compress package tarball instead of
281 .Xr gzip 1 .
282 Please note that this option is a NO-OP if the format of the resulting
283 archive is explicitly specified by the recognizable suffix of
284 .Ar pkg-filename .
285 Currently
286 .Nm
287 recognizes the following suffixes:
288 .Pa .tbz , .tgz
289 and
290 .Pa .tar .
291 .It Fl y
292 Compatibility synonym for
293 .Fl j .
294 .It Fl z
295 Use
296 .Xr gzip 1
297 utility to compress package tarball.
298 .It Fl b Ar pkg-name
299 Create package file from a locally installed package named
300 .Ar pkg-name .
301 If the
302 .Ar pkg-filename
303 is not specified, then resulting archive will be created in the
304 current directory and named
305 .Ar pkg-name
306 with an appropriate extraction suffix applied.
307 .El
308 .Sh PACKING LIST DETAILS
309 The
310 .Dq packing list
311 format (see
312 .Fl f )
313 is fairly simple, being
314 nothing more than a single column of filenames to include in the
315 package.  However, since absolute pathnames are generally a bad idea
316 for a package that could be installed potentially anywhere, there is
317 another method of specifying where things are supposed to go
318 and, optionally, what ownership and mode information they should be
319 installed with.  This is done by embedding specialized command sequences
320 in the packing list.  Briefly described, these sequences are:
321 .Bl -tag -width indent -compact
322 .It Cm @cwd Ar directory
323 Set the internal directory pointer to point to
324 .Ar directory .
325 All subsequent filenames will be assumed relative to this directory.
326 Note:
327 .Cm @cd
328 is also an alias for this command.
329 .It Cm @srcdir Ar directory
330 Set the internal directory pointer for _creation only_ to
331 .Ar directory .
332 That is to say that it overrides
333 .Cm @cwd
334 for package creation but not extraction.
335 .It Cm @exec Ar command
336 Execute
337 .Ar command
338 as part of the unpacking process.  If
339 .Ar command
340 contains any of the following sequences somewhere in it, they will
341 be expanded inline.  For the following examples, assume that
342 .Cm @cwd
343 is set to
344 .Pa /usr/local
345 and the last extracted file was
346 .Pa bin/emacs .
347 .Bl -tag -width indent -compact
348 .It Cm "%F"
349 Expands to the last filename extracted (as specified), in the example case
350 .Pa bin/emacs
351 .It Cm "\&%D"
352 Expand to the current directory prefix, as set with
353 .Cm @cwd ,
354 in the example case
355 .Pa /usr/local .
356 .It Cm "\&%B"
357 Expand to the
358 .Dq basename
359 of the fully qualified filename, that
360 is the current directory prefix, plus the last filespec, minus
361 the trailing filename.  In the example case, that would be
362 .Pa /usr/local/bin .
363 .It Cm "%f"
364 Expand to the
365 filename
366 part of the fully qualified name, or
367 the converse of
368 .Cm \&%B ,
369 being in the example case,
370 .Pa emacs .
371 .El
372 .It Cm @unexec Ar command
373 Execute
374 .Ar command
375 as part of the deinstallation process.  Expansion of special
376 .Cm %
377 sequences is the same as for
378 .Cm @exec .
379 This command is not executed during the package add, as
380 .Cm @exec
381 is, but rather when the package is deleted.  This is useful
382 for deleting links and other ancillary files that were created
383 as a result of adding the package, but not directly known to
384 the package's table of contents (and hence not automatically
385 removable).  The advantage of using
386 .Cm @unexec
387 over a deinstallation script is that you can use the
388 .Dq special sequence expansion
389 to get at files regardless of where they've
390 been potentially redirected (see
391 .Fl p ) .
392 .It Cm @mode Ar mode
393 Set default permission for all subsequently extracted files to
394 .Ar mode .
395 Format is the same as that used by the
396 .Cm chmod
397 command (well, considering that it's later handed off to it, that's
398 no surprise).  Use without an arg to set back to default (extraction)
399 permissions.
400 .It Cm @option Ar option
401 Set internal package options, the only two currently supported ones
402 being
403 .Ar extract-in-place ,
404 which tells the pkg_add command not to extract the package's tarball
405 into a staging area but rather directly into the target
406 hierarchy (this is typically meant to be used only by distributions
407 or other special package types), and
408 .Ar preserve ,
409 which tells pkg_add to move any existing files out of the way,
410 preserving the previous contents (which are also resurrected on
411 pkg_delete, so caveat emptor).
412 .It Cm @owner Ar user
413 Set default ownership for all subsequently extracted files to
414 .Ar user .
415 Use without an arg to set back to default (extraction)
416 ownership.
417 .It Cm @group Ar group
418 Set default group ownership for all subsequently extracted files to
419 .Ar group .
420 Use without an arg to set back to default (extraction)
421 group ownership.
422 .It Cm @comment Ar string
423 Imbed a comment in the packing list.  Useful in
424 trying to document some particularly hairy sequence that
425 may trip someone up later.
426 .It Cm @ignore
427 Used internally to tell extraction to ignore the next file (don't
428 copy it anywhere), as it's used for some special purpose.
429 .It Cm @ignore_inst
430 Similar to
431 .Cm @ignore ,
432 but the ignoring of the next file is delayed one evaluation cycle.  This
433 makes it possible to use this directive in the
434 .Ar packinglist
435 file, so you can pack a
436 specialized datafile in with a distribution for your install script (or
437 something) yet have the installer ignore it.
438 .It Cm @name Ar name
439 Set the name of the package.  This is mandatory and is usually
440 put at the top.  This name is potentially different from the name of
441 the file it came in, and is used when keeping track of the package
442 for later deinstallation.  Note that
443 .Nm
444 will derive this field from the package name and add it automatically
445 if none is given.
446 .It Cm @dirrm Ar name
447 Declare directory
448 .Pa name
449 to be deleted at deinstall time.  By default, directories created by a
450 package installation are not deleted when the package is deinstalled;
451 this provides an explicit directory cleanup method.  This directive
452 should appear at the end of the package list.  If more than one
453 .Cm @dirrm
454 directives are used, the directories are removed in the order specified.
455 The
456 .Pa name
457 directory will not be removed unless it is empty.
458 .It Cm @mtree Ar name
459 Declare
460 .Pa name
461 as an
462 .Xr mtree 8
463 input file to be used at install time (see
464 .Fl m
465 above).  Only the first
466 .Cm @mtree
467 directive is honored.
468 .It Cm @display Ar name
469 Declare
470 .Pa name
471 as the file to be displayed at install time (see
472 .Fl D
473 above).
474 .It Cm @pkgdep Ar pkgname
475 Declare a dependency on the
476 .Ar pkgname
477 package.  The
478 .Ar pkgname
479 package must be installed before this package may be
480 installed, and this package must be deinstalled before the
481 .Ar pkgname
482 package is deinstalled.  Multiple
483 .Cm @pkgdep
484 directives may be used if the package depends on multiple other packages.
485 .El
486 .Sh ENVIRONMENT
487 The environment variable
488 .Ev PKG_TMPDIR
489 names the directory where
490 .Nm
491 will attempt to create its temporary files.
492 If
493 .Ev PKG_TMPDIR
494 is not set,
495 the directory named by the contents of
496 .Ev TMPDIR
497 will be used.
498 If neither of
499 .Ev PKG_TMPDIR
500 and
501 .Ev TMPDIR
502 are set, the builtin defaults are used.
503 .Sh FILES
504 .Bl -tag -width /usr/tmp -compact
505 .It Pa /var/tmp
506 Temporary directory if environmental variables
507 .Ev PKG_TMPDIR
508 and
509 .Ev TMPDIR
510 are not set.
511 .It Pa /tmp
512 The next choice if
513 .Pa /var/tmp
514 does not exist.
515 .It Pa /usr/tmp
516 The last choice if
517 .Pa /tmp
518 is unsuitable.
519 .El
520 .Sh SEE ALSO
521 .Xr pkg_add 1 ,
522 .Xr pkg_delete 1 ,
523 .Xr pkg_info 1 ,
524 .Xr pkg_update 1 ,
525 .Xr pkg_version 1 ,
526 .Xr sysconf 3
527 .Sh HISTORY
528 The
529 .Nm
530 command first appeared in
531 .Fx .
532 .Sh AUTHORS
533 .An Jordan Hubbard
534 .Sh CONTRIBUTORS
535 .An John Kohl Aq jtk@rational.com
536 .Sh BUGS
537 Hard links between files in a distribution must be bracketed by
538 .Cm @cwd
539 directives in order to be preserved as hard links when the package is
540 extracted.  They additionally must not end up being split between
541 .Cm tar
542 invocations due to exec argument-space limitations (this depends on the
543 value returned by
544 .Fn sysconf _SC_ARG_MAX ) .
545 .Pp
546 Sure to be others.