]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.sbin/pkg_install/create/pkg_create.1
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.sbin / pkg_install / create / pkg_create.1
1 .\"
2 .\" FreeBSD install - a package for the installation and maintenance
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 November 9, 2012
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, .txz
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 J
329 Use
330 .Xr xz 1
331 utility to compress package tarball instead of
332 .Xr gzip 1 .
333 Please note that this option is a NO-OP if the format of the resulting
334 archive is explicitly specified by the recognizable suffix of
335 .Ar pkg-filename .
336 Currently
337 .Nm
338 recognizes the following suffixes:
339 .Pa .tbz , .tgz, .txz
340 and
341 .Pa .tar .
342 .It Fl b , -backup Ar pkg-name
343 Create package file from a locally installed package named
344 .Ar pkg-name .
345 If the
346 .Ar pkg-filename
347 is not specified, then resulting archive will be created in the
348 current directory and named
349 .Ar pkg-name
350 with an appropriate extraction suffix applied.
351 .It Fl R , -recursive
352 When creating package file from a locally installed package
353 also create package files for all packages required by
354 .Ar pkg-name .
355 Resulting archive(s) will be created in the current directory
356 and named using name of the respective package with appropriate
357 extraction suffix applied.
358 .It Fl x , -regex
359 Use basic regular expressions for
360 .Ar pkg-name .
361 .It Fl E , -extended
362 Use extended (modern) regular expressions for
363 .Ar pkg-name .
364 .It Fl G , -no-glob
365 Use exact matching for
366 .Ar pkg-name .
367 .It Fl n
368 Run in
369 .Dq no clobber
370 mode.
371 If a package tarball exists, the
372 .Nm
373 utility will not overwrite it.
374 This is useful, for example, when multiple packages are saved with
375 several consecutive runs of
376 .Nm
377 with the
378 .Fl Rb
379 options.
380 Saving common dependencies multiple times would do a lot of duplicate
381 work in this case.
382 The
383 .Fl n
384 option avoids repackaging common dependencies multiple times.
385 .El
386 .Sh PACKING LIST DETAILS
387 The
388 .Dq packing list
389 format (see
390 .Fl f )
391 is fairly simple, being
392 nothing more than a single column of filenames to include in the
393 package.
394 However, since absolute pathnames are generally a bad idea
395 for a package that could be installed potentially anywhere, there is
396 another method of specifying where things are supposed to go
397 and, optionally, what ownership and mode information they should be
398 installed with.
399 This is done by embedding specialized command sequences
400 in the packing list.
401 Briefly described, these sequences are:
402 .Bl -tag -width indent -compact
403 .It Cm @cwd Op Ar directory
404 Set the internal directory pointer to point to
405 .Ar directory .
406 All subsequent filenames will be assumed relative to this directory.
407 If no
408 .Ar directory
409 argument is given, it will set the internal directory pointer to the
410 first prefix value.
411 Note:
412 .Cm @cd
413 is also an alias for this command.
414 .It Cm @srcdir Ar directory
415 Set the internal directory pointer for _creation only_ to
416 .Ar directory .
417 That is to say that it overrides
418 .Cm @cwd
419 for package creation but not extraction.
420 .It Cm @exec Ar command
421 Execute
422 .Ar command
423 as part of the unpacking process.
424 If
425 .Ar command
426 contains any of the following sequences somewhere in it, they will
427 be expanded inline.
428 For the following examples, assume that
429 .Cm @cwd
430 is set to
431 .Pa /usr/local
432 and the last extracted file was
433 .Pa bin/emacs .
434 .Bl -tag -width indent -compact
435 .It Cm "%F"
436 Expands to the last filename extracted (as specified), in the example case
437 .Pa bin/emacs
438 .It Cm "\&%D"
439 Expand to the current directory prefix, as set with
440 .Cm @cwd ,
441 in the example case
442 .Pa /usr/local .
443 .It Cm "\&%B"
444 Expand to the
445 .Dq basename
446 of the fully qualified filename, that
447 is the current directory prefix, plus the last filespec, minus
448 the trailing filename.
449 In the example case, that would be
450 .Pa /usr/local/bin .
451 .It Cm "%f"
452 Expand to the
453 filename
454 part of the fully qualified name, or
455 the converse of
456 .Cm \&%B ,
457 being in the example case,
458 .Pa emacs .
459 .El
460 .It Cm @unexec Ar command
461 Execute
462 .Ar command
463 as part of the deinstallation process.
464 Expansion of special
465 .Cm %
466 sequences is the same as for
467 .Cm @exec .
468 This command is not executed during the package add, as
469 .Cm @exec
470 is, but rather when the package is deleted.
471 This is useful
472 for deleting links and other ancillary files that were created
473 as a result of adding the package, but not directly known to
474 the package's table of contents (and hence not automatically
475 removable).
476 The advantage of using
477 .Cm @unexec
478 over a deinstallation script is that you can use the
479 .Dq special sequence expansion
480 to get at files regardless of where they have
481 been potentially redirected (see
482 .Fl p ) .
483 .It Cm @mode Ar mode
484 Set default permission for all subsequently extracted files to
485 .Ar mode .
486 Format is the same as that used by the
487 .Cm chmod
488 command (well, considering that it is later handed off to it, that is
489 no surprise).
490 Use without an arg to set back to default (extraction)
491 permissions.
492 .It Cm @option Ar option
493 Set internal package options, the only two currently supported ones
494 being
495 .Ar extract-in-place ,
496 which tells the pkg_add command not to extract the package's tarball
497 into a staging area but rather directly into the target
498 hierarchy (this is typically meant to be used only by distributions
499 or other special package types), and
500 .Ar preserve ,
501 which tells pkg_add to move any existing files out of the way,
502 preserving the previous contents (which are also resurrected on
503 pkg_delete, so caveat emptor).
504 .It Cm @owner Ar user
505 Set default ownership for all subsequently extracted files to
506 .Ar user .
507 Use without an arg to set back to default (extraction)
508 ownership.
509 .It Cm @group Ar group
510 Set default group ownership for all subsequently extracted files to
511 .Ar group .
512 Use without an arg to set back to default (extraction)
513 group ownership.
514 .It Cm @comment Ar string
515 Imbed a comment in the packing list.
516 Useful in
517 trying to document some particularly hairy sequence that
518 may trip someone up later.
519 .It Cm @noinst Ar option Ar file
520 Specify that the package would have installed
521 .Pa file
522 if
523 .Pa option
524 had been specified at build time.
525 The action of
526 .Cm @noinst
527 is the same that
528 .Cm @comment
529 (which is doing nothing, it is just additional information).
530 .It Cm @ignore
531 Used internally to tell extraction to ignore the next file (do not
532 copy it anywhere), as it is used for some special purpose.
533 .It Cm @ignore_inst
534 Similar to
535 .Cm @ignore ,
536 but the ignoring of the next file is delayed one evaluation cycle.
537 This
538 makes it possible to use this directive in the
539 .Ar packinglist
540 file, so you can pack a
541 specialized datafile in with a distribution for your install script (or
542 something) yet have the installer ignore it.
543 .It Cm @name Ar name
544 Set the name of the package.
545 This is mandatory and is usually
546 put at the top.
547 This name is potentially different from the name of
548 the file it came in, and is used when keeping track of the package
549 for later deinstallation.
550 Note that
551 .Nm
552 will derive this field from the package name and add it automatically
553 if none is given.
554 .It Cm @dirrm Ar name
555 Declare directory
556 .Pa name
557 to be deleted at deinstall time.
558 By default, directories created by a
559 package installation are not deleted when the package is deinstalled;
560 this provides an explicit directory cleanup method.
561 This directive
562 should appear at the end of the package list.
563 If more than one
564 .Cm @dirrm
565 directives are used, the directories are removed in the order specified.
566 The
567 .Pa name
568 directory will not be removed unless it is empty.
569 .It Cm @mtree Ar name
570 Declare
571 .Pa name
572 as an
573 .Xr mtree 8
574 input file to be used at install time (see
575 .Fl m
576 above).
577 Only the first
578 .Cm @mtree
579 directive is honored.
580 .It Cm @display Ar name
581 Declare
582 .Pa name
583 as the file to be displayed at install time (see
584 .Fl D
585 above).
586 .It Cm @pkgdep Ar pkgname
587 Declare a dependency on the
588 .Ar pkgname
589 package.
590 The
591 .Ar pkgname
592 package must be installed before this package may be
593 installed, and this package must be deinstalled before the
594 .Ar pkgname
595 package is deinstalled.
596 Multiple
597 .Cm @pkgdep
598 directives may be used if the package depends on multiple other packages.
599 .It Cm @conflicts Ar pkgcflname
600 Declare a conflict with the
601 .Ar pkgcflname
602 package, as the two packages contain references to the same files,
603 and so cannot co-exist on the same system.
604 .El
605 .Sh ENVIRONMENT
606 The environment variable
607 .Ev PKG_TMPDIR
608 names the directory where
609 .Nm
610 will attempt to create its temporary files.
611 If
612 .Ev PKG_TMPDIR
613 is not set,
614 the directory named by the contents of
615 .Ev TMPDIR
616 will be used.
617 If neither of
618 .Ev PKG_TMPDIR
619 and
620 .Ev TMPDIR
621 are set, the builtin defaults are used.
622 .Sh FILES
623 .Bl -tag -width /usr/tmp -compact
624 .It Pa /var/tmp
625 Temporary directory if environmental variables
626 .Ev PKG_TMPDIR
627 and
628 .Ev TMPDIR
629 are not set.
630 .It Pa /tmp
631 The next choice if
632 .Pa /var/tmp
633 does not exist.
634 .It Pa /usr/tmp
635 The last choice if
636 .Pa /tmp
637 is unsuitable.
638 .It Ev PKG_OLD_NOWARN
639 If set
640 .Nm
641 will not warn about its use in the presence of pkgng databases.
642 .El
643 .Sh SEE ALSO
644 .Xr pkg_add 1 ,
645 .Xr pkg_delete 1 ,
646 .Xr pkg_info 1 ,
647 .Xr pkg_version 1 ,
648 .Xr sysconf 3
649 .Sh HISTORY
650 The
651 .Nm
652 command first appeared in
653 .Fx .
654 .Sh AUTHORS
655 .An Jordan Hubbard
656 .Sh CONTRIBUTORS
657 .An John Kohl Aq jtk@rational.com ,
658 .An Oliver Eikemeier Aq eik@FreeBSD.org
659 .Sh BUGS
660 Hard links between files in a distribution must be bracketed by
661 .Cm @cwd
662 directives in order to be preserved as hard links when the package is
663 extracted.
664 They additionally must not end up being split between
665 .Cm tar
666 invocations due to exec argument-space limitations (this depends on the
667 value returned by
668 .Fn sysconf _SC_ARG_MAX ) .
669 .Pp
670 Sure to be others.