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