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