\input texinfo   @c -*-texinfo-*-
@comment $Id@w{$}
@comment %**start of header
@setfilename qi.info
@settitle Qi user guide
@documentencoding ISO-8859-1
@syncodeindex pg cp
@comment %**end of header

@set VERSION 1.3
@set UPDATED 10 Sep 2019

@copying
This user guide is for Qi (version @value{VERSION},
@value{UPDATED}), which is a simple but well-integrated package manager.

Copyright @copyright{} 2019 Matias Andres Fonzo, Santiago del Estero,
Argentina.

@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the section entitled
``GNU Free Documentation License''.
@end quotation
@end copying

@dircategory Package management
@direntry
* Qi: (qi).                   A user-friendly package manager.
@end direntry

@titlepage
@finalout
@title Qi
@subtitle for version @value{VERSION}, @value{UPDATED}
@author Matias Fonzo (@email{selk@@dragora.org})

@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@contents

@ifnottex
@node Top
@top

This user guide is for Qi (version @value{VERSION},
@value{UPDATED}).
@end ifnottex

@menu
* Introduction::              Description and features of qi
* Invoking qi::               Command-line options
* The qirc file::             Configuration file
* Packages::                  Managing packages
* Recipes::                   Building packages
* Order files::               Handling build order
* Creating packages::         Making Qi packages
* Examining packages::        Debugging purposes
* Exit status::               Exit codes
* Index::
@end menu

@sp 1
Copyright (C) 2019 Matias Fonzo.

Qi's home page can be found at @uref{http://www.dragora.org}.
@w{Send bug reports or suggestions to @email{dragora-users@@nongnu.org}.}

@node Introduction
@chapter Introduction
@cindex introduction

Qi is a simple but well-integrated package manager.  It can create,
install, remove, and upgrade software packages.  Qi produces binary
packages using recipes, which are files containing specific instructions
to build each package from source.  Qi can manage multiple packages
under a single directory hierarchy.  This method allows to maintain a set
of packages and multiple versions of them.  This means that Qi could be
used as the main package manager or complement the existing one.

Qi offers a friendly command line interface, a global configuration
file, a simple recipe layout to deploy software packages; also works
with binary packages in parallel, speeding up installations and packages
in production.  The format used for packages is a simplified but safe
POSIX pax archive compressed with lzip.

Qi is a modern (POSIX-compliant) shell script released under the
terms of the GNU General Public License.  There are only two major
dependencies for the magic: graft(1) and tarlz(1), the rest is expected
to be found in any Unix-like system.

@node Invoking qi
@chapter Invoking qi
@cindex invocation

This chapter describes the synopsis and command line options for
invoke Qi.

@example
Usage: qi [@var{OPTION}]... [@var{FILE}]...
@end example

@noindent
One mandatory option specifies the operation that @samp{qi} should
perform, other options are meant to detail how this operation should be
performed.

@noindent
qi supports the following options to operate:

@table @code
@item -b
Build package using recipe names.

@item -c
Create .tlz package from directory.

@item -d
Delete packages.

@item -i
Install packages.

@item -o
Resolve build order through .order files.

@item -u
Update packages (implies -i, -d and -p options).

@item -w
Warn about files that will be linked.

@item -x
Extract a package for debugging purposes.
@end table

@noindent
There are common options between modes:

@table @code
@item -N
Do not read the configuration file.

This will ignore any value in the qirc file.

@item -P <DIR>
Package directory for installations.

This option sets @samp{$@{packagedir@}}.

Only valid for -i, -d, or -u options.

@item -f
Force option.

This option can force the build of a recipe, or force the update of a
pre-existing package.

Only valid for -b, -u options.

@item -t <DIR>
Target directory for symbolic links.

This option sets @samp{$@{targetdir@}}.

Only valid for -i, -d, or -u options.

@item -k
Keep (don't delete) @samp{$@{srcdir@}} or @samp{$@{destdir@}} in build
mode, keep (don't delete) package directory in delete mode.

Only valid for -b, -d or -u options.

@item -p
Prune conflicts on package installations.

This option may proceed with the package installation if one or more
conflicts occur.

@item -r /rootdir
Use the fully qualified named directory as the root directory for all qi
operations.  The target directory and package directory will be relative
to the specified directory, including the log file for graft.

@item -v
Be verbose (a 2nd -v gives more).
@end table

@noindent
Options for build mode (-b):

@table @code
@item -O <DIR>
Where the packages produced are written.

This option sets @samp{$@{outdir@}}.

@item -W <DIR>
Where archives, patches, and recipes are expected.

This option sets @samp{$@{worktree@}}.

@item -Z <DIR>
Where (compressed) sources will be found.

This option sets @samp{$@{tardir@}}.

@item -a
Architecture to use.

Default value is obtained via uname(1) as @samp{uname -m}.

@item -j
Parallel jobs for the compiler.

If not specified, default sets to 1.

@item -1
Increment release number (@samp{$@{release@}} + 1).

It will be omitted if the -n option is being used.

@item -n
Don't create a .tlz package.

@item -S
Selects the option to skip completed recipes.

This means, in interactive mode, when the dialog
to summarize recipes is shown.
@end table

@noindent
Informative options:

@table @code
@item -L
Print default directory locations.

This will print the target directory, package directory, working tree,
the directory for tarballs, and the output directory for the packages
produced.

@item -h
Display the help describing the options and then exit.

@item -V
Print the version number and license information.
The version number should be included in all bug reports.
@end table

@noindent
Expected non-option arguments are package directories and regular files:
recipes or files ending in .tlz, .order.  When FILE is -, qi can read from
the standard input.  See examples in @ref{Packages}.


@node The qirc file
@chapter The qirc file
@cindex configuration file

The global @file{qirc} file offers a way to define variables and tools
(such as a download manager) for default use.  This file is used by qi
at runtime, e.g., to build, install, remove or upgrade packages.

@noindent
It has the following rules:

@itemize @bullet
@item Variables must be declared as @samp{name=value}.

@item Declaration of values should only take one line, no line break.

@item For security reasons, assignments like @samp{name=$var} are only
interpreted as literal.
@end itemize

@noindent
The command line options related to the package directory and target
directory plus some of the options used for the build mode can override
some values in @file{qirc}.  See @ref{Invoking qi}.

@noindent
The order in which qi looks for this file is:

@enumerate
@item
@env{$@{HOME@}/.qirc}
@- Effective user.

@item
@samp{$@{sysconfdir@}/qirc}
@- System-wide.
@end enumerate

If you intend to run qi as effective user, the file
@samp{$@{sysconfdir@}/qirc} could be copied to @env{$@{HOME@}/.qirc}
setting the paths for @samp{$@{packagedir@}} and @samp{$@{targetdir@}}
according to the @env{$HOME}.


@node Packages
@chapter Packages
@cindex managing packages

A package is a suite of programs usually distributed in binary form
which may also contain manual pages, documentation, or any other file
associated to a specific software.

The package format used by qi is a simplified POSIX pax archive
compressed with lzip.  The file extension for packages is @samp{.tlz}.

@noindent
Both package installation and package de-installation are managed using
two important (internal) variables: @samp{$@{packagedir@}} and
@samp{$@{targetdir@}}, these values can be changed in the
configuration file or via options.

@samp{$@{packagedir@}} is a common directory tree where the package
contents will be decompressed (will reside).

@samp{$@{targetdir@}} is a target directory where the links will be
made by graft(1) taking @samp{$@{packagedir@}/package_name} into account.

@noindent
Packages are installed in self-contained directory trees and symbolic
links from a common area are made to the package files.  This allows
multiple versions of the same package to coexist on the same system.

@section Package conflicts
@cindex package conflicts

All the links to install or remove a package are handled by graft(1).
Since multiple packages can be installed or removed at the same time,
certain conflicts may arise between the packages.

@noindent
graft@footnote{The official guide for Graft can be found at
@url{http://peters.gormand.com.au/Home/tools/graft/graft.html}.}
defines a CONFLICT as one of the following conditions:

@itemize @bullet
@item
If the package object is a directory and the target object exists but is
not a directory.

@item
If the package object is not a directory and the target object exists
and is not a symbolic link.

@item
If the package object is not a directory and the target object exists
and is a symbolic link to something other than the package object.
@end itemize

@noindent
The default behavior of qi for an incoming package is to ABORT if a
conflict arises.  When a package is going to be deleted, qi tells to
graft(1) to remove those parts that are not in conflict, leaving the
links to the belonging package.  This behavior can be forced if the
-p option is given.

@section Installing packages
@cindex package installation

To install a single package, simply type:

@example
qi -i coreutils-8.30-i586+1.tlz
@end example

@noindent
To install multiple packages at once, type:

@example
qi -i gcc-8.3.0-i586+1.tlz rafaela-2.2-i586+1.tlz ...
@end example

@noindent
Warn about the files that will be linked:

@example
qi -w bash-5.0-i586+1.tlz
@end example

This is to verify the content of a package before installing it.

@noindent
See the process of an installation (very verbose):

@example
qi -i -v mariana-3.0-i586+1.tlz
@end example

A second -v gives more.

@noindent
Installing package in a different location:

@example
qi -r /media/floppy -i lzip-1.21-i586+1.tlz
@end example

The -r option assumes @samp{$@{targetdir@}} and @samp{$@{packagedir@}}.
See:

@example
qi -r /home/selk -P /pkgs -t / -i lzip-1.21-i586+1.tlz
@end example

In this case the content of "lzip-1.21-i586+1.tlz" will be decompressed
into @samp{/home/selk/pkgs/lzip-1.21-i586+1}.  Assuming that the main
binary for lzip is under @samp{/home/selk/pkgs/lzip-1.21-i586+1/usr/bin/}
the target for "usr/bin" will be created at @samp{/home/selk}.  Considering
that you have exported the @env{PATH} as @samp{$@{HOME@}/usr/bin}, now the
system is able to see the recent lzip.

@noindent
Installing from a list of packages using standard input:

@example
cat FILELIST.txt | qi -i -
@end example

The list of packages must contain full path names to be passed in the
installation, e.g.:
/var/cache/qi/packages/x86_64/devel/tcl-8.6.9-x86_64+1.tlz
/var/cache/qi/packages/x86_64/devel/tk-8.6.9.1-x86_64+1.tlz
/var/cache/qi/packages/x86_64/devel/vala-0.42.3-x86_64+1.tlz

@section Removing packages
@cindex package de-installation

To remove a package, simply type:

@example
qi -d xz-5.2.4-i586+1.tlz
@end example

@noindent
Delete mode will match the package name using @samp{$@{packagedir@}} as
prefix.  For example, if the value of @samp{$@{packagedir@}} is set to
/usr/local/pkgs, this will be equal to:

@example
qi -d /usr/local/pkgs/xz-5.2.4-i586+1
@end example

@noindent
Detailed output (very verbose):

@example
qi -d -v /usr/local/pkgs/xz-5.2.4-i586+1
@end example

A second -v gives more.

@noindent
By default the delete mode does not preserve a package directory after
removing its links from @samp{$@{targetdir@}}, but this behavior can be
changed if the -k option is passed:

@example
qi -d -k /usr/local/pkgs/lzip-1.21-i586+1
@end example

This means that the links to the package can be reactivated, later:

@example
cd /usr/local/pkgs && graft -i lzip-1.21-i586+1
@end example

@noindent
Removing package from a different location:

@example
qi -r /home/cthulhu -P /pkgs -t / -d xz-5.2.4-i586+1
@end example

@noindent
Removing a package using standard input:

@example
echo "vala-0.42.3-x86_64+1" | qi -d -
@end example

This will match with the package directory.

@section Upgrading packages
@cindex package upgrade

The upgrade mode inherits the properties of the installation and removal
process.  To make sure that a package is updated, the package is installed
in a temporary directory taking @samp{$@{packagedir@}} into account.  Once
the incoming package is pre-installed, qi can proceed to search and delete
packages that have the same name (considered as previous ones).  Finally,
the package is re-installed at its final location and the temporary
directory is removed.

@noindent
To upgrade a package, just type:

@example
qi -u gcc-9.0.1-i586+1.tlz
@end example

This will proceed to update "gcc-9.0.1-i586+1" removing other versions
of "gcc" (if any).

@noindent
If you want to keep the package directories of versions found during the
upgrade process, just pass:

@example
qi -u -k gcc-9.0.1-i586+1.tlz
@end example

@noindent
To see the upgrade process (very verbose):

@example
qi -u -v gcc-9.0.1-i586+1.tlz
@end example

A second -v gives more.

@noindent
To force the upgrade of an existing package:

@example
qi -u -f gcc-9.0.1-i586+1.tlz
@end example

@subsection Package blacklist
@cindex package blacklist

To implement general package facilities, either to install, remove or
maintain the hierarchy of packages in a clean manner, qi makes use of the
pruning operation via graft(1):

There is a risk if those are crucial packages for the proper functioning
of the system, because it implies the deactivation of symbolic from the
target directory, @emph{especially} when transitioning an incoming package
into its final location during upgrade.

@noindent
A blacklist of package names has been devised for the case where
a user decides to upgrade all packages in the system, or
just the crucial ones, such as the C library.

The blacklist is related to the upgrade mode only, consists in installing
a package instead of updating it or removing previous versions of it;
the content of the package will be updated over the existing content at
@samp{$@{packagedir@}}, while the existing links from
@samp{$@{targetdir@}} will be preserved.  A pruning of links will be
carried out in order to re-link possible differences with the recent
content, this helps to avoid leaving dead links in the target directory.

@noindent
Since the upgrade mode is also used to install a new package, the mechanism
for blacklist is to install a declared package if it does not already
exist.  If it already exists, it is verified that the binary package is
newer than the package directory in order to perform an update.

Package names for the blacklist can be set from the configuration file.


@node Recipes
@chapter Recipes
@cindex recipes

A recipe is a file telling qi what to do.  Most often, the recipe tells
qi how to build a binary package from a source tarball.

A recipe has two parts: a list of variable definitions and a list of
sections.  By convention, the syntax of a section is:

@example
section_name()
@{
    section lines
@}
@end example

The section name is followed by parentheses, one newline and an opening
brace.  The line finishing the section contains just a closing brace.
The section names or the function names currently recognized are
@samp{build}.

The @samp{build} section is an augmented shell script.  This is the main
section (or @strong{shell function}) which contains the instructions to
build and produce a package.

@section Variables
@cindex variables

A "variable" is a @strong{shell variable} defined either in @file{qirc}
or in a recipe to represent a string of text, called the variable's
"value".  These values are substituted by explicit request in the
definitions of other variables or in calls to external commands.

Variables can represent lists of file names, options to pass to
compilers, programs to run, directories to look in for source files,
directories to write output to, or anything else you can imagine.

Definitions of variables in qi have four levels of precedence.
Options which define variables from the command-line override those
specified in the @file{qirc} file, while variables defined in the recipe
override those specified in @file{qirc}, taking priority over those
variables set by command-line options.  Finally, the variables have
default values if they are not defined anywhere.

Options that set variables through the command-line can only reference
variables defined in @file{qirc} and variables with default values.

Definitions of variables in @file{qirc} can only reference variables
previously defined in @file{qirc} and variables with default values.

Definitions of variables in the recipe can only reference variables
set by the command-line, variables previously defined in the recipe,
variables defined in @file{qirc}, and variables with default values.

@section Special variables
@cindex special variables

There are variables which can only be set using the command line options or
via @file{qirc}, there are other special variables which can be defined or
redefined in a recipe.  See the following definitions:

@samp{outdir} is the directory where the packages produced are written.
This variable can not be redefined in the recipe.  Default sets to
@samp{/var/cache/qi/packages}.

@samp{worktree} is the working tree where archives, patches, and recipes
are expected.  This variable can not be redefined in the recipe.  Default
sets to @samp{/usr/src/qi}.

@samp{tardir} is defined in the recipe to the directory where the tarball
containing the source can be found.  The full name of the tarball is
composed as @samp{$@{tardir@}/$tarname}.  Its value is available in the
recipe as @samp{$@{tardir@}}; a value of . for @samp{tardir} sets it to
the value of CWD (Current Working Directory), this is where the recipe
lives.

@samp{arch} is the architecture to compose the package name.  Its value is
available in the recipe as @samp{$@{arch@}}.  Default value is the output
of @samp{uname -m}.

@samp{jobs} is the number of parallel jobs to pass to the compiler.  Its
value is available in the recipe as @samp{$@{jobs@}}.  The default value
is 1.

The two variables @samp{$@{srcdir@}} and @samp{$@{destdir@}} can be
set in the recipe, as any other variable, but if they are not, qi uses
default values for them when building a package.

@samp{srcdir} contains the source code to be compiled, and defaults to
@samp{$@{program@}-$@{version@}}.  @samp{destdir} is the place where the
built package will be installed, and defaults to
@samp{$@{TMPDIR@}/package-$@{program@}}.

If @samp{pkgname} is left undefined, the special variable @samp{program}
is assigned by default.  If @samp{pkgversion} is left undefined, the
special variable @samp{version} is assigned by default.

@samp{pkgname} and @samp{pkgversion} along with: @samp{version}, @samp{arch},
and @samp{release} are used to produce the name of the package in the form:
@samp{$@{pkgname@}-$@{pkgversion@}-$@{arch@}+$@{release@}.tlz}

A special variable called @samp{replace} can be used to declare package
names that will be replaced at the time of installation.

@noindent
A typical recipe contains the following variables:

@itemize @bullet
@item @samp{program}: software name.

It matches the source name.  It is also used to compose the name of the
package if @samp{$@{pkgname@}} is not specified.

@item @samp{version}: software version.

It matches the source name.  It is also used to compose the version of the
package if @samp{$@{pkgversion@}} is not specified.

@item @samp{arch}: software architecture.

It is used to compose the architecture of the package in which it is
build.

@item @samp{release}: release number.

This is used to reflect the release number of the package.  It is
recommended to increase this number after any significant change in
the recipe or post-install script.
@end itemize

@noindent
Obtaining sources over the network must be declared in the recipe using
the @samp{fetch} variable.  Use double quotes for separated values.

The variables @samp{netget} and @samp{rsync} can be defined in @file{qirc}
to establish a network downloader in order to get the sources.  If they
are not defined, qi uses default values:

@samp{netget} is the general network downloader tool, defaults sets to
@samp{wget -c -w1 -t3 --no-check-certificate}.

@samp{rsync} is the network tool for sources containing the prefix for
the RSYNC protocol, default sets to
@samp{rsync -v -a -L -z -i --progress}.

The variable @samp{description} is used to print the package description
when a package is installed.

A description has two parts: a brief description, and a long description.
By convention, the syntax of @samp{description} is:

@example
description="
Brief description.

Long description.
"
@end example

The first line of the value represented is a brief description of the
software (called "blurb").  A blank line separates the @emph{brief
description} from the @emph{long description}, which should contain a more
descriptive description of the software.

@noindent
An example looks like:

@example
description="
The GNU core utilities.

The GNU core utilities are the basic file, shell and text manipulation
utilities of the GNU operating system.  These are the core utilities
which are expected to exist on every operating system.
"
@end example

Please consider a length limit of 78 characters as maximum, because the same
one would be used on the meta file creation.  See
@ref{Recipes, The meta file} section.

The @samp{homepage} variable is used to declare the main site or home page:

@example
homepage=http://www.gnu.org/software/gcc
@end example

The variable @samp{license} is used for license information@footnote{
The proposal for @samp{license} was made by Richard M. Stallman at
@url{http://lists.gnu.org/archive/html/gnu-linux-libre/2016-05/msg00003.html}.}.
Some code in the program can be covered by license A, license B, or
license C.  For "separate licensing" or "heterogeneous licensing", we
suggest using @strong{|} for a disjunction, @strong{&} for a conjunction
(if that ever happens in a significant way), and comma for heterogeneous
licensing.  Comma would have lower precedence, plus added special terms.

@example
license="LGPL, GPL | Artistic + added permission"
@end example

@section Writing recipes
@cindex writing recipes

Originally, qi was designed for the version 3 of Dragora GNU/Linux (this
does not mean that you can't use it in another distribution, just that
if you do you will need to test it for your selves).  To aid this here
are some references to well written recipes:

@noindent
@url{http://git.savannah.nongnu.org/cgit/dragora.git/tree/recipes}.
@url{http://notabug.org/dragora/dragora/src/master/recipes}.

You can also check the "doc" directory in the distribution sources of qi
for some examples.

@section Building packages
@cindex package build

A recipe is any valid regular file.  Qi sets priorities for reading a
recipe, the order in which qi looks for a recipe is:

@enumerate
@item
Current working directory.

@item
If the specified path name does not contain "recipe" as the last
component.  Qi will complete it by adding "recipe" to the path name.

@item
If the recipe is not in the current working directory, it will be
searched under @samp{$@{worktree@}/recipes}.  The last component will be
completed adding "recipe" to the specified path name.
@end enumerate

@noindent
To build a single package, type:

@example
qi -b x-apps/xterm
@end example

@noindent
Multiple jobs can be passed to the compiler to speed up the build process:

@example
qi -b -j3 x-apps/xterm
@end example

@noindent
Update or install the package produced (if it is not already installed)
when finish:

@example
qi -b -j3 -u x-apps/xterm
@end example

@noindent
Only process a recipe but do not create the binary package:

@example
qi -b -n dict/aspell
@end example

The options -i or -u have no effect when -n is given.

@noindent
This can be useful to inspect the build process of recipe:

qi -b -k -n dict/aspell 2>&1 | tee aspell-buildlog.txt

The -k option could preserve the source directory and the destination
directory for later inspection.  A log file of the build process will be
created redirecting both, standard error and standard output to tee(1).

@section Variables from the environment
@cindex environment variables

Qi has environment variables which can be used at build time:

The variable @env{TMPDIR} sets the temporary directory for sources, which is
used for package extractions (see @ref{Examining packages}) and is
prepended to the value of @samp{$@{srcdir@}} and @samp{$@{destdir@}} in
build mode.  By convention its default value is equal to
@samp{/usr/src/qi/build}.

The variables @env{QICFLAGS}, @env{QICXXFLAGS}, and @env{QILDFLAGS} have
no effect by default.  The environment variables such as @env{CFLAGS},
@env{CXXFLAGS}, and @env{LDFLAGS} are unset at compile time:

@noindent
Recommended practice is to set variables in the command line of
@samp{configure} or @emph{make(1)} instead of exporting to the
environment.  As follows:

@quotation
Variables not defined in a site shell script can be set in the environment
passed to configure.  However, some packages may run configure again
during the build, and the customized values of these variables may be
lost.  In order to avoid this problem, you should set them in the
configure command line, using @samp{VAR=value}.  For example:

@code{./configure CC=/usr/local2/bin/gcc}

@url{http://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Defining-Variables.html}
@end quotation

@quotation
Indeed, while configure can notice the definition of CC in
@samp{./configure CC=bizarre-cc}, it is impossible to notice it in
@samp{CC=bizarre-cc ./configure}, which, unfortunately, is what most
users do.

[...]

configure: error: changes in the environment can compromise the build.

@url{http://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html}
@end quotation

@quotation
It is not wise for makefiles to depend for their functioning on
environment variables set up outside their control, since this would cause
different users to get different results from the same makefile.  This is
against the whole purpose of most makefiles.

@url{http://gnu.org/software/make/manual/make.html#Environment}
@end quotation

@section The meta file
@cindex the meta file

The "meta file" is a regular file created during the build mode, it
contains information about the package such as package name, package
version, architecture, release, fetch address, description, and other
minor data extracted from processed recipes.  The name of the file is
generated as @samp{$@{full_pkgname@}.tlz.txt}, and its purpose is to
reflect essential information to the user without having to look inside
the package content.  The file format is also intended to be imported
from other scripts.

The content of a meta file looks like:

@example
#
# The Bourne Again SHell.
#
# Bash is an sh-compatible shell that incorporates useful features from
# the Korn shell (ksh) and C shell (csh).  It is intended to conform to
# the IEEE POSIX P1003.2/ISO 9945.2 shell and tools standard.
#
# It offers functional improvements over sh for both programming and
# interactive use.
#

QICFLAGS="-g0 -Os -mtune=generic -pipe"
QICXXFLAGS="-g0 -Os -mtune=generic -pipe"
QILDFLAGS="-s"
pkgname=bash
pkgversion=5.0
arch=x86_64
release=1
blurb="The Bourne Again SHell."
homepage="http://www.gnu.org/software/bash"
license="GPLv3+"
fetch="ftp://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz"
replace=""
@end example

Package descriptions are extracted from the variable @samp{description}
where each line is interpreted literally and pre-formatted to fit in
(exactly) @strong{80 columns}, plus the character @samp{#} and a space
is prefixed to every line.

@noindent
In addition to the Special variables, there are implicit variables such as
@samp{blurb}:

The @samp{blurb} variable is related to the special variable
@samp{description}.  Its value is composed using the first (substantial)
line of @samp{description}, mentioned as the "brief description".


@node Order files
@chapter Order files
@cindex handling build order

The order mode has the purpose of resolving the build order through
.order files.  An order file contains a list of recipe names, by default
does not perform any action other than to print a resolved list in
descending order.  For example, if @strong{a} depends on @strong{b} and
@strong{c}, and @strong{c} depends on @strong{b} as well, the file might
look like:

@example
a: c b
b:
c: b
@end example

Each letter represents a recipe name, complete dependencies for
the first recipe name are listed in descending order, which is
printed from right to left, and removed from left to right:

@sc{Output}

@example
b
c
a
@end example

Blank lines, colons and parentheses are simply ignored.  Comment lines
beginning with @samp{#} are allowed.

@noindent
An order file could be used to build a series of packages, for example,
if the content is:

@example
# Image handling libraries

libs/libjpeg-turbo: devel/nasm
x-libs/jasper: libs/libjpeg-turbo
libs/tiff: libs/libjpeg-turbo
@end example

To proceed with each recipe, we can type:

@example
qi -o imglibs.order | qi -b -i -
@end example

The output of @samp{qi -o imglibs.order} tells to qi in which order it
should build the recipes:

@example
devel/nasm
libs/libjpeg-turbo
x-libs/jasper
libs/tiff
@end example


@node Creating packages
@chapter Creating packages
@cindex package creation

The "creation mode" is an internal function of qi to make new Qi compatible
compatible packages, the creation mode is selected by the -c option.
A package is produced using the contents of the Current Directory, and
the package file is written out.

@example
Usage: qi -c [@var{OUTPUT/packagename.tlz}]...
@end example

The argument for the file name to be written must contain a fully
qualified named directory as the output directory where the package
produced will be written.  The file name should be composed using the
full name: name-version-architecture+release.tlz

@sc{Example}

@example
cd /usr/local/pkgs
cd claws-mail-3.17.1-x86_64+1
qi -c /var/cache/qi/packages/x86_64/local/claws-mail-3.17.1-x86_64+1.tlz
@end example

In this case, the package "claws-mail-3.17.1-x86_64+1.tlz" will be written
into @samp{/var/cache/qi/packages/x86_64/local/}.

@noindent
All packages produced are complemented by a checksum file (.sha256).


@node Examining packages
@chapter Examining packages
@cindex package examination

The "extraction mode" serves to examine binary packages for debugging
purposes. The extraction mode is selected by the -x option.  It
decompresses a package into a single directory, verifying its integrity
and preserving its properties.

@example
Usage: qi -x [@var{packagename.tlz}]...
@end example

@sc{Example}

@example
qi -x mksh-R56c-x86_64+1.tlz
@end example

This action will put the content of "mksh-R56c-x86_64+1.tlz" into a
single directory, this will be a private directory for the user who

requested the action, creation mode will be equal to @strong{u=rwx,g=,o=
(0700)}.  The package content will reside on this location, default
mask to deploy the content will be equal to
@strong{u=rwx,g=rwx,o=rwx (0000)}.

@noindent
The creation of the custom directory is influenced by the value of the
@env{TMPDIR} variable.


@node Exit status
@chapter Exit status
@cindex exit codes

All the exit codes are described in this chapter.

@table @samp
@item 0
Successful completion (no errors).

@item 1
Minor common errors:

@itemize @minus
@item Help usage on illegal options or required arguments.

@item Program needed by qi (prerequisite) is not available.
@end itemize

@item 2
Command execution error:

This code is used to return the evaluation of external commands and shell
arguments in case of error.

@item 3
Integrity check error for compressed files.

Compressed files means:

@itemize @minus
@item Tarball files from tar(1).
Supported extensions: .tar, .tar.gz, .tgz, .tar.Z, .tar.bz2, .tbz2, .tbz,
.tar.xz, .txz

@item Tarball files from tarlz(1).
Supported extensions: .tar.lz, .tlz

@item Zip files from unzip(1).
Supported extensions: .zip, .ZIP

@item Gzip files from gzip(1).
Supported extensions: .gz, .Z

@item Bzip2 files from bzip2(1).
Supported extensions: .bz2

@item Lzip files from lzip(1).
Supported extensions: .lz

@item Xz files from xz(1).
Supported extensions: .xz
@end itemize

@item 4
File empty, not regular, or expected.

Commonly, it is expected:

@itemize @minus
@item An argument for the mode of operation.

@item A readable file or directory.

@item A binary package (.tlz).

@item A valid recipe.

@item An order file (.order).

@item A protocol supported by the network downloader tool.

@item A checksum file (.sha256).
@end itemize

@item 5
Empty or not defined variable:

This code is used to report empty or undefined variables; usually,
variables coming from a recipe or assigned arrays that are tested.

@item 6
Package already installed:

The package directory for an incoming .tlz package already exists.

@item 10
Network manager error:

This code is used if the network downloader tool fails for some reason.
@end table


@node Index
@unnumbered Index

@printindex cp

@bye

