doc/manual.txt: multiple improvements and tweaks.

This commit is contained in:
Juan RP 2013-12-31 07:42:58 +01:00
parent 7f821b3682
commit 1594c3e48e
1 changed files with 229 additions and 189 deletions

View File

@ -1,3 +1,5 @@
// vim: set syntax=asciidoc:
The XBPS source packages manual The XBPS source packages manual
=============================== ===============================
Juan RP <xtraeme@gmail.com> Juan RP <xtraeme@gmail.com>
@ -8,7 +10,7 @@ Juan RP <xtraeme@gmail.com>
:website: http://www.voidlinux.eu :website: http://www.voidlinux.eu
This article contains an exhaustive manual of how to create new source This article contains an exhaustive manual of how to create new source
packages for XBPS, the package manager of the *Void Linux distribution*. packages for XBPS, the `Void Linux` native packaging system.
Introduction Introduction
------------ ------------
@ -81,11 +83,11 @@ Building a package consist of the following phases:
*fetch*:: *fetch*::
This phase downloads required sources for a `source package`, as defined by This phase downloads required sources for a `source package`, as defined by
the `distfiles` variable or `do_fetch()` function. the `distfiles` variable or `do_fetch()` function.
*extract*:: *extract*::
This phase extracts the `distfiles` files into `$wrksrc` or executes the `do_extract()` This phase extracts the `distfiles` files into `$wrksrc` or executes the `do_extract()`
function, which is the directory to be used to compile the `source package`. function, which is the directory to be used to compile the `source package`.
*configure*:: *configure*::
This phase executes the `configuration` of a `source package`, i.e `GNU configure scripts`. This phase executes the `configuration` of a `source package`, i.e `GNU configure scripts`.
@ -95,7 +97,7 @@ Building a package consist of the following phases:
*install-destdir*:: *install-destdir*::
This phase installs the `package files` into a `fake destdir`, via `make install` or This phase installs the `package files` into a `fake destdir`, via `make install` or
any other compatible method. any other compatible method.
*build-pkg*:: *build-pkg*::
This phase builds the `binary packages` with files stored in the `package destdir`. This phase builds the `binary packages` with files stored in the `package destdir`.
@ -111,28 +113,28 @@ The following functions are defined by `xbps-src` and can be used on any templat
*vinstall()*:: *vinstall()*::
`vinstall <file> <mode> <targetdir> [<name>]` `vinstall <file> <mode> <targetdir> [<name>]`
Installs `file` with the specified `mode` into `targetdir` in `$DESTDIR` Installs `file` with the specified `mode` into `targetdir` in `$DESTDIR`
(if called from a `source section`) or `$PKGDESTDIR` (if called from a `package section`). (if called from a `source section`) or `$PKGDESTDIR` (if called from a `package section`).
The optional 4th argument can be used to change the `file name`. The optional 4th argument can be used to change the `file name`.
*vcopy()*:: *vcopy()*::
`vcopy <pattern> <targetdir>` `vcopy <pattern> <targetdir>`
Copies resursively all files in `pattern` to `targetdir` on `$DESTDIR` Copies resursively all files in `pattern` to `targetdir` on `$DESTDIR`
(if called from a `source section`) or `$PKGDESTDIR` (if called from a `package section`). (if called from a `source section`) or `$PKGDESTDIR` (if called from a `package section`).
*vmove()*:: *vmove()*::
`vmove <pattern>` `vmove <pattern>`
Moves `pattern` to the specified directory in `$DESTDIR` Moves `pattern` to the specified directory in `$DESTDIR`
(if called from a `source section`) or `$PKGDESTDIR` (if called from a `package section`). (if called from a `source section`) or `$PKGDESTDIR` (if called from a `package section`).
*vmkdir()*:: *vmkdir()*::
`vmkdir <directory> [<mode>]` `vmkdir <directory> [<mode>]`
Creates a directory in `$DESTDIR` (if called from a `source section`) or Creates a directory in `$DESTDIR` (if called from a `source section`) or
$PKGDESTDIR` (if called from a `package section`). The 2nd optional argument `$PKGDESTDIR` (if called from a `package section`). The 2nd optional argument
sets the mode of the directory. sets the mode of the directory.
NOTE: shell wildcards must be properly quoted. NOTE: shell wildcards must be properly quoted.
@ -145,7 +147,7 @@ The following variables are defined by `xbps-src` and can be used on any templat
*sourcepkg*:: *sourcepkg*::
Set to the to main package name, can be used to match the main package Set to the to main package name, can be used to match the main package
rather than additional binary package names. rather than additional binary package names.
*CHROOT_READY*:: *CHROOT_READY*::
True if the target chroot (masterdir) is ready for chroot builds. True if the target chroot (masterdir) is ready for chroot builds.
@ -155,11 +157,11 @@ The following variables are defined by `xbps-src` and can be used on any templat
*DESTDIR*:: *DESTDIR*::
Full path to the fake destdir used by the `source section`, set to Full path to the fake destdir used by the `source section`, set to
`${XBPS_MASTERDIR}/destdir/${sourcepkg}-${version}`. `${XBPS_MASTERDIR}/destdir/${sourcepkg}-${version}`.
*PKGDESTDIR*:: *PKGDESTDIR*::
Full path to the fake destdir used by the `pkg_install()` function in the Full path to the fake destdir used by the `pkg_install()` function in the
`package section`, set to `${XBPS_MASTERDIR}/destdir/pkg-${pkgname}-${version}`. `package section`, set to `${XBPS_MASTERDIR}/destdir/pkg-${pkgname}-${version}`.
*XBPS_MACHINE*:: *XBPS_MACHINE*::
The machine architecture as returned by `uname -m`. The machine architecture as returned by `uname -m`.
@ -185,7 +187,7 @@ The list of mandatory variables in the `source section`:
*license*:: *license*::
A string matching any license file available in `/usr/share/licenses`. A string matching any license file available in `/usr/share/licenses`.
Multiple licenses should be separated by commas, i.e `GPL-3, LGPL-2.1`. Multiple licenses should be separated by commas, i.e `GPL-3, LGPL-2.1`.
*maintainer*:: *maintainer*::
A string in the form of `name <user@domain>`. A string in the form of `name <user@domain>`.
@ -195,136 +197,137 @@ The list of mandatory variables in the `source section`:
*revision*:: *revision*::
A number that must be set to 1 when the `source package` is created, or A number that must be set to 1 when the `source package` is created, or
updated to a new `upstream version`. This should only be increased when updated to a new `upstream version`. This should only be increased when
the generated `binary packages` have been modified. the generated `binary packages` have been modified.
*short_desc*:: *short_desc*::
A string with a brief description for this package. Max 72 chars. A string with a brief description for this package. Max 72 chars.
*version*:: *version*::
A string with the package version. Must not contain dashes and at least A string with the package version. Must not contain dashes and at least
one digit is required. one digit is required.
Optional variables Optional variables
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
*hostmakedepends*:: *hostmakedepends*::
The list of `host` dependencies required to build the package. Dependencies The list of `host` dependencies required to build the package. Dependencies
can be specified with the following version comparators: `<`, `>`, `<=`, `>=` can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
or `foo-1.0_1` to match an exact version. If version comparator is not or `foo-1.0_1` to match an exact version. If version comparator is not
defined (just a package name), the version comparator is automatically set to `>=0`. defined (just a package name), the version comparator is automatically set to `>=0`.
Example `hostmakedepends="foo blah<1.0"`. Example `hostmakedepends="foo blah<1.0"`.
*makedepends*:: *makedepends*::
The list of `target` dependencies required to build the package. Dependencies The list of `target` dependencies required to build the package. Dependencies
can be specified with the following version comparators: `<`, `>`, `<=`, `>=` can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
or `foo-1.0_1` to match an exact version. If version comparator is not or `foo-1.0_1` to match an exact version. If version comparator is not
defined (just a package name), the version comparator is automatically set to `>=0`. defined (just a package name), the version comparator is automatically set to `>=0`.
Example `makedepends="foo blah>=1.0"`. Example `makedepends="foo blah>=1.0"`.
*bootstrap*:: *bootstrap*::
If enabled the source package is considered to be part of the `bootstrap` If enabled the source package is considered to be part of the `bootstrap`
process and required to be able to build packages in the chroot. Only a process and required to be able to build packages in the chroot. Only a
small number of packages must set this property. small number of packages must set this property.
*distfiles*:: *distfiles*::
The full URL to the `upstream` source distribution files. Multiple files The full URL to the `upstream` source distribution files. Multiple files
can be separated by blanks. The files must end in `.tar.lzma`, `.tar.xz`, can be separated by blanks. The files must end in `.tar.lzma`, `.tar.xz`,
`.txz`, `.tar.bz2`, `.tbz`, `.tar.gz`, `.tgz`, `.gz`, `.bz2`, `.tar` or `.txz`, `.tar.bz2`, `.tbz`, `.tar.gz`, `.tgz`, `.gz`, `.bz2`, `.tar` or
`.zip`. Example `distfiles="http://foo.org/foo-1.0.tar.gz"` `.zip`. Example `distfiles="http://foo.org/foo-1.0.tar.gz"`
*checksum*:: *checksum*::
The `sha256` digests matching `${distfiles}`. Multiple files can be The `sha256` digests matching `${distfiles}`. Multiple files can be
separated by blanks. Please note that the order must be the same than separated by blanks. Please note that the order must be the same than
was used in `${distfiles}`. Example `checksum="kkas00xjkjas"` was used in `${distfiles}`. Example `checksum="kkas00xjkjas"`
*long_desc*:: *long_desc*::
A long description of the main package. Max 80 chars per line and must A long description of the main package. Max 80 chars per line and must
not contain the following characters: `&`, `<`, `>`. not contain the following characters: `&`, `<`, `>`.
*wrksrc*:: *wrksrc*::
The directory name where the package sources are extracted, by default The directory name where the package sources are extracted, by default
set to `${pkgname}-${version}`. set to `${pkgname}-${version}`.
*build_wrksrc*:: *build_wrksrc*::
A directory relative to `${wrksrc}` that will be used when building the package. A directory relative to `${wrksrc}` that will be used when building the package.
*create_wrksrc*:: *create_wrksrc*::
Enable it to create the `${wrksrc}` directory. Required if a package Enable it to create the `${wrksrc}` directory. Required if a package
contains multiple `distfiles`. contains multiple `distfiles`.
*only_for_archs*:: *only_for_archs*::
This expects a separated list of architectures where the package can be This expects a separated list of architectures where the package can be
built matching `uname -m` output. Example `only_for_archs="x86_64 armv6l"` built matching `uname -m` output. Example `only_for_archs="x86_64 armv6l"`
*build_style*:: *build_style*::
This specifies the `build method` for a package. Read below to know more This specifies the `build method` for a package. Read below to know more
about the available package `build methods`. If `build_style` is not set, about the available package `build methods`. If `build_style` is not set,
the package must define at least a `do_install()` function, and optionally the package must define at least a `do_install()` function, and optionally
more build phases as such `do_configure()`, `do_build()`, etc. more build phases as such `do_configure()`, `do_build()`, etc.
*create_srcdir*:: *create_srcdir*::
This creates a directory in `${XBPS_SRCDISTDIR}` as such `${pkgname}-${version}` This creates a directory in `${XBPS_SRCDISTDIR}` as such `${pkgname}-${version}`
to store the package sources at the `extract` phase. Required in packages that to store the package sources at the `extract` phase. Required in packages that
use unversioned ${distfiles}`. use unversioned ${distfiles}`.
*configure_script*:: *configure_script*::
The name of the `configure` script to execute at the `configure` phase if The name of the `configure` script to execute at the `configure` phase if
`${build_style}` is set to `configure` or `gnu-configure` build methods. `${build_style}` is set to `configure` or `gnu-configure` build methods.
By default set to `./configure`. By default set to `./configure`.
*configure_args*:: *configure_args*::
The arguments to be passed in to the `configure` script if `${build_style}` The arguments to be passed in to the `configure` script if `${build_style}`
is set to `configure` or `gnu-configure` build methods. By default, prefix is set to `configure` or `gnu-configure` build methods. By default, prefix
must be set to `/usr`. In `gnu-configure` packages, some options are already must be set to `/usr`. In `gnu-configure` packages, some options are already
set by default: `--prefix=/usr --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man --localstatedir=/var`. set by default: `--prefix=/usr --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man --localstatedir=/var`.
*make_cmd*:: *make_cmd*::
The executable to run at the `build` phase if `${build_style}` is set to The executable to run at the `build` phase if `${build_style}` is set to
`configure`, `gnu-configure` or `gnu-makefile` build methods. `configure`, `gnu-configure` or `gnu-makefile` build methods.
By default set to `make`. By default set to `make`.
*make_build_args*:: *make_build_args*::
The arguments to be passed in to `${make_cmd}` at the build phase if The arguments to be passed in to `${make_cmd}` at the build phase if
`${build_style}` is set to `configure`, `gnu-configure` or `gnu_makefile` `${build_style}` is set to `configure`, `gnu-configure` or `gnu_makefile`
build methods. Unset by default. build methods. Unset by default.
*make_install_args*:: *make_install_args*::
The arguments to be passed in to `${make_cmd}` at the `install-destdir` The arguments to be passed in to `${make_cmd}` at the `install-destdir`
phase if `${build_style}` is set to `configure`, `gnu-configure` or phase if `${build_style}` is set to `configure`, `gnu-configure` or
`gnu_makefile` build methods. Unset by default. `gnu_makefile` build methods. By default set to
`PREFIX=/usr DESTDIR=${DESTDIR}`.
*make_build_target*:: *make_build_target*::
The target to be passed in to `${make_cmd}` at the build phase if The target to be passed in to `${make_cmd}` at the build phase if
`${build_style}` is set to `configure`, `gnu-configure` or `gnu_makefile` `${build_style}` is set to `configure`, `gnu-configure` or `gnu_makefile`
build methods. Unset by default (`all` target). build methods. Unset by default (`all` target).
*make_install_target*:: *make_install_target*::
The target to be passed in to `${make_cmd}` at the `install-destdir` phase The target to be passed in to `${make_cmd}` at the `install-destdir` phase
if `${build_style}` is set to `configure`, `gnu-configure` or `gnu_makefile` if `${build_style}` is set to `configure`, `gnu-configure` or `gnu_makefile`
build methods. By default set to `DESTDIR=${DESTDIR} install`. build methods. By default set to `install`.
*patch_args*:: *patch_args*::
The arguments to be passed in to the `patch(1)` command when applying The arguments to be passed in to the `patch(1)` command when applying
patches to the package sources after `do_extract()`. Patches are stored in patches to the package sources after `do_extract()`. Patches are stored in
`srcpkgs/<pkgname>/patches` and must be in `-p0` format. By default set to `-Np0`. `srcpkgs/<pkgname>/patches` and must be in `-p0` format. By default set to `-Np0`.
*disable_parallel_build*:: *disable_parallel_build*::
If set the package won't be built in parallel and `XBPS_MAKEJOBS` has no effect. If set the package won't be built in parallel and `XBPS_MAKEJOBS` has no effect.
*keep_libtool_archives*:: *keep_libtool_archives*::
If enabled the `GNU Libtool` archives won't be removed. By default those If enabled the `GNU Libtool` archives won't be removed. By default those
files are always removed automatically. files are always removed automatically.
*skip_extraction*:: *skip_extraction*::
A list of filenames that should not be extracted in the `extract` phase. A list of filenames that should not be extracted in the `extract` phase.
This must match the basename of any url defined in `${distfiles}`. This must match the basename of any url defined in `${distfiles}`.
Example `skip_extraction="foo-${version}.tar.gz"`. Example `skip_extraction="foo-${version}.tar.gz"`.
*force_debug_pkgs*:: *force_debug_pkgs*::
If enabled binary packages with debugging symbols will be generated If enabled binary packages with debugging symbols will be generated
even if `XBPS_DEBUG_PKGS` is disabled in `xbps-src.conf` or in the even if `XBPS_DEBUG_PKGS` is disabled in `xbps-src.conf` or in the
`command line arguments`. `command line arguments`.
build style scripts build style scripts
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -337,32 +340,35 @@ The current list of available `build_style` scripts is the following:
*cmake*:: *cmake*::
For packages that use the CMake build system, configuration arguments For packages that use the CMake build system, configuration arguments
can be passed in via `configure_args`. can be passed in via `configure_args`.
*configure*:: *configure*::
For packages that use non-GNU configure scripts, at least `--prefix=/usr` For packages that use non-GNU configure scripts, at least `--prefix=/usr`
should be passed in via `configure_args`. should be passed in via `configure_args`.
*gnu-configure*:: *gnu-configure*::
For packages that use GNU configure scripts, additional configuration For packages that use GNU configure scripts, additional configuration
arguments can be passed in via `configure_args`. arguments can be passed in via `configure_args`.
*gnu-makefile*:: *gnu-makefile*::
For packages that use GNU make, build arguments can be passed in via For packages that use GNU make, build arguments can be passed in via
`make_build_args` and install arguments via `make_install_args`. The build `make_build_args` and install arguments via `make_install_args`. The build
target can be overriden via `make_build_target` and the install target target can be overriden via `make_build_target` and the install target
via `make_install_target`.
*meta*:: *meta*::
For `meta-packages`, i.e packages that only install local files or simply For `meta-packages`, i.e packages that only install local files or simply
depend on additional packages. depend on additional packages. This build style does not install
dependencies to the root directory, and only checks if a binary package is
available in repositories.
*perl-ModuleBuild*:: *perl-ModuleBuild*::
For packages that use the Perl For packages that use the Perl
http://search.cpan.org/~leont/Module-Build-0.4202/lib/Module/Build.pm[Module::Build] method. http://search.cpan.org/~leont/Module-Build-0.4202/lib/Module/Build.pm[Module::Build] method.
*perl*:: *perl*::
For packages that use the Perl For packages that use the Perl
http://perldoc.perl.org/ExtUtils/MakeMaker.html[ExtUtils::MakeMaker] build method. http://perldoc.perl.org/ExtUtils/MakeMaker.html[ExtUtils::MakeMaker] build method.
*python-module*:: *python-module*::
For packages that use the Python module build method (setup.py). For packages that use the Python module build method (setup.py).
@ -373,6 +379,9 @@ The current list of available `build_style` scripts is the following:
*waf*:: *waf*::
For packages that use the Python `waf` method with python2. For packages that use the Python `waf` method with python2.
NOTE: if `build_style` is not set, the template must (at least) define a
`do_install()` function and optionally more phases via `do_xxx()` functions.
Functions Functions
~~~~~~~~~ ~~~~~~~~~
The following functions can be defined to change the behavior of how the The following functions can be defined to change the behavior of how the
@ -392,7 +401,7 @@ package is downloaded, compiled and installed.
*do_configure()*:: *do_configure()*::
Actions to execute to configure the package; `${configure_args}` should Actions to execute to configure the package; `${configure_args}` should
still be passed in if it's a GNU configure script. still be passed in if it's a GNU configure script.
*post_configure()*:: *post_configure()*::
Actions to execute after `do_configure()`. Actions to execute after `do_configure()`.
@ -418,41 +427,8 @@ package is downloaded, compiled and installed.
NOTE: A function defined in a template has preference over the same function NOTE: A function defined in a template has preference over the same function
defined by a `build_style` script. defined by a `build_style` script.
Run-time dependencies
~~~~~~~~~~~~~~~~~~~~~
Dependencies for ELF executables or shared libraries are detected
automatically by `xbps-src`, hence run-time dependencies must not be specified
in the *package sections* with the following exceptions:
- ELF binaries using dlopen(3).
- non ELF objects, i.e perl/python/ruby/etc modules.
- Overriding the minimal version specified in the `shlibs` file.
The run-time dependencies for ELF binaries are detected by checking which SONAMEs
use and then the SONAMEs are mapped to a binary package name with a minimal
required version. The `shlibs` file in the `xbps-packages/common` directory
sets up the `SONAME pkgname>=version` mappings.
For example the `foo-1.0_1` package provides the `libfoo.so.1` SONAME and
software requiring this library will link to `libfoo`; the resulting binary
package will have a run-time dependency to `foo>=1.0_1` package as specified in
`common/shlibs`:
-----------------------
# common/shlibs
...
libfoo.so.1 foo-1.0_1
...
-----------------------
- The first field specifies the SONAME.
- The second field specified the package name and minimal version required.
- A third optional field specifies the architecture (rarely used).
Build options Build options
~~~~~~~~~~~~~ -------------
Some packages might be built with different build options to enable/disable Some packages might be built with different build options to enable/disable
additional features; `xbps-src` allows you to do this with some simple tweaks additional features; `xbps-src` allows you to do this with some simple tweaks
to the `template` file. to the `template` file.
@ -467,7 +443,7 @@ The following variables may be set to allow package build options:
*desc_option_<option>*:: *desc_option_<option>*::
Sets the description for the build option `option`. This must match the Sets the description for the build option `option`. This must match the
keyword set in *build_options*. keyword set in *build_options*.
After defining those required variables, you can check for the After defining those required variables, you can check for the
`build_option_<option>` variable to know if it has been set and adapt the source `build_option_<option>` variable to know if it has been set and adapt the source
@ -533,9 +509,69 @@ The build options can also be shown for binary packages via `xbps-query(8)`:
$ xbps-query -R --property=build-options foo $ xbps-query -R --property=build-options foo
-------------------------------------------- --------------------------------------------
Contributing via git Package section
~~~~~~~~~~~~~~~~~~~~ ---------------
Mandatory functions
~~~~~~~~~~~~~~~~~~~
A `package section` needs at least one mandatory function matching the
`$pkgname` of the `source section`: `<pkgname>_package()`. Multiple binary
packages with the same template can be created by adding additional
`<pkg>_package()` functions.
Those `<pkg>_package()` functions are run in alphabetical order, with the
exception of the `<pkgname>_package()` function, which is always the last one.
Optional variables
~~~~~~~~~~~~~~~~~~
*conf_files*::
A list of configuration files the binary package owns; this expects full
paths, and multiple entries can be separated by blanks, i.e:
`conf_files="/etc/foo.conf /etc/foo2.conf"`.
*noarch*::
If set, the binary package is not architecture specific and can be shared
by all supported architectures.
*nonfree*::
If set, the binary package will be put into the *non free* repository.
*nostrip*::
If set, the ELF binaries with debugging symbols won't be stripped. By
default all binaries are stripped.
Run-time dependencies
---------------------
Dependencies for ELF executables or shared libraries are detected
automatically by `xbps-src`, hence run-time dependencies must not be specified
in the *package sections* with the following exceptions:
- ELF binaries using dlopen(3).
- non ELF objects, i.e perl/python/ruby/etc modules.
- Overriding the minimal version specified in the `shlibs` file.
The run-time dependencies for ELF binaries are detected by checking which SONAMEs
use and then the SONAMEs are mapped to a binary package name with a minimal
required version. The `shlibs` file in the `xbps-packages/common` directory
sets up the `SONAME pkgname>=version` mappings.
For example the `foo-1.0_1` package provides the `libfoo.so.1` SONAME and
software requiring this library will link to `libfoo`; the resulting binary
package will have a run-time dependency to `foo>=1.0_1` package as specified in
`common/shlibs`:
-----------------------
# common/shlibs
...
libfoo.so.1 foo-1.0_1
...
-----------------------
- The first field specifies the SONAME.
- The second field specified the package name and minimal version required.
- A third optional field specifies the architecture (rarely used).
Contributing via git
--------------------
You can fork the `xbps-packages` git repository on github and then set up You can fork the `xbps-packages` git repository on github and then set up
a remote to pull in new changes: a remote to pull in new changes:
@ -556,8 +592,12 @@ for more information.
For commit messages please use the following rules: For commit messages please use the following rules:
- If you've imported a new package use `New package: <pkgver>`. - If you've imported a new package use `"New package: <pkgver>"`.
- If you've updated a package use `<pkgname>: updated to <version>`. - If you've updated a package use `"<pkgname>: updated to <version>"`.
- If you've removed a package use `<pkgname>: removed ...`. - If you've removed a package use `"<pkgname>: removed ..."`.
- If you've modified a package use `"<pkgname>: ..."`.
Help
----
If after reading this `manual` you still need some kind of help, please join
us at `#xbps` via IRC at `irc.freenode.net`.