testing: re-organize recipes into categories
[dragora.git] / qi / doc / qi.texi
blobd7bd33890cf83a28c7544d8a57bddd1a84ebfbad
1 \input texinfo   @c -*-texinfo-*-
2 @comment $Id@w{$}
3 @comment %**start of header
4 @setfilename qi.info
5 @settitle Qi manual
6 @documentencoding ISO-8859-1
7 @syncodeindex pg cp
8 @comment %**end of header
10 @set VERSION 1.0-rc4
11 @set UPDATED 30 Jan 2017
13 @copying
14 This manual is for Qi (version @value{VERSION},
15 @value{UPDATED}), which is a simple source builder and package manager.
17 Copyright @copyright{} 2015, 2016, 2017 Matias A. Fonzo, Argentina,
18 Santiago del Estero.
20 @quotation
21 Permission is granted to copy, distribute and/or modify this document
22 under the terms of the GNU Free Documentation License, Version 1.3 or
23 any later version published by the Free Software Foundation; with no
24 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
25 Texts.  A copy of the license is included in the section entitled
26 ``GNU Free Documentation License''.
27 @end quotation
28 @end copying
30 @dircategory Texinfo documentation system
31 @direntry
32 * Qi: (qi).                     Source builder and package manager.
33 @end direntry
35 @titlepage
36 @finalout
37 @title Qi
38 @subtitle for version @value{VERSION}, @value{UPDATED}
39 @author Matias A. Fonzo (@email{selk@@dragora.org})
41 @page
42 @vskip 0pt plus 1filll
43 @insertcopying
44 @end titlepage
46 @contents
48 @ifnottex
49 @node Top
50 @top
52 This manual is for Qi (version @value{VERSION},
53 @value{UPDATED}).
54 @end ifnottex
56 @menu
57 * Introduction::                    Purpose, description
58 * Invocation::                      Command-line interface
59 * The qirc file::                   Configuration file
60 * Packages::                        Managing packages
61 * Recipes::                         Building packages
62 * Order files::                     Handling the build order
63 * Examine packages::                Debugging purposes
64 * Messages::                        Output messages
65 * Exit status::                     Exit codes
66 * GNU Free Documentation License::
67 * Index::
68 @end menu
70 @sp 1
71 Copyright @copyright{} 2015-2017 Matias A. Fonzo, Argentina, Santiago
72 del Estero.
74 The Qi home page can be found at @uref{http://www.dragora.org}.
75 @w{Send bug reports or suggestions to @email{dragora-users@@nongnu.org}.}
78 @node Introduction
79 @chapter Introduction
80 @cindex introduction
82 Qi is a source builder and a package manager:
84 It contains a set of (individual) tools to build, install, remove, and
85 upgrade software packages.  It follows the philosophy of simplicity
86 without adding too many features, such as those that can be found in
87 popular package managers.  Basically it does two things: builds
88 packages and manages them.
90   Qi constructs the sources using recipe names, files that contain
91 specific instructions to build every source.  As result, a binary
92 package is obtained which can be installed, removed, upgraded, or
93 inspected in the system.
95 The packages are managed thanks to an external tool called
96 @emph{graft(1)}, which provides a mechanism for managing multiple
97 packages under a single directory hierarchy, it was inspired by both
98 Depot (Carnegie Mellon University) and Stow (Bob Glickstein).  In this
99 aspect, Qi complements Graft: it can work with packages, check them,
100 solve conflicts, and more...
103 @node Invocation
104 @chapter Invocation
105 @cindex invocation
107 The synopsis to invoke Qi is:
109 @example
110 pkg<action> [options] [package|recipe|order] ...
111 @end example
113 @noindent
114 The following commands or actions are supported by Qi:
116 @table @samp
118 @item pkghelp
119 Shows the help.
121 @item pkgadd
122 Add the packages to the system using @emph{graft(1)} for linking.
124 @item pkgremove
125 Remove the packages from the system.
127 @item pkgupgrade
128 Upgrade software packages.
130 @item pkgbuild
131 Build packages using recipe files.
133 @item pkgorder
134 Resolves the build order through .order files.
136 @item pkgerupt
137 Examine packages for debugging purposes.
139 @sp 1
140 @noindent
141 @strong{Global options}
143 There are global or common options for the commands, as well as specific to each one.
145 @item -h
146 Show options for the given command and exit.
148 @sp 1
149 @noindent
150 @strong{Options for command @samp{pkgadd}:}
152 @item -f
153 Force package installation (implies -p).
155 @item -P
156 Extract package on an installation tree.
158 This option sets @samp{$@{packagedir@}}.
160 Default value: @emph{PREFIX/pkg}
162 @item -p
163 Prune conflicts.
165 @item -t
166 Target directory for linking.
168 This option sets @samp{$@{targetdir@}}.
170 Default value: @emph{/}
172 @item -V
173 @emph{graft(1)} very verbose.
175 @item -w
176 Warn about the files that will be linked.
178 @sp 1
179 @noindent
180 @strong{Options for command @samp{pkgremove}:}
182 @item -k
183 Keep (don't delete) package directory.
185 @item -P
186 Remove from an installation tree.
188 This option sets @samp{$@{packagedir@}}.
190 Default value: @emph{PREFIX/pkg}
192 @item -p
193 Prune conflicts.
195 @item -t
196 Target directory for unlinking.
198 This option sets @samp{$@{targetdir@}}.
200 Default value: @emph{/}
202 @item -V
203 @emph{graft(1)} very verbose.
205 @sp 1
206 @noindent
207 @strong{Options for command @samp{pkgupgrade}:}
209 @item -k
210 Keep (don't delete) package directory.
212 @item -P
213 Package installation tree.
215 This option sets @samp{$@{packagedir@}}.
217 Default value: @emph{PREFIX/pkg}
219 @item -t
220 Target directory.
222 This option sets @samp{$@{targetdir@}}.
224 Default value: @emph{/}
226 @item -V
227 Enable (very) verbose mode.
229 @item -w
230 Warn about packages that will be upgraded.
232 @sp 1
233 @noindent
234 @strong{Options for command @samp{pkgbuild}:}
236 @item -a
237 Architecture to use.
239 This option sets @samp{$@{arch@}}.
241 Default value is obtained via @emph{uname(1)} as @samp{uname -m}.
243 @item -i
244 Increment release number.
246 This option increment the release number when a package is produced.
248 @item -j
249 Parallel jobs for the compiler
251 This option sets @samp{$@{jobs@}}.
253 Default value: @emph{1}
255 @item -k
256 Keep (don't delete) @samp{$@{srcdir@}} and @samp{$@{destdir@}}.
258 @item -n
259 Don't create a .tlz package.
261 @item -o
262 Where the produced packages are written.
264 This option sets @samp{$@{outdir@}}.
266 Default value: @emph{/var/cache/qi/packages}
268 @item -U
269 Perform package upgrade after build.
271 This option calls to @command{pkgupgrade}.
273 @sp 1
274 @noindent
275 @strong{Options for command @samp{pkgorder}:}
277 @item -x
278 Exclude depends file.
280 @section Environment
281 @cindex environment
283 Some influential environment variables:
285 @item QICFLAGS
286 C compiler flags for building packages.
288 Default value: @emph{"-g0 -Os"}
290 @item QICXXFLAGS
291 C++ compiler flags for building packages.
293 Default value: @emph{"-g0 -Os"}
295 @item QILDFLAGS
296 Linker flags for building packages.
298 Default value: @emph{-s}
300 @item DOPOST
301 post-install script control variable.
303 The @env{DOPOST} variable is currently used for @command{pkgadd},
304 @command{pkgupgrade}, @command{pkgbuild} (when option -U is given).
306 A different value than "DOPOST" omits the execution of the post-install
307 script (if any).
309 @item RC
310 Runtime configuration file.
312 A different value than "RC" overrides the configuration file.
314 This is used by: @command{pkgadd}, @command{pkgremove},
315 @command{pkgupgrade}, @command{pkgbuild}.
317 @item TMPDIR
318 Temporary directory (by default @emph{/tmp}).
320 @env{TMPDIR} is expanded with random numbers for major security.
322 This is used by: @command{pkgbuild}, @command{pkgerupt}.
323 @end table
325 @section Notes
326 @cindex notes
328 @itemize @bullet
329 @item Command names has been prefixed with @samp{pkg} to facilitate the
330 set in relation to its purpose.
332 @item The @emph{PREFIX} reference is related with the installation
333 prefix of Qi.
335 @item All the options can be mixed.  Options specified in the
336 command-line have priority over the config file @file{qirc}.
337 If there are no options, and if @file{qirc} is not present,
338 default (internal) values will be used instead.
339 @end itemize
342 @node The qirc file
343 @chapter The qirc file
344 @cindex the qirc file
346 @file{qirc} is the configuration file for Qi used at runtime during the
347 installation, removal of a package or when a recipe is built.  This
348 file is optional, and it can be useful to define variables and
349 configure external tools (such as a download manager) for default use.
351 @itemize @bullet
352 @item Variables are declared as @samp{name=value}.
354 @item Declaration of values should only take one line, no line break.
356 @item Assignments like @samp{name=$var} are only interpreted as
357 literal.
358 @end itemize
360 @noindent
361 The options specified in the command-line can override the values
362 specified in the configuration file.  For more information, see
363 @ref{Invocation}.
365 @noindent
366 The order in which Qi looks for this file is:
368 @enumerate
369 @item
370 @env{$@{HOME@}/.qirc}
371 @- Effective user.
373 @item
374 @samp{$@{sysconfdir@}/qirc}
375 @- System-wide.
376 @end enumerate
378 If you intend to run Qi for a specific user, you should copy the file
379 @samp{$@{sysconfdir@}/qirc} to @env{$@{HOME@}/.qirc} setting
380 @samp{$@{packagedir@}} and @samp{$@{targetdir@}} for your @env{$HOME}.
383 @node Packages
384 @chapter Packages
385 @cindex packages
387 A package is a suite of programs usually distributed in binary form
388 which may also contain manual pages, documentation, or any other file
389 associated to a specific software.
391 The Qi package format is a simple redistributable @emph{tar(1)} archive
392 compressed with @emph{lzip(1)}.  The package extension ends in ".tlz".
394 @noindent
395 Both package installation and package deinstallation are managed using
396 @samp{$@{packagedir@}} and @samp{$@{targetdir@}}:
398 @samp{$@{packagedir@}} is a common directory tree where the package contents
399 is decompressed (resides).  By default the tree is located at
400 @emph{PREFIX/pkg}.
402 @samp{$@{targetdir@}} is a target directory where the links will be
403 made taking @samp{$@{packagedir@}/package_name} into account.
405   Packages are installed in self-contained directory trees and symbolic
406 links from a common area are made to the package files.  This allows
407 multiple versions of the same package to co-exist on the one system.
409   All the links to install or to remove a package are managed using
410 @emph{graft(1)}.  Since multiple packages can be installed or removed
411 at the same time, certain conflicts may arise between the packages.
413   According to the User's Guide of Graft@footnote{The official guide
414 for Graft can be found at
415 @url{http://peters.gormand.com.au/Home/tools/graft/graft.html}.},
416 a conflict is defined as one of the following conditions:
418 @itemize @bullet
419 @item If the package object is a directory and the target object exists
420 but is not a directory.
422 @item If the package object is not a directory and the target object
423 exists and is not a symbolic link.
425 @item If the package object is not a directory and the target object
426 exists and is a symbolic link to something other than the package
427 object.
428 @end itemize
430 @noindent
431 Qi's default behavior is to not proceed with the installation when a
432 conflict occurs.  But when a package that is going to be removed is in
433 conflict with another package, @emph{graft(1)} removes those parts that
434 are not in conflict, leaving the links belonging to the original
435 package.  This behavior can be changed if the option -p is specified
436 (see the examples below).
438 @section Adding packages
439 @cindex adding packages
441 This sort order is particularly useful just before the actual package
442 installation, because it helps to understand how the package
443 installation works:
445 @enumerate
446 @item Detects and reports if the package is already installed.
448 @item Ignores some signals up to completing the installation:
449 HUP INT QUIT ABRT TERM.
451 @item The integrity of the file (package) is checked.
453 @item Creates required directory for the package as
454 @samp{$@{packagedir@}/package_name}.
456 @item Decompress the content of the package in
457 @samp{$@{packagedir@}/package_name}.
459 @item A test of the package is performed before completing the
460 installation to see if there are no conflicts with another package.
461 This is the default behavior if -p is not supplied.
463 @item @emph{graft(1)} is invoked to install symbolic links from
464 the package installation directory to the target directory.
466 @item If the meta file is readable, the description will be shown for
467 the package.
469 @item Run post install instructions from @file{post-install}, if any.
470 @end enumerate
472 @noindent
473 @emph{Usage:} pkgadd [-hfpVw] [-P <DIR>] [-t <DIR>] [package.tlz ...]
475 To install a single package, simply type:
477 @example
478 pkgadd coreutils-8.24-x86_64+1.tlz
479 @end example
481 To install multiple packages at once:
483 @example
484 pkgadd gcc-4.9.3-x86_64+1.tlz rafaela-2.2-i586+1.tlz ...
485 @end example
487 Warn about the files that will be linked:
489 @example
490 pkgadd -w gcc-4.9.3-x86_64+1.tlz
491 @end example
493 @itemize @bullet
494 @item This is to verify the content of a package before installing it.
495 @end itemize
497 See what happens when a package is installed (very verbose):
499 @example
500 pkgadd -V mariana-3.0-x86_64+1.tlz
501 @end example
503 @itemize @bullet
504 @item This is for a detailed (long) output.
505 @end itemize
507 Installing in a different directory tree and target:
509 @example
510 pkgadd -P /tmp/pkgdir -T /tmp/targetdir lzip-1.17-i586+1.tlz
511 @end example
513   When a package is already installed, @command{pkgadd} refuses to
514 continue.  This is to keep some control over the database of your
515 packages, if you really want to force the installation of a package,
516 you can use the -f option (which implies -p).  See below.
518 @strong{Pruning conflicts}
520 Remove objects (files, links or directories) from the target
521 directory that are in conflict with the package directory:
523 @example
524 pkgadd -p zutils-1.4-x86_64+1.tlz
525 @end example
527 When the -p option is used, it proceeds to install the package
528 normally, but first will try to remove any conflict.  Use it with care,
529 combine this option with -V.
531 @section Removing packages
532 @cindex removing packages
534 This sort order is particularly useful just before the actual package
535 deinstallation, because it helps to understand how the package
536 deinstallation works:
538 @enumerate
539 @item Look for a package name to remove inside of
540 @samp{$@{packagedir@}}.  Package names must be specified using the full
541 package name, such as "name-version-arch+release.tlz" or specifying the
542 package name directory.
544 @item Ignores some signals up to completing the deinstallation:
545 HUP INT QUIT ABRT TERM.
547 @item @emph{graft(1)} is invoked to remove symbolic links from
548 the package installation directory to the target directory:
550 If a conflict exists with another package, those links that are not in
551 conflict will be preserved.  It's possible to prune all the conflicts
552 using the -p option.
554 @item Remove directories made empty by package deletion.  This has
555 effect on @samp{$@{targetdir@}} but not for @samp{$@{packagedir@}}.
557 @item The package directory is deleted if the option -k is not
558 supplied.
559 @end enumerate
561 @noindent
562 @emph{Usage:} pkgremove [-hkpV] [-P <DIR>] [-t <DIR>] [package_name ...]
564 To remove a package, just execute the command:
566 @example
567 pkgremove xz-5.2.2-x86_64+1
568 @end example
570 To remove multiple versions of the same package:
572 @example
573 pkgremove xz*
574 @end example
576 To remove multiple packages at once:
578 @example
579 pkgremove foo bar baz ...
580 @end example
582 Detailed output (very verbose):
584 @example
585 pkgremove -V xz-5.2.2-x86_64+1
586 @end example
588 Removing from a different directory tree and target:
590 @example
591 pkgremove -P /tmp/pkgdir -T /tmp/targetdir lzip-1.17-x86_64+1
592 @end example
594 Pruning conflicts:
596 @example
597 pkgremove -p -V hunter
598 @end example
600 @section Upgrading packages
601 @cindex upgrading packages
603 This sort order is particularly useful just before the actual package
604 upgrade, because it helps to understand how the package upgrade works:
606 @enumerate
607 @item Prepare temporary location for the incoming package.
609 @item Pre-install incoming package into the temporary location.
611 @item Remove packages under the same name: this is considered
612 as the old packages. (Default behaviour if -k is not supplied).
614 @item Upgrade or install the package calling to @command{pkgadd}.
616 @item Delete temporary location of the package.
617 @end enumerate
619 @noindent
620 @emph{Usage:} pkgupgrade [-hkVw] [-P <DIR>] [-t <DIR>] [package.tlz ...]
622 Upgrading a package is simple as:
624 @example
625 pkgupgrade coreutils-8.25-x86_64+1.tlz
626 @end example
628 @noindent
629 @samp{pkgupgrade} uses @command{pkgadd} and @command{pkgremove} to
630 upgrade software packages.  So it inherits the properties of each
631 utility, except here, only the essential options are provided.  For
632 example, the option -V (for a detailed output) belongs to when these
633 utilities are invoked.  The options -P and -t work in the same way as
634 the previous examples for @command{pkgadd}, @command{pkgremove}.
635 @samp{pkgupgrade} will try to update the package or to install it
636 (in case it has not been installed).
638 To see what packages will be updated (if any), always type:
640 @example
641 pkgupgrade -w coreutils-8.25-x86_64+1.tlz
642 @end example
644 @section Notes
645 @cindex notes
647 @itemize @bullet
648 @item Some signals like HUP INT QUIT ABRT TERM are ignored on the
649 package installation or deinstallation.  The intention is to ignore
650 the cancellation while the package is being installed or removed (e.g.
651 Ctrl+C, terminal window closed, etc.).  The installation or removal
652 of a package can be crucial for the proper functioning of the system.
654 @item The meta file is read from the directory where the package is
655 found.
657 @item A post-install script is read from
658 @samp{$@{packagedir@}/package_name/var/lib/qi/post-install/name.install}.
660 @item Default behavior is to upgrade or install a package removing old
661 packages, this is "packages found under the same name".  If you want to
662 preserve the multiple versions of the same package, you must pass the
663 -k option.
664 @end itemize
667 @node Recipes
668 @chapter Recipes
669 @cindex recipes
671 A recipe is a file telling qi what to do.  Most often, the recipe
672 tells qi how to build a binary package from a source tarball.
674 A recipe has two parts: a list of variable definitions and a list of
675 sections.  By convention, the syntax of a section is:
677 @example
678 section_name() @{
679   section lines
681 @end example
683 The section name is followed by parentheses, one space and an opening
684 brace.  The line finishing the section contains just a closing brace.
685 The section names or the function names currently recognized are
686 @samp{build}.
688 The @samp{build} section is an augmented shell script.  This is the main
689 section (or @strong{shell function}) which contains the instructions to
690 build and produce a package.
692 @section Variables
693 @cindex variables
695 A "variable" is a @strong{shell variable} defined either in @file{qirc}
696 or in a recipe to represent a string of text, called the variable's
697 "value".  These values are substituted by explicit request in the
698 definitions of other variables or in calls to external commands.
700 Variables can represent lists of file names, options to pass to
701 compilers, programs to run, directories to look in for source files,
702 directories to write output in, or anything else you can imagine.
704 Definitions of variables in qi have four levels of precedence.
705 Options which define variables from the command-line override those
706 specified in the @file{qirc} file, while variables defined in the recipe
707 override those specified in @file{qirc}, taking priority over those
708 variables settled by options via command-line.  Finally, some variables
709 (arch, jobs, outdir, worktree, tardir, netget, rsync) have default
710 values if they are not defined anywhere.
712 Options that set variables through the command-line can only reference
713 variables defined in @file{qirc} and variables with default values.
715 Definitions of variables in @file{qirc} can only reference variables
716 previously defined in @file{qirc} and variables with default values.
718 Definitions of variables in the recipe can only reference variables
719 settled by command-line, variables previously defined in the recipe,
720 variables defined in @file{qirc}, and variables with default values.
722 @subsection Special variables
723 @cindex special variables
725 The three variables @samp{arch}, @samp{jobs}, and @samp{outdir} can
726 only be set using command line options or in @file{qirc}.  If not
727 specified, they have default values.
729   @samp{arch} is the architecture to compose the package name.  Its
730 value is available in the recipe as @samp{$@{arch@}}.  Default value is
731 the output of @samp{uname -m}.
733   @samp{jobs} is the number of jobs to pass to the compiler.  Its
734 default value is available in the recipe as @samp{$@{jobs@}}.  Defaults
735 to @samp{1}.
737   @samp{outdir} is the directory where the produced packages are
738 written.  This variable cannot be redefined in the recipe.  Defaults to
739 @samp{/var/cache/qi/packages}.
741   @samp{worktree} is the working tree where archives, patches, and
742 recipes are expected.  This variable cannot be redefined in the
743 recipe.  Defaults to @samp{/usr/src/qi}.
745   The variable @samp{tardir} is defined in the recipe to the directory
746 where the tarball containing the source can be found.  The full name of
747 the tarball is commonly used as @samp{$@{tardir@}/$tarname}.  A value
748 of @samp{.} for @samp{tardir} sets it to the value of the CWD (Current
749 Working Directory), this means, from where the recipe is located.
751   The two variables @samp{srcdir} and @samp{destdir} can be defined in
752 the recipe, as any other variable, but if they are not, Qi uses default
753 values for them when building the package.
755 @samp{srcdir} contains the source code to be compiled, and defaults to
756 @samp{$@{program@}-$@{version@}}.
758 @samp{destdir} is the place where the built package will be installed,
759 and defaults to @samp{$@{TMPDIR@}/package-$@{program@}}.
761   If @samp{pkgname} is left undefined, the special variable
762 @samp{program} is assigned by default.  If @samp{pkgversion} is left
763 undefined, the special variable @samp{version} is assigned by default.
765   @samp{pkgname}, @samp{pkgversion}, along with @samp{version},
766 @samp{arch}, and @samp{release}, are used to produce the name of the
767 package in the form
768 @samp{$@{pkgname@}-$@{pkgversion@}-$@{arch@}+$@{release@}.tlz}.  All of
769 them must be defined in the recipe, excepting @samp{arch}, which is
770 optional.
772 @itemize @bullet
773 @item @samp{program}: name of the package.
775 @item @samp{version}: version of the package.
777 @item @samp{arch}: architecture of the package.
779 @item @samp{release}: release number of the package. It is recommended to 
780 increase this number after any significant change in the recipe is made.
781 @end itemize
783 @noindent
784 Obtaining sources over the network must be declared in the recipe using
785 the @samp{fetch} variable.  Use double quotes for separated values.
787   The variables @samp{netget} and @samp{rsync} can be defined in
788 @file{qirc} to establish a network downloader in order to get the
789 sources.  If they are not defined, qi uses default values:
791 @samp{netget} is the general network downloader tool for use, and
792 defaults to @samp{wget -c -w1 -t3 --no-check-certificate}.
794 @samp{rsync} is the network tool for sources containing the prefix for
795 the RSYNC protocol, and defaults to
796 @samp{rsync -v -a -L -z -i --progress}.
798 @noindent
799 There are three important variables to produce meta information of the
800 package: @samp{description}, @samp{homepage}, @samp{license}.
802   The variable @samp{description} is special to write the description of the
803 package, which will be shown when installed.
805   A description has two parts: a brief description and a long
806 description.  By convention, the syntax of a description is:
808 @example
809 description="
810 Brief description.
812 Long description.
814 @end example
816 @noindent
817 The first (substantial) line of the value is a brief description of the
818 software (called the "blurb").  A new (blank) line is followed to
819 separate the brief description from the long description.
821 An example looks like:
823 @example
824 description="
825 A source builder and a package manager.
827 Qi is a source builder and a package manager.  It contains a set of
828 tools to build, install, remove, and upgrade software packages.
830 Qi follows the philosophy of the simplicity without adding too many
831 features, such as those that can be found in popular package managers.
832 Basically it does two things: builds packages and manages them.
834 @end example
836 @itemize @bullet
837 @item Consider a length limit of 78 characters as maximum.
838 @xref{Recipes, The meta file}.
839 @end itemize
841 @noindent
842 The @samp{homepage} variable is used simply to declare the main site or
843 home of the source, thus:
845 @example
846 homepage=http://www.dragora.org
847 @end example
849 @noindent
850 The variable @samp{license} is used for license information@footnote{
851 The proposal for @samp{license} was made by Richard M. Stallman at
852 @url{http://lists.gnu.org/archive/html/gnu-linux-libre/2016-05/msg00003.html}.}.
853 Some code in the program can be covered by license A, license B, or
854 license C.  For "separate licensing" or "heterogeneous licensing",
855 we suggest using @strong{|} for a disjunction, @strong{&} for a
856 conjunction (if that ever happens in a significant way), and comma
857 for heterogeneous licensing.  Comma would have lower precedence.  Plus
858 added special terms.
860 @example
861 license="LGPL, GPL | Artistic, GPL + added permission"
862 @end example
864 @subsection Variables from the environment
865 @cindex variables from the environment
867 The variables @env{QICFLAGS}, @env{QICXXFLAGS}, and @env{QILDFLAGS} have
868 no effect by default.  The environment variables such as @env{CFLAGS},
869 @env{CXXFLAGS}, and @env{LDFLAGS} are unset at compile time.
871 Recommended practices is to set variables in front of @samp{configure}
872 or in front of @emph{make(1)} instead of exporting to the environment.
873 As follows:
875 @quotation
876 Variables not defined in a site shell script can be set in the
877 environment passed to configure. However, some packages may run
878 configure again during the build, and the customized values of these
879 variables may be lost. In order to avoid this problem, you should set
880 them in the configure command line, using @samp{VAR=value}.  For
881 example:
883 @code{./configure CC=/usr/local2/bin/gcc}
885 @url{http://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Defining-Variables.html}
886 @end quotation
888 @quotation
889 Indeed, while configure can notice the definition of CC in @samp{./configure
890 CC=bizarre-cc}, it is impossible to notice it in @samp{CC=bizarre-cc
891 ./configure}, which, unfortunately, is what most users do.
893 [...]
895 configure: error: changes in the environment can compromise the build.
897 @url{http://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html}
898 @end quotation
900 @quotation
901 It is not wise for makefiles to depend for their functioning on
902 environment variables set up outside their control, since this would
903 cause different users to get different results from the same makefile.
904 This is against the whole purpose of most makefiles. 
906 @url{http://gnu.org/software/make/manual/make.html#Environment}
907 @end quotation
909 @section The meta file
910 @cindex the meta file
912 The "meta file" is an external file created by @command{pkgbuild} when
913 a recipe is processed and when a package is produced.  The file is
914 generated as @samp{$@{full_pkgname@}.tlz.txt} which contains
915 information about the package such as @samp{program}, @samp{version},
916 @samp{release}.  Also definitions of the special variables
917 @samp{fetch}, @samp{description}, @samp{homepage}, @samp{license}.
919 A meta file has the purpose to extract information and the purpose to
920 reflect essential information to the user without having to check
921 inside the package itself.
923 The meta file is basically composed as:
925 @example
926 # Description
928 variable=value
930 @end example
932 @noindent
933 The description is extracted from the declared variable
934 @samp{description}, where each line is interpreted literally and where
935 the description is pre-formatted to fit in (exactly) 80 columns.  Plus
936 @samp{# } is prepend to each line.
938 Followed by new line, the rest is composed by variables; the inclusion
939 of its values, may vary.  For example, in addition to the special
940 variables, there are implicit variables such as @samp{blurb},
941 @samp{depends}.
943   The @samp{blurb} variable is related to the special variable
944 @samp{description}.  Always taking the first (substantial) line
945 or "brief description".
947   The value of @samp{depends} only will be included if the
948 @file{depends} file is a regular file.  @xref{Order files, The depends
949 file}.
951 @noindent
952 Now let's take a look on a real example of a meta file:
954 @example
955 # A lossless data compressor based on the LZMA algorithm.
957 # Clzip is a lossless data compressor with a user interface similar to
958 # the one of gzip or bzip2.  Clzip is about as fast as gzip, compresses
959 # most files more than bzip2, and is better than both from a data
960 # recovery perspective.
962 # Clzip uses the lzip file format; the files produced by clzip are fully
963 # compatible with lzip-1.4 or newer, and can be rescued with lziprecover.
965 # Clzip is in fact a C language version of lzip, intended for embedded
966 # devices or systems lacking a C++ compiler.
968 QICFLAGS="-g0 -Os"
969 QICXXFLAGS="-g0 -Os"
970 QILDFLAGS="-s"
971 program=clzip
972 version=1.8
973 release=1
974 blurb="A lossless data compressor based on the LZMA algorithm."
975 homepage="http://lzip.nongnu.org/clzip.html"
976 license="GPLv2+"
977 fetch="http://download.savannah.gnu.org/releases/lzip/clzip/clzip-1.8.tar.gz"
978 depends=" "
980 @end example
982 Creation of the meta file is made in @samp{$@{outdir@}}.
984 @section Building packages
985 @cindex building packages
987 This sort order is particularly useful just before the actual package
988 build, because it helps to understand how a package is being built:
990 @enumerate
991 @item A recipe is read from the current directory, if not, it will be
992 looked in @samp{$@{worktree@}/recipes}.  Names of recipes can be
993 invoked relative to @samp{$@{worktree@}/recipes}.  The recipe must be
994 a regular file and must be readable by the user who is running the
995 command.
997 @item Checks are made when the recipe is imported (included), essential
998 variable names cannot be empty: @samp{program}, @samp{version},
999 @samp{release}.  Also the main function @samp{build()} must be present.
1001 @item @command{pkgbuild} tries to obtain the sources remotely if it
1002 does not exist locally (@samp{$@{tardir@}}).  Once the source is
1003 already in place, its timestamp is updated, creating or updating the
1004 SHA1 sum.
1006 @item Required directories are created: @samp{$@{TMPDIR@}/$srcdir},
1007 @samp{$@{outdir@}}, @samp{$@{destdir@}/var/lib/qi/recipes}.
1009 @item Sane ownerships and permissions are applied to the full source
1010 directory: @samp{$@{TMPDIR@}/$srcdir}.
1012 @item The main function @samp{build()} is called.  Exits immediately if
1013 a command exits with a non-zero status.
1015 @item A package is going to be created under the following conditions:
1017 @itemize @bullet
1018 @item If @samp{$@{destdir@}} is not empty.
1020 @item If the option -n was not given.
1021 @end itemize
1023 A copy of the recipe (file) is included on
1024 @samp{$@{destdir@}/var/lib/qi/recipes} as @samp{$@{full_pkgname@}.recipe}.
1026 If the @file{post-install} script is in the current working directory
1027 or from where the recipe name resides, it will be added as
1028 @samp{$@{destdir@}/var/lib/qi/post-install/$@{full_pkgname@}.install}.
1030 The package is produced from the content of @samp{$@{destdir@}}.  First,
1031 creating a tarball, and then compressing it using the maximum level of
1032 compression of @emph{lzip(1)}.
1034 @item By default, directories like @samp{$@{TMPDIR@}/$srcdir} and
1035 @samp{$@{destdir@}} are deleted.
1037 @item If the option -U is given, @command{pkgupgrade} is invoked to
1038 install or upgrade the package.
1040 @end enumerate
1042 @noindent
1043 @emph{Usage:} pkgbuild [-hiknU] [-a <ARCH>] [-j <JOBS>] [-o <DIR>] [recipe ...]
1045 To build a single package, simply type:
1047 @example
1048 pkgbuild clzip.recipe
1049 @end example
1051 Compile passing parallel jobs to the compiler for speed up the process:
1053 @example
1054 pkgbuild -j4 clzip.recipe
1055 @end example
1057 To build and install or upgrade multiple packages at once:
1059 @example
1060 pkgbuild -U clzip.recipe zutils.recipe matias.recipe
1061 @end example
1063 Reading recipes and building from the output of a command:
1065 @example
1066 cat depends | pkgbuild -
1067 @end example
1069 Incrementing the release number after a significant change in a recipe:
1070 @example
1071 pkgbuild -i stargazer.recipe
1072 @end example
1074 @noindent
1075 If the recipe name cannot be read from the current directory or from
1076 a specific path name, @samp{$@{worktree@}/recipes} is used for the
1077 search:
1079 There is a special case for the names of recipes @samp{recipe}.
1080 @command{pkgbuild} can complete the recipe name without being required
1081 to be specified in the command-line, only if the name of the recipe is
1082 @samp{recipe}.  For example:
1084 @example
1085 pkgbuild devel/gcc
1086 @end example
1088 Will complete the search as @samp{$@{worktree@}/recipes/devel/gcc/recipe}.
1090 @section Writing recipes
1091 @cindex writing recipes
1093 @subsection Internal functions
1094 @cindex internal functions
1096 Some internal functions are available to be applied on the recipe:
1098 @table @samp
1100 @item unpack()
1101 The unpack function can decompress multiple (compressed) files while
1102 verifies the integrity.  Depending on where the function is called,
1103 the decompression occurs in the current working directory.
1105 Usage: @code{unpack file(s) ...}
1107 The cases supported for the special extensions are: *.tar, *.tar.*,
1108 *.tgz*, *.tbz*, *.tlz*, *.txz*, *.zip, *.ZIP, *.gz, *.bz2, *.lz.
1109 @end table
1112 @node Order files
1113 @chapter Order files
1114 @cindex .order files
1116 @command{pkgorder} has the purpose to resolve the build order through
1117 .order files.  In other words, is a good complement for
1118 @command{pkgbuild}.
1120 @noindent
1121 @emph{Usage:} pkgorder [-x] [file_name.order ...]
1123 @noindent
1124 Basically, @command{pkgorder} reads from a declared file which ends in
1125 ".order".  The output is an ordered list of recipe names which can be
1126 passed to @command{pkgbuild} (via a pipe) to build a number or a series
1127 of packages.
1129 @sc{Declaration}
1131 If 'a' depends on 'b' and 'c', and 'c' depends on 'b' as well, the file
1132 might look like:
1134 @example
1135 a.recipe: c.recipe b.recipe
1136 b.recipe:
1137 c.recipe: b.recipe
1138 @end example
1140 Each letter represents a recipe name, complete dependencies for
1141 the first recipe name are listed in descending order, which is
1142 printed from right to left, and removed from left to right:
1144 @sc{Output}
1146 @example
1147 b.recipe
1148 c.recipe
1149 a.recipe
1150 @end example
1152 @itemize @bullet
1153 @item Commented lines starting with a '#' are allowed.  Blank lines,
1154 colons, parentheses, and end of line are removed.
1155 @end itemize
1157 @section The depends file
1158 @cindex the depends file
1160 When @command{pkgorder} read from an order file; by default, it will
1161 proceed to read the dependencies of each recipe.  This behavior can be
1162 omitted if the -x option is given.
1164   The procedure for reading the dependencies of each recipe is
1165 extracting the directory location where the order file resides.  Then
1166 it iterates over the declared items extracting its location in search
1167 of the special file @file{depends}.
1169 @itemize @bullet
1170 @item The @file{depends} file only is read (sequentially) if it is
1171 a regular file and is not empty.
1172 @end itemize
1174 @noindent
1175 The special file @file{depends} must contain a list of prerequisites
1176 for the recipe.  Prerequisites are names of valid recipes, including
1177 its location.  The location must be relative to @samp{$@{worktree@}}
1178 (variable described in @ref{Recipes}).
1180 Example of a @file{depends} file declared for @emph{bash.recipe}:
1182 @example
1183 libs/readline/readline.recipe
1184 @end example
1186 Then, if @emph{core/bash/bash.recipe} has been declared on
1187 @emph{core.order}, the output would be:
1189 @example
1191 libs/readline/readline.recipe
1192 core/bash/bash.recipe
1194 @end example
1196 Combined in a pipe, @emph{readline} represents the first dependency
1197 of @emph{bash}:
1199 @example
1200 @code{pkgorder core.order | pkgbuild -U -}
1201 @end example
1204 @node Examine packages
1205 @chapter Examine packages
1206 @cindex examine packages
1208 @command{pkgerupt} is a special command to examine packages for
1209 debugging purposes.
1211 @noindent
1212 @emph{Usage:} pkgerupt [-h] [package.tlz ...]
1214 When a package name is given @command{pkgerupt} will create a random
1215 directory for the package.  The prefix directory where the random
1216 directory is created is controlled by the @env{TMPDIR} variable,
1217 by default @env{TMPDIR} is assigned to @emph{/tmp}.  Creation mode
1218 is "u=,g=rwx,o=rwx" (0700).
1220 The extraction to inspecting a package is equivalent to the shell
1221 instruction:
1223 @example
1224 @code{( umask 000 && cd -- $PRVDIR && lzip -cd - | tar -xf - ) < $file}
1225 @end example
1227 The package content is decompressed in the random (private) directory
1228 via pipe.  Creation mode is "u=rwx,g=rwx,o=rwx" (0777).
1230   If there is any substantial change, consider increasing the build
1231 number when repackaging: edit the value of the @samp{release} variable
1232 (recipe), compose the output file using the new number.
1235 @node Messages
1236 @chapter Messages
1237 @cindex output messages
1239 Some symbols are used for output messages to help to identify
1240 the messages shown by the tools in Qi.  There are four simple
1241 categories where the symbols are represented:
1243 @sp 1
1244 @noindent
1245 @strong{Specifics}
1247 This symbols are unique to identify the running tool:
1249 @table @samp
1250 @item +
1251 This symbol belongs to the @command{pkgadd} tool.
1253 @item -
1254 This symbol belongs to the @command{pkgremove} tool.
1256 @item ~
1257 This symbol belongs to the @command{pkgupgrade} tool.
1259 @item #
1260 This symbol belongs to the @command{pkgbuild} tool.
1262 @item =
1263 This symbol belongs to the @command{pkgerupt} tool.
1265 @item %
1266 This symbol is used to scan a package or to warn when
1267 the option is used.
1269 Specific symbols are enclosed between @samp{( )}.
1270 @end table
1272 @table @samp
1273 @strong{Preventive}
1275 Preventive symbols are intended to alert the user about unforeseen
1276 or important situations, and to meet requirements before proceeding:
1278 @item *
1279 Normally used for testing compressed sources, obtain remote sources,
1280 or set system permissions.
1282 Preventive symbols are enclosed between @samp{[ ]}.
1283 @end table
1285 @table @samp
1286 @strong{Informative}
1288 Informative symbols are intended to inform users the most essential
1289 tasks during the execution:
1291 @item i
1292 Symbol used when a task is going to be performed or when a task has
1293 been completed.
1295 @item !
1296 This symbol informs about deleting files.
1298 Informative symbols are enclosed between @samp{[ ]}.
1299 @end table
1301 @strong{Transitory}
1303 Transitory symbols are part for occasional changes (@samp{@@}) but no
1304 less important.  Also to invoke Qi tools externally (@samp{^}).
1306 Transitory symbols are enclosed between @samp{@{ @}}.
1309 @node Exit status
1310 @chapter Exit status
1311 @cindex exit codes
1313 All the conditions of exit codes are described in this chapter.
1315 @table @samp
1317 @item 0
1318 Successful completion (no errors).
1320 @item 1
1321 @strong{Minor common errors:}
1323 @itemize @minus
1324 @item Illegal option.
1326 @item Option requires an argument.
1328 @item Internal function to load not found.
1330 @item Program (prerequisite) is not available.
1331 @end itemize
1333 @item 2
1334 @strong{Command execution error}
1336 Evaluation of external commands or shell arguments.  If it fails,
1337 returns 2.
1339 @item 3
1340 @strong{Integrity check error for compressed files}
1342 Compressed files means:
1344 @itemize @minus
1345 @item All the tarballs supported by @emph{tar(1)}.
1347 @item Zip files supported by @emph{unzip(1)}.
1349 @item Gzip files supported by @emph{gzip(1)}.
1351 @item Bzip2 files supported by @emph{bzip2(1)}.
1353 @item Lzip files supported by @emph{lzip(1)}.
1354 @end itemize
1356 @item 4
1357 @strong{File empty, not regular, or expected}
1359 Commonly, it is expected:
1361 @itemize @minus
1362 @item A binary package (.tlz).
1364 @item An installed package to remove.
1366 @item A recipe file.
1368 @item A file of order (.order).
1369 @end itemize
1371 @item 5
1372 @strong{Empty or not defined variable}
1374 This exit code is used for reporting about empty or undefined variables.
1375 Usually, variables of the recipe or assigned arrays that are tested.
1377 @item 6
1378 @strong{Package already installed}
1380 The package directory for an incoming package already exists.
1382 @item 10
1383 @strong{Network manager error}
1385 Exit status from the execution of the network manager tool and its
1386 arguments.
1387 @end table
1389 @noindent
1390 @cartouche
1391 Error messages are reported to the standard error.
1392 @end cartouche
1395 @node GNU Free Documentation License
1396 @appendix GNU Free Documentation License
1398 @include fdl.texi
1401 @node Index
1402 @unnumbered Index
1404 @printindex cp
1406 @bye