vmware-horizon-client: update distfile URL
[void-pkg.git] / Manual.md
blob25dc4ef7df101edd39337d90ab3d3cf03ebf9b3b
1 # The XBPS source packages manual
3 This article contains an exhaustive manual of how to create new source
4 packages for XBPS, the `Void Linux` native packaging system.
6 *Table of Contents*
8 * The XBPS source packages manual
9         * [Introduction](#Introduction)
10         * [Package build phases](#buildphase)
11         * [Package naming conventions](#namingconventions)
12                 * [Libraries](#libs)
13                 * [Language Modules](#language_modules)
14                 * [Language Bindings](#language_bindings)
15                 * [Programs](#programs)
16         * [Global functions](#global_funcs)
17         * [Global variables](#global_vars)
18         * [Available variables](#available_vars)
19                 * [Mandatory variables](#mandatory_vars)
20                 * [Optional variables](#optional_vars)
21                 * [About the depends variables](#explain_depends)
22         * [Repositories](#repositories)
23                 * [Repositories defined by Branch](#repo_by_branch)
24                 * [Package defined repositories](#pkg_defined_repo)
25         * [Checking for new upstream releases](#updates)
26         * [Handling patches](#patches)
27         * [Build style scripts](#build_scripts)
28         * [Build helper scripts](#build_helper)
29         * [Functions](#functions)
30         * [Build options](#build_options)
31         * [INSTALL and REMOVE files](#install_remove_files)
32         * [INSTALL.msg and REMOVE.msg files](#install_remove_files_msg)
33         * [Creating system accounts/groups at runtime](#runtime_account_creation)
34         * [Writing runit services](#writing_runit_services)
35         * [32bit packages](#32bit_pkgs)
36         * [Subpackages](#pkgs_sub)
37         * [Some package classes](#pkgs_classes)
38                 * [Development packages](#pkgs_development)
39                 * [Data packages](#pkgs_data)
40                 * [Documentation packages](#pkgs_documentation)
41                 * [Python packages](#pkgs_python)
42                 * [Go packages](#pkgs_go)
43                 * [Haskell packages](#pkgs_haskell)
44                 * [Font packages](#pkgs_font)
45         * [Renaming a package](#pkg_rename)
46         * [Removing a package](#pkg_remove)
47         * [XBPS Triggers](#xbps_triggers)
48                 * [appstream-cache](#triggers_appstream_cache)
49                 * [binfmts](#triggers_binfmts)
50                 * [dkms](#triggers_dkms)
51                 * [gconf-schemas](#triggers_gconf_schemas)
52                 * [gdk-pixbuf-loaders](#triggers_gdk_pixbuf_loaders)
53                 * [gio-modules](#triggers_gio_modules)
54                 * [gettings-schemas](#triggers_gsettings_schemas)
55                 * [gtk-icon-cache](#triggers_gtk_icon_cache)
56                 * [gtk-immodules](#triggers_gtk_immodules)
57                 * [gtk-pixbuf-loaders](#triggers_gtk_pixbuf_loaders)
58                 * [gtk3-immodules](#triggers_gtk3_immodules)
59                 * [hwdb.d-dir](#triggers_hwdb.d_dir)
60                 * [info-files](#triggers_info_files)
61                 * [initramfs-regenerate](#triggers_initramfs_regenerate)
62                 * [kernel-hooks](#triggers_kernel_hooks)
63                 * [mimedb](#triggers_mimedb)
64                 * [mkdirs](#triggers_mkdirs)
65                 * [pango-modules](#triggers_pango_module)
66                 * [pycompile](#triggers_pycompile)
67                 * [register-shell](#triggers_register_shell)
68                 * [system-accounts](#triggers_system_accounts)
69                 * [texmf-dist](#triggers_texmf_dist)
70                 * [update-desktopdb](#triggers_update_desktopdb)
71                 * [x11-fonts](#triggers_x11_fonts)
72                 * [xml-catalog](#triggers_xml_catalog)
73         * [Void specific documentation](#documentation)
74         * [Notes](#notes)
75         * [Contributing via git](#contributing)
76         * [Help](#help)
78 <a id="Introduction"></a>
79 ### Introduction
81 The `void-packages` repository contains all the
82 recipes to download, compile and build binary packages for Void Linux.
83 These `source` package files are called `templates`.
85 The `template` files are shell scripts that define `variables` and `functions`
86 to be processed by `xbps-src`, the package builder, to generate binary packages.
87 The shell used by `xbps-src` is GNU bash; `xbps-src` doesn't aim to be
88 compatible with POSIX `sh`.
90 By convention, all templates start with a comment saying that it is a
91 `template file` for a certain package. Most of the lines should be kept under 80
92 columns; variables that list many values can be split into new lines, with the
93 continuation in the next line indented by one space.
95 A simple `template` example is as follows:
97 ```
98 # Template file for 'foo'
99 pkgname=foo
100 version=1.0
101 revision=1
102 build_style=gnu-configure
103 short_desc="A short description max 72 chars"
104 maintainer="name <email>"
105 license="GPL-3.0-or-later"
106 homepage="http://www.foo.org"
107 distfiles="http://www.foo.org/foo-${version}.tar.gz"
108 checksum="fea0a94d4b605894f3e2d5572e3f96e4413bcad3a085aae7367c2cf07908b2ff"
111 The template file contains definitions to download, build and install the
112 package files to a `fake destdir`, and after this a binary package can be
113 generated with the definitions specified on it.
115 Don't worry if anything is not clear as it should be. The reserved `variables`
116 and `functions` will be explained later. This `template` file should be created
117 in a directory matching `$pkgname`, Example: `void-packages/srcpkgs/foo/template`.
119 If everything went fine after running
121     $ ./xbps-src pkg <pkgname>
123 a binary package named `foo-1.0_1.<arch>.xbps` will be generated in the local repository
124 `hostdir/binpkgs`.
126 <a id="buildphase"></a>
127 ### Package build phases
129 Building a package consist of the following phases:
131 - `setup` This phase prepares the environment for building a package.
133 - `fetch` This phase downloads required sources for a `source package`, as defined by
134 the `distfiles` variable or `do_fetch()` function.
136 - `extract` This phase extracts the `distfiles` files into `$wrksrc` or executes the `do_extract()`
137 function, which is the directory to be used to compile the `source package`.
139 - `patch` This phase applies all patches in the patches directory of the package and
140 can be used to perform other operations before configuring the package.
142 - `configure` This phase executes the `configuration` of a `source package`, i.e `GNU configure scripts`.
144 - `build` This phase compiles/prepares the `source files` via `make` or any other compatible method.
146 - `check` This optional phase checks the result of the `build` phase by running the testsuite provided by the package.
147 If the default `do_check` function provided by the build style doesn't do anything, the template should set
148 `make_check_target` and/or `make_check_args` appropriately or define its own `do_check` function. If tests take too long
149 or can't run in all environments, `make_check` should be set to fitting value or
150 `do_check` should be customized to limit testsuite unless `XBPS_CHECK_PKGS` is `full`.
152 - `install` This phase installs the `package files` into the package destdir `<masterdir>/destdir/<pkgname>-<version>`,
153 via `make install` or any other compatible method.
155 - `pkg` This phase builds the `binary packages` with files stored in the
156 `package destdir` and registers them into the local repository.
158 - `clean` This phase cleans up the package (if defined).
160 `xbps-src` supports running just the specified phase, and if it ran
161 successfully, the phase will be skipped later (unless its work directory
162 `${wrksrc}` is removed with `xbps-src clean`).
164 <a id="namingconventions"></a>
165 ### Package naming conventions
167 <a id="libs"></a>
168 #### Libraries
170 Libraries are packages which provide shared objects (\*.so) in /usr/lib.
171 They should be named like their upstream package name with the following
172 exceptions:
174 - The package is a subpackage of a front end application and provides
175 shared objects used by the base package and other third party libraries. In that
176 case it should be prefixed with 'lib'. An exception from that rule is: If an
177 executable is only used for building that package, it moves to the -devel
178 package.
180 Example: wireshark -> subpkg libwireshark
182 Libraries have to be split into two sub packages: `<name>` and `<name>-devel`.
184 - `<name>` should only contain those parts of a package which are needed to run
185 a linked program.
187 - `<name>-devel` should contain all files which are needed to compile a package
188 against this package. If the library is a sub package, its corresponding
189 development package should be named `lib<name>-devel`
191 <a id="language_modules"></a>
192 #### Language Modules
194 Language modules are extensions to script or compiled languages. Those packages
195 do not provide any executables themselves, but can be used by other packages
196 written in the same language.
198 The naming convention to those packages is:
201 <language>-<name>
204 If a package provides both, a module and a executable, it should be split into
205 a package providing the executable named `<name>` and the module named
206 `<language>-<name>`. If a package starts with the languages name itself, the
207 language prefix can be dropped. Short names for languages are no valid substitute
208 for the language prefix.
210 Example: python-pam, perl-URI, python3-pyside2
212 <a id="language_bindings"></a>
213 #### Language Bindings
215 Language Bindings are packages which allow programs or libraries to have
216 extensions or plugins written in a certain language.
218 The naming convention to those packages is:
220 <name>-<language>
223 Example: gimp-python, irssi-perl
225 <a id="programs"></a>
226 #### Programs
228 Programs put executables under /usr/bin (or in very special cases in other
229 .../bin directories)
231 For those packages the upstream packages name should be used. Remember that
232 in contrast to many other distributions, void doesn't lowercase package names.
233 As a rule of thumb, if the tar.gz of a package contains uppercase letter, then
234 the package name should contain them too; if it doesn't, the package name
235 is lowercase.
237 Programs can be split into program packages and library packages. The program
238 package should be named as described above. The library package should be
239 prefixed with "lib" (see section `Libraries`)
241 <a id="global_funcs"></a>
242 ### Global functions
244 The following functions are defined by `xbps-src` and can be used on any template:
246 - *vinstall()* `vinstall <file> <mode> <targetdir> [<name>]`
248         Installs `file` with the specified `mode` into `targetdir` in the pkg `$DESTDIR`.
249         The optional 4th argument can be used to change the `file name`.
251 - *vcopy()* `vcopy <pattern> <targetdir>`
253         Copies recursively all files in `pattern` to `targetdir` in the pkg `$DESTDIR`.
255 - *vmove()* `vmove <pattern>`
257         Moves `pattern` to the specified directory in the pkg `$DESTDIR`.
259 - *vmkdir()* `vmkdir <directory> [<mode>]`
261         Creates a directory in the pkg `$DESTDIR`. The 2nd optional argument sets the mode of the directory.
263 - *vbin()* `vbin <file> [<name>]`
265         Installs `file` into `usr/bin` in the pkg `$DESTDIR` with the
266         permissions 0755. The optional 2nd argument can be used to change
267         the `file name`.
269 - *vman()* `vman <file> [<name>]`
271         Installs `file` as a man page. `vman()` parses the name and
272         determines the section as well as localization. Also transparently
273         converts gzipped (.gz) and bzipped (.bz2) manpages into plaintext.
274         Example mappings:
276         - `foo.1` -> `${DESTDIR}/usr/share/man/man1/foo.1`
277         - `foo.fr.1` -> `${DESTDIR}/usr/share/man/fr/man1/foo.1`
278         - `foo.1p` -> `${DESTDIR}/usr/share/man/man1/foo.1p`
279         - `foo.1.gz` -> `${DESTDIR}/usr/share/man/man1/foo.1`
280         - `foo.1.bz2` -> `${DESTDIR}/usr/share/man/man1/foo.1`
282 - *vdoc()* `vdoc <file> [<name>]`
284         Installs `file` into `usr/share/doc/<pkgname>` in the pkg
285         `$DESTDIR`. The optional 2nd argument can be used to change the
286         `file name`.
288 - *vconf()* `vconf <file> [<name>]`
290         Installs `file` into `etc` in the pkg
291         `$DESTDIR`. The optional 2nd argument can be used to change the
292         `file name`.
294 - *vsconf()* `vsconf <file> [<name>]`
296         Installs `file` into `usr/share/examples/<pkgname>` in the pkg
297         `$DESTDIR`. The optional 2nd argument can be used to change the
298         `file name`.
300 - <a id="vlicense"></a>
301  *vlicense()* `vlicense <file> [<name>]`
303         Installs `file` into `usr/share/licenses/<pkgname>` in the pkg
304         `$DESTDIR`. The optional 2nd argument can be used to change the
305         `file name`. See [license](#var_license) for when to use it.
307 - *vsv()* `vsv <service> [<facility>]`
309         Installs `service` from `${FILESDIR}` to /etc/sv. The service must
310         be a directory containing at least a run script. Note the `supervise`
311         symlink will be created automatically by `vsv` and that the run script
312         is automatically made executable by this function.
313         For further information on how to create a new service directory see
314         [The corresponding section the FAQ](http://smarden.org/runit/faq.html#create).
315         A `log` sub-service will be automatically created if one does not exist in
316         `${FILESDIR}/$service`, containing `exec vlogger -t $service -p $facility`.
317         if a second argument is not specified, the `daemon` facility is used.
318         For more information about `vlogger` and available values for the facility,
319         see [vlogger(8)](https://man.voidlinux.org/vlogger.8).
321 - *vsed()* `vsed -i <file> -e <regex>`
323         Wrapper around sed that checks sha256sum of a file before and after running
324         the sed command to detect cases in which the sed call didn't change anything.
325         Takes any arbitrary amount of files and regexes by calling `-i file` and
326         `-e regex` repeatedly, at least one file and one regex must be specified.
328         Note that vsed will call the sed command for every regex specified against
329         every file specified, in the order that they are given.
331 - *vcompletion()* `<file> <shell> [<command>]`
333         Installs shell completion from `file` for `command`, in the correct location
334         and with the appropriate filename for `shell`. If `command` isn't specified,
335         it will default to `pkgname`. The `shell` argument can be one of `bash`,
336         `fish` or `zsh`.
338 - *vextract()* `[-C <target directory>] [--no-strip-components|--strip-components=<n>] <file>`
340         Extracts `file` to `target directory` with `n` directory components stripped. If
341         `target directory` not specified, defaults to the working directory. If
342         `--strip-components` or `--no-strip-components` is not specified, defaults to
343         `--strip-components=1`.
345 - *vsrcextract()* `[-C <target directory>] [--no-strip-components|--strip-components=<n>] <file>`
347         Extracts `$XBPS_SRCDISTDIR/$pkgname-$version/<file>` to `target directory`
348         with `n` directory components stripped. If `target directory` not specified,
349         defaults to the working directory. If `--strip-components` or `--no-strip-components`
350         is not specified, defaults to `--strip-components=1`.
352         This is useful when used in conjunction with `skip_extraction` and for submodule distfiles.
354 - *vsrccopy()* `<file>... <target>`
356         Copies `file`s from `$XBPS_SRCDISTDIR/$pkgname-$version/` into the `target` directory,
357         creating `target` if it does not exist.
359         This is useful when used in conjunction with `skip_extraction`.
361 > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`.
363 <a id="global_vars"></a>
364 ### Global variables
366 The following variables are defined by `xbps-src` and can be used on any template:
368 - `makejobs` Set to `-jX` if `XBPS_MAKEJOBS` is defined, to allow parallel jobs with `GNU make`.
370 - `sourcepkg`  Set to the to main package name, can be used to match the main package
371 rather than additional binary package names.
373 - `CHROOT_READY`  Set if the target chroot (masterdir) is ready for chroot builds.
375 - `CROSS_BUILD` Set if `xbps-src` is cross compiling a package.
377 - `XBPS_CHECK_PKGS` Set if `xbps-src` is going to run tests for a package.
378 Longer testsuites should only be run in `do_check()` if it is set to `full`.
380 - `DESTDIR` Full path to the fake destdir used by the source pkg, set to
381 `<masterdir>/destdir/${sourcepkg}-${version}`.
383 - `FILESDIR` Full path to the `files` package directory, i.e `srcpkgs/foo/files`.
384 The `files` directory can be used to store additional files to be installed
385 as part of the source package.
387 - `PKGDESTDIR` Full path to the fake destdir used by the `pkg_install()` function in
388 `subpackages`, set to `<masterdir>/destdir/${pkgname}-${version}`.
390 - `XBPS_BUILDDIR` Directory to store the `source code` of the source package being processed,
391 set to `<masterdir>/builddir`. The package `wrksrc` is always stored
392 in this directory such as `${XBPS_BUILDDIR}/${wrksrc}`.
394 - `XBPS_MACHINE` The machine architecture as returned by `xbps-uhelper arch`.
396 - `XBPS_ENDIAN` The machine's endianness ("le" or "be").
398 - `XBPS_LIBC` The machine's C library ("glibc" or "musl").
400 - `XBPS_WORDSIZE` The machine's word size in bits (32 or 64).
402 - `XBPS_NO_ATOMIC8` The machine lacks native 64-bit atomics (needs libatomic emulation).
404 - `XBPS_SRCDISTDIR` Full path to where the `source distfiles` are stored, i.e `$XBPS_HOSTDIR/sources`.
406 - `XBPS_SRCPKGDIR` Full path to the `srcpkgs` directory.
408 - `XBPS_TARGET_MACHINE` The target machine architecture when cross compiling a package.
410 - `XBPS_TARGET_ENDIAN` The target machine's endianness ("le" or "be").
412 - `XBPS_TARGET_LIBC` The target machine's C library ("glibc" or "musl").
414 - `XBPS_TARGET_WORDSIZE` The target machine's word size in bits (32 or 64).
416 - `XBPS_TARGET_NO_ATOMIC8` The target machine lacks native 64-bit atomics (needs libatomic emulation).
418 - `XBPS_FETCH_CMD` The utility to fetch files from `ftp`, `http` of `https` servers.
420 - `XBPS_WRAPPERDIR` Full path to where xbps-src's wrappers for utilities are stored.
422 - `XBPS_CROSS_BASE` Full path to where cross-compile dependencies are installed, varies according to the target architecture triplet. i.e `aarch64` -> `/usr/aarch64-linux-gnu`.
424 - `XBPS_RUST_TARGET` The target architecture triplet used by `rustc` and `cargo`.
426 - `XBPS_BUILD_ENVIRONMENT` Enables continuous-integration-specific operations. Set to `void-packages-ci` if in continuous integration.
428 <a id="available_vars"></a>
429 ### Available variables
431 <a id="mandatory_vars"></a>
432 #### Mandatory variables
434 The list of mandatory variables for a template:
436 - `homepage` An URL pointing to the upstream homepage.
439 - <a id="var_license"></a>
440 `license` A string matching the license's [SPDX Short identifier](https://spdx.org/licenses),
441 `Public Domain`, or string prefixed with `custom:` for other licenses.
442 Multiple licenses should be separated by commas, Example: `GPL-3.0-or-later, custom:Hugware`.
444   Empty meta-packages that don't include any files
445   and thus have and require no license should use
446   `Public Domain`.
448   Note: `AGPL`, `MIT`, `BSD`, `ISC`, `X11`, and custom licenses
449   require the license file to be supplied with the binary package.
451 - `maintainer` A string in the form of `name <user@domain>`.  The email for this field
452 must be a valid email that you can be reached at. Packages using
453 `users.noreply.github.com` emails will not be accepted.
455 - `pkgname` A string with the package name, matching `srcpkgs/<pkgname>`.
457 - `revision` A number that must be set to 1 when the `source package` is created, or
458 updated to a new `upstream version`. This should only be increased when
459 the generated `binary packages` have been modified.
461 - `short_desc` A string with a brief description for this package. Max 72 chars.
463 - `version` A string with the package version. Must not contain dashes or underscore
464 and at least one digit is required. Shell's variable substitution usage is not allowed.
466 `pkgname` and `version` are forbidden to contain special characters. Hence, they don't
467 need to be quoted, and by convention, they shouldn't be.
469 <a id="optional_vars"></a>
470 #### Optional variables
472 - `hostmakedepends` The list of `host` dependencies required to build the package, and
473 that will be installed to the master directory. There is no need to specify a version
474 because the current version in srcpkgs will always be required.
475 Example: `hostmakedepends="foo blah"`.
477 - `makedepends` The list of `target` dependencies required to build the package, and that
478 will be installed to the master directory. There is no need to specify a version
479 because the current version in srcpkgs will always be required.
480 Example: `makedepends="foo blah"`.
482 - `checkdepends` The list of dependencies required to run the package checks, i.e.
483 the script or make rule specified in the template's `do_check()` function.
484 Example: `checkdepends="gtest"`.
486 - `depends` The list of dependencies required to run the package. These dependencies
487 are not installed to the master directory, rather are only checked if a binary package
488 in the local repository exists to satisfy the required version. Dependencies
489 can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
490 or `foo-1.0_1` to match an exact version. If version comparator is not
491 defined (just a package name), the version comparator is automatically set to `>=0`.
492 Example: `depends="foo blah>=1.0"`. See the [Runtime dependencies](#deps_runtime) section
493 for more information.
495 - `bootstrap` If enabled the source package is considered to be part of the `bootstrap`
496 process and required to be able to build packages in the chroot. Only a
497 small number of packages must set this property.
499 - `conflicts` An optional list of packages conflicting with this package.
500 Conflicts can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
501 or `foo-1.0_1` to match an exact version. If version comparator is not
502 defined (just a package name), the version comparator is automatically set to `>=0`.
503 Example: `conflicts="foo blah>=0.42.3"`.
505 - `distfiles` The full URL to the `upstream` source distribution files. Multiple files
506 can be separated by whitespaces. The files must end in `.tar.lzma`, `.tar.xz`,
507 `.txz`, `.tar.bz2`, `.tbz`, `.tar.gz`, `.tgz`, `.gz`, `.bz2`, `.tar` or
508 `.zip`. To define a target filename, append `>filename` to the URL.
509 Example:
510         distfiles="http://foo.org/foo-1.0.tar.gz http://foo.org/bar-1.0.tar.gz>bar.tar.gz"
512   To avoid repetition, several variables for common hosting sites
513   exist:
515   | Variable         | Value                                           |
516   |------------------|-------------------------------------------------|
517   | CPAN_SITE        | https://cpan.perl.org/modules/by-module          |
518   | DEBIAN_SITE      | http://ftp.debian.org/debian/pool               |
519   | FREEDESKTOP_SITE | https://freedesktop.org/software                 |
520   | GNOME_SITE       | https://ftp.gnome.org/pub/GNOME/sources          |
521   | GNU_SITE         | https://ftp.gnu.org/gnu                          |
522   | KERNEL_SITE      | https://www.kernel.org/pub/linux                 |
523   | MOZILLA_SITE     | https://ftp.mozilla.org/pub                      |
524   | NONGNU_SITE      | https://download.savannah.nongnu.org/releases    |
525   | PYPI_SITE        | https://files.pythonhosted.org/packages/source  |
526   | SOURCEFORGE_SITE | https://downloads.sourceforge.net/sourceforge    |
527   | UBUNTU_SITE      | http://archive.ubuntu.com/ubuntu/pool           |
528   | XORG_SITE        | https://www.x.org/releases/individual            |
529   | KDE_SITE         | https://download.kde.org/stable                 |
530   | VIDEOLAN_SITE    | https://download.videolan.org/pub/videolan      |
532 - `checksum` The `sha256` digests matching `${distfiles}`. Multiple files can be
533 separated by blanks. Please note that the order must be the same than
534 was used in `${distfiles}`. Example: `checksum="kkas00xjkjas"`
536 If a distfile changes its checksum for every download because it is packaged
537 on the fly on the server, like e.g. snapshot tarballs from any of the
538 `https://*.googlesource.com/` sites, the checksum of the `archive contents`
539 can be specified by prepending a commercial at (@).
540 For tarballs you can find the contents checksum by using the command
541 `tar xf <tarball.ext> --to-stdout | sha256sum`.
543 - `wrksrc` The directory name where the package sources are extracted, set to `${pkgname}-${version}`.
545 - `build_wrksrc` A directory relative to `${wrksrc}` that will be used when building the package.
547 - `create_wrksrc` Usually, after extracting, if there're multiple top-level
548   files and/or directories or when there're no directories at all, top-level files,
549   and directories will be wrapped inside one more layer of directory.
550   Set `create_wrksrc` to force this behaviour.
552 - `build_style` This specifies the `build method` for a package. Read below to know more
553 about the available package `build methods` or effect of leaving this not set.
555 - `build_helper` Whitespace-separated list of files in `common/build-helper` to be
556 sourced and its variables be made available on the template. i.e. `build_helper="rust"`.
558 - `configure_script` The name of the `configure` script to execute at the `configure` phase if
559 `${build_style}` is set to `configure` or `gnu-configure` build methods.
560 By default set to `./configure`.
562 - `configure_args` The arguments to be passed in to the `configure` script if `${build_style}`
563 is set to `configure` or `gnu-configure` build methods. By default, prefix
564 must be set to `/usr`. In `gnu-configure` packages, some options are already
565 set by default: `--prefix=/usr --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man --localstatedir=/var`.
567 - `make_cmd` The executable to run at the `build` phase if `${build_style}` is set to
568 `configure`, `gnu-configure` or `gnu-makefile` build methods.
569 By default set to `make`.
571 - `make_build_args` The arguments to be passed in to `${make_cmd}` at the build phase if
572 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
573 build methods. Unset by default.
575 - `make_check_args` The arguments to be passed in to `${make_cmd}` at the check phase if
576 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
577 build methods. Unset by default.
579 - `make_install_args` The arguments to be passed in to `${make_cmd}` at the `install`
580 phase if `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile` build methods.
582 - `make_build_target` The build target. If `${build_style}` is set to `configure`, `gnu-configure`
583 or `gnu-makefile`, this is the target passed to `${make_cmd}` in the build phase;
584 when unset the default target is used.
585 If `${build_style}` is `python3-pep517`, this is the path of the package
586 directory that should be built as a Python wheel; when unset, defaults to `.` (the current
587 directory with respect to the build).
589 - `make_check_target` The target to be passed in to `${make_cmd}` at the check phase if
590 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
591 build methods. By default set to `check`.
593 - `make_install_target` The installation target. When `${build_style}` is set to `configure`,
594 `gnu-configure` or `gnu-makefile`, this is the target passed to `${make_command}` in the install
595 phase; when unset, it defaults to `install`. If `${build_style}` is `python-pep517`, this is the
596 path of the Python wheel produced by the build phase that will be installed; when unset, the
597 `python-pep517` build style will look for a wheel matching the package name and version in the
598 current directory with respect to the install.
600 - `make_check_pre` The expression in front of `${make_cmd}`. This can be used for wrapper commands
601 or for setting environment variables for the check command. By default empty.
603 - `patch_args` The arguments to be passed in to the `patch(1)` command when applying
604 patches to the package sources during `do_patch()`. Patches are stored in
605 `srcpkgs/<pkgname>/patches` and must be in `-p1` format. By default set to `-Np1`.
607 - `disable_parallel_build` If set the package won't be built in parallel
608 and `XBPS_MAKEJOBS` will be set to 1. If a package does not work well with `XBPS_MAKEJOBS`
609 but still has a mechanism to build in parallel, set `disable_parallel_build` and
610 use `XBPS_ORIG_MAKEJOBS` (which holds the original value of `XBPS_MAKEJOBS`) in the template.
612 - `disable_parallel_check` If set tests for the package won't be built and run in parallel
613 and `XBPS_MAKEJOBS` will be set to 1. If a package does not work well with `XBPS_MAKEJOBS`
614 but still has a mechanism to run checks in parallel, set `disable_parallel_check` and
615 use `XBPS_ORIG_MAKEJOBS` (which holds the original value of `XBPS_MAKEJOBS`) in the template.
617 - `make_check` Sets the cases in which the `check` phase is run.
618 This option has to be accompanied by a comment explaining why the tests fail.
619 Allowed values:
620   - `yes` (the default) to run if `XBPS_CHECK_PKGS` is set.
621   - `extended` to run if `XBPS_CHECK_PKGS` is `full`.
622   - `ci-skip` to run locally if `XBPS_CHECK_PKGS` is set, but not as part of pull request checks.
623   - `no` to never run.
626 - `keep_libtool_archives` If enabled the `GNU Libtool` archives won't be removed. By default those
627 files are always removed automatically.
629 - `skip_extraction` A list of filenames that should not be extracted in the `extract` phase.
630 This must match the basename of any url defined in `${distfiles}`.
631 Example: `skip_extraction="foo-${version}.tar.gz"`.
633 - `nodebug` If enabled -dbg packages won't be generated even if `XBPS_DEBUG_PKGS` is set.
635 - `conf_files` A list of configuration files the binary package owns; this expects full
636 paths, wildcards will be extended, and multiple entries can be separated by blanks.
637 Example: `conf_files="/etc/foo.conf /etc/foo2.conf /etc/foo/*.conf"`.
639 - `mutable_files` A list of files the binary package owns, with the expectation
640   that those files will be changed. These act a lot like `conf_files` but
641   without the assumption that a human will edit them.
643 - `make_dirs` A list of entries defining directories and permissions to be
644   created at install time. Each entry should be space separated, and will
645   itself contain spaces. `make_dirs="/dir 0750 user group"`. User and group and
646   mode are required on every line, even if they are `755 root root`. By
647   convention, there is only one entry of `dir perms user group` per line.
649 - `repository` Defines the repository in which the package will be placed. See
650   *Repositories* for a list of valid repositories.
652 - `nostrip` If set, the ELF binaries with debugging symbols won't be stripped. By
653 default all binaries are stripped.
655 - `nostrip_files` White-space separated list of ELF binaries that won't be stripped of
656 debugging symbols. Files can be given by full path or by filename.
658 - `noshlibprovides` If set, the ELF binaries won't be inspected to collect the provided
659 sonames in shared libraries.
661 - `noverifyrdeps` If set, the ELF binaries and shared libraries won't be inspected to collect
662 their reverse dependencies. You need to specify all dependencies in the `depends` when you
663 need to set this.
665 - `skiprdeps` White space separated list of filenames specified by their absolute path in
666 the `$DESTDIR` which will not be scanned for runtime dependencies. This may be useful to
667 skip files which are not meant to be run or loaded on the host but are to be sent to some
668 target device or emulation.
670 - `ignore_elf_files` White space separated list of machine code files
671 in /usr/share directory specified by absolute path, which are expected and allowed.
673 - `ignore_elf_dirs` White space separated list of directories in /usr/share directory
674 specified by absolute path, which are expected and allowed to contain machine code files.
676 - `nocross` If set, cross compilation won't be allowed and will exit immediately.
677 This should be set to a string describing why it fails, or a link to a buildlog (from the official builders, CI buildlogs can vanish) demonstrating the failure.
679 - `restricted` If set, xbps-src will refuse to build the package unless
680 `etc/conf` has `XBPS_ALLOW_RESTRICTED=yes`. The primary builders for Void
681 Linux do not have this setting, so the primary repositories will not have any
682 restricted package. This is useful for packages where the license forbids
683 redistribution.
685 - `subpackages` A white space separated list of subpackages (matching `foo_package()`)
686 to override the guessed list. Only use this if a specific order of subpackages is required,
687 otherwise the default would work in most cases.
689 - `broken` If set, building the package won't be allowed because its state is currently broken.
690 This should be set to a string describing why it is broken, or a link to a buildlog demonstrating the failure.
692 - `shlib_provides` A white space separated list of additional sonames the package provides on.
693 This appends to the generated file rather than replacing it.
695 - `shlib_requires` A white space separated list of additional sonames the package requires.
696 This appends to the generated file rather than replacing it.
698 - `nopie` Only needs to be set to something to make active, disables building the package with hardening
699   features (PIE, relro, etc). Not necessary for most packages.
701 - `nopie_files` White-space separated list of ELF binaries that won't be checked
702 for PIE. Files must be given by full path.
704 - `reverts` xbps supports a unique feature which allows to downgrade from broken
705 packages automatically. In the `reverts` field one can define a list of broken
706 pkgver the resulting package should revert. This field *must* be defined before
707 `version` and `revision` fields in order to work as expected. The versions
708 defined in `reverts` must be bigger than the one defined in `version`.
709 Example:
711     ```
712     reverts="2.0_1 2.0_2"
713     version=1.9
714     revision=2
715     ```
717 - `alternatives` A white space separated list of supported alternatives the package provides.
718 A list is composed of three components separated by a colon: group, symlink and target.
719 Example: `alternatives="vi:/usr/bin/vi:/usr/bin/nvi ex:/usr/bin/ex:/usr/bin/nvi-ex"`.
721 - `font_dirs` A white space separated list of directories specified by an absolute path where a
722 font package installs its fonts.
723 It is used in the `x11-fonts` xbps-trigger to rebuild the font cache during install/removal
724 of the package.
725 Example: `font_dirs="/usr/share/fonts/TTF /usr/share/fonts/X11/misc"`
727 - `dkms_modules` A white space separated list of Dynamic Kernel Module Support (dkms) modules
728 that will be installed and removed by the `dkms` xbps-trigger with the install/removal of the
729 package.
730 The format is a white space separated pair of strings that represent the name of the module,
731 most of the time `pkgname`, and the version of the module, most of the time `version`.
732 Example: `dkms_modules="$pkgname $version zfs 4.14"`
734 - `register_shell` A white space separated list of shells defined by absolute path to be
735 registered into the system shells database. It is used by the `register-shell` trigger.
736 Example: `register_shell="/bin/tcsh /bin/csh"`
738 - `tags` A white space separated list of tags (categories) that are registered into the
739 package metadata and can be queried with `xbps-query` by users.
740 Example for qutebrowser: `tags="browser chromium-based qt5 python3"`
742 - `perl_configure_dirs` A white space separate list of directories relative to `wrksrc`
743 that contain Makefile.PL files that need to be processes for the package to work. It is
744 used in the perl-module build_style and has no use outside of it.
745 Example: `perl_configure_dirs="blob/bob foo/blah"`
747 - `preserve` If set, files owned by the package in the system are not removed when
748 the package is updated, reinstalled or removed. This is mostly useful for kernel packages
749 that shouldn't remove the kernel files when they are removed in case it might break the
750 user's booting and module loading. Otherwise in the majority of cases it should not be
751 used.
753 - `fetch_cmd` Executable to be used to fetch URLs in `distfiles` during the `do_fetch` phase.
755 - `changelog` An URL pointing to the upstream changelog. Raw text files are preferred.
757 - `archs` Whitespace separated list of architectures that a package can be
758 built for, available architectures can be found under `common/cross-profiles`.
759 In general, `archs` should only be set if the upstream software explicitly targets
760 certain architectures or there is a compelling reason why the software should not be
761 available on some supported architectures.
762 Prepending a pattern with a tilde means disallowing build on the indicated archs.
763 The first matching pattern is taken to allow/deny build. When no pattern matches,
764 the package is built if the last pattern includes a tilde.
765 Examples:
767         ```
768         # Build package only for musl architectures
769         archs="*-musl"
770         # Build package for x86_64-musl and any non-musl architecture
771         archs="x86_64-musl ~*-musl"
772         # Default value (all arches)
773         archs="*"
774         ```
775 A special value `noarch` used to be available, but has since been removed.
777 - `nocheckperms` If set, xbps-src will not fail on common permission errors (world writable files, etc.)
779 - `nofixperms` If set, xbps-src will not fix common permission errors (executable manpages, etc.)
781 - `no_generic_pkgconfig_link` If set, xbps-src will not create a symlink from `$XBPS_CROSS_TRIPLET-pkg-config`
782   to `$XBPS_WRAPPERDIR/pkg-config` before building the template.
784 <a id="explain_depends"></a>
785 #### About the many types of `depends` variables
787 So far, we have listed four types of `depends` variables: `hostmakedepends`,
788 `makedepends`, `checkdepends` and `depends`. These different kinds of variables
789 are necessary because `xbps-src` supports cross compilation and to avoid
790 installing unnecessary packages in the build environment.
792 During a build process, there are programs that must be _run_ on the host, such
793 as `yacc` or the C compiler. The packages that contain these programs should be
794 listed in `hostmakedepends`, and will be installed on the host when building the
795 target package. Some of these packages are dependencies of the `base-chroot`
796 package and don't need to be listed. It is possible that some of the programs
797 necessary to build a project are located in `-devel` packages.
799 The target package can also depend on other packages for libraries to link
800 against or header files. These packages should be listed in `makedepends` and
801 will match the target architecture, regardless of the architecture of the build
802 machine. Typically, `makedepends` will contain mainly `-devel` packages.
804 Furthermore, if `XBPS_CHECK_PKGS` is set or the `-Q` option is passed to
805 `xbps-src`, the target package might require specific dependencies or libraries
806 that are linked into its test binaries to run its test suite. These dependencies
807 should be listed in `checkdepends` and will be installed as if they were part of
808 `hostmakedepends`. Some dependencies that can be included in `checkdepends` are:
810 - `dejagnu`: used for some GNU projects
811 - `cmocka-devel`: linked into test binaries
812 - `dbus`: makes it possible to run `dbus-run-session <test-command>` to provide
813   a D-Bus session for applications that need it
814 - `git`: some test suites run the `git` command
816 <a id="deps_runtime"></a>
817 Lastly, a package may require certain dependencies at runtime, without which it
818 is unusable. These dependencies, when they aren't detected automatically by
819 XBPS, should be listed in `depends`.
821 Libraries linked by ELF objects are detected automatically by `xbps-src`, hence they
822 must not be specified in templates via `depends`. This variable should list:
824 - executables called as separate processes.
825 - ELF objects using dlopen(3).
826 - non-object code, e.g. C headers, perl/python/ruby/etc modules.
827 - data files.
828 - overriding the minimal version specified in the `common/shlibs` file.
830 The runtime dependencies for ELF objects are detected by checking which SONAMEs
831 they require and then the SONAMEs are mapped to a binary package name with a minimal
832 required version. The `common/shlibs` file
833 sets up the `<SONAME> <pkgname>>=<version>` mappings.
835 For example the `foo-1.0_1` package provides the `libfoo.so.1` SONAME and
836 software requiring this library will link to `libfoo.so.1`; the resulting binary
837 package will have a run-time dependency on `foo>=1.0_1` package as specified in
838 `common/shlibs`:
841 # common/shlibs
843 libfoo.so.1 foo-1.0_1
847 - The first field specifies the SONAME.
848 - The second field specified the package name and minimal version required.
849 - A third optional field (usually set to `ignore`) can be used to skip checks in soname bumps.
851 Dependencies declared via `depends` are not installed to the master directory, rather they are
852 only checked if they exist as binary packages, and are built automatically by `xbps-src` if
853 the specified version is not in the local repository.
855 As a special case, `virtual` dependencies may be specified as runtime dependencies in the
856 `depends` template variable. Several different packages can provide common functionality by
857 declaring a virtual name and version in the `provides` template variable (e.g.
858 `provides="vpkg-0.1_1"`). Packages that rely on the common functionality without concern for the
859 specific provider can declare a dependency on the virtual package name with the prefix `virtual?`
860 (e.g., `depends="virtual?vpkg-0.1_1"`). When a package is built by `xbps-src`, providers for any
861 virtual packages will be confirmed to exist and will be built if necessary. A map from virtual
862 packages to their default providers is defined in `etc/defaults.virtual`. Individual mappings can be
863 overridden by local preferences in `etc/virtual`. Comments in `etc/defaults.virtual` provide more
864 information on this map.
866 Finally, as a general rule, if a package is built the exact same way whether or
867 not a particular package is present in `makedepends` or `hostmakedepends`, that
868 package shouldn't be added as a build time dependency.
870 <a id="repositories"></a>
871 ### Repositories
873 <a id="repo_by_branch"></a>
874 #### Repositories defined by Branch
876 The global repository takes the name of
877 the current branch, except if the name of the branch is master. Then the resulting
878 repository will be at the global scope. The usage scenario is that the user can
879 update multiple packages in a second branch without polluting his local repository.
881 <a id="pkg_defined_repo"></a>
882 #### Package defined Repositories
884 The second way to define a repository is by setting the `repository` variable in
885 a template. This way the maintainer can define repositories for a specific
886 package or a group of packages. This is currently used to distinguish between
887 certain classes of packages.
889 The following repository names are valid:
891 * `bootstrap`: Repository for xbps-src-specific packages.
892 * `debug`: Repository for packages containing debug symbols. In almost all cases,
893   these packages are generated automatically.
894 * `nonfree`: Repository for packages that are closed source or have nonfree licenses.
896 <a id="updates"></a>
897 ### Checking for new upstream releases
899 New upstream versions can be automatically checked using
900 `./xbps-src update-check <pkgname>`. In some cases you need to override
901 the sensible defaults by assigning the following variables in a `update`
902 file in the same directory as the relevant `template` file:
904 - `site` contains the URL where the version number is
905   mentioned.  If unset, defaults to `homepage` and the directories where
906 `distfiles` reside.
908 - `pkgname` is the package name the default pattern checks for.
909 If unset, defaults to `pkgname` from the template.
911 - `pattern` is a perl-compatible regular expression
912 matching the version number.  Anchor the version number using `\K`
913 and `(?=...)`.  Example: `pattern='<b>\K[\d.]+(?=</b>)'`, this
914 matches a version number enclosed in `<b>...</b>` tags.
916 - `ignore` is a space-separated list of shell globs that match
917 version numbers which are not taken into account for checking newer
918 versions.  Example: `ignore="*b*"`
920 - `version` is the version number used to compare against
921 upstream versions. Example: `version=${version//./_}`
923 - `single_directory` can be set to disable
924 detecting directory containing one version of sources in url,
925 then searching new version in adjacent directories.
927 - `vdprefix` is a perl-compatible regular expression matching
928 part that precedes numeric part of version directory
929 in url. Defaults to `(|v|$pkgname)[-_.]*`.
931 - `vdsuffix` is a perl-compatible regular expression matching
932 part that follows numeric part of version directory
933 in url. Defaults to `(|\.x)`.
935 - `disabled` can be set to disable update checking for the package,
936 in cases where checking for updates is impossible or does not make sense.
937 This should be set to a string describing why it is disabled.
939 <a id="patches"></a>
940 ### Handling patches
942 Sometimes software needs to be patched, most commonly to fix bugs that have
943 been found or to fix compilation with new software.
945 To handle this, xbps-src has patching functionality. It will look for all files
946 that match the glob `srcpkgs/$pkgname/patches/*.{diff,patch}` and will
947 automatically apply all files it finds using `patch(1)` with `-Np1`. This happens
948 during the `do_patch()` phase. The variable `PATCHESDIR` is
949 available in the template, pointing to the `patches` directory.
951 The patching behaviour can be changed in the following ways:
953 - A file called `series` can be created in the `patches` directory with a newline
954 separated list of patches to be applied in the order presented. When present
955 xbps-src will only apply patches named in the `series` file.
957 - A file with the same name as one of the patches but with `.args` as extension can
958 be used to set the args passed to `patch(1)`. As an example, if `foo.patch` requires
959 special arguments to be passed to `patch(1)` that can't be used when applying other
960 patches, `foo.patch.args` can be created containing those args.
962 <a id="build_scripts"></a>
963 ### build style scripts
965 The `build_style` variable specifies the build method to build and install a
966 package. It expects the name of any available script in the
967 `void-packages/common/build-style` directory. Please note that required packages
968 to execute a `build_style` script must be defined via `$hostmakedepends`.
970 The current list of available `build_style` scripts is the following:
972 - If `build_style` is not set, the template must (at least) define
973 `do_install()` function and optionally more build phases such as
974 `do_configure()`, `do_build()`, etc., and may overwrite default `do_fetch()` and
975 `do_extract()` that fetch and extract files defined in `distfiles` variable.
977 - `cargo` For packages written in rust that use Cargo for building.
978 Configuration arguments (such as `--features`) can be defined in the variable
979 `configure_args` and are passed to cargo during `do_build`.
981 - `cmake` For packages that use the CMake build system, configuration arguments
982 can be passed in via `configure_args`. The `cmake_builddir` variable may be
983 defined to specify the directory for building under `build_wrksrc` instead of
984 the default `build`.
986 - `configure` For packages that use non-GNU configure scripts, at least `--prefix=/usr`
987 should be passed in via `configure_args`.
989 - `fetch` For packages that only fetch files and are installed as is via `do_install()`.
991 - `gnu-configure` For packages that use GNU autotools-compatible configure scripts,
992 additional configuration arguments can be passed in via `configure_args`.
994 - `gnu-makefile` For packages that use GNU make, build arguments can be passed in via
995 `make_build_args` and install arguments via `make_install_args`. The build
996 target can be overridden via `make_build_target` and the install target
997 via `make_install_target`. This build style tries to compensate for makefiles
998 that do not respect environment variables, so well written makefiles, those
999 that do such things as append (`+=`) to variables, should have `make_use_env`
1000 set in the body of the template.
1002 - `go` For programs written in Go that follow the standard package
1003 structure. The variable `go_import_path` must be set to the package's
1004 import path, e.g. `github.com/github/hub` for the `hub` program. This
1005 information can be found in the `go.mod` file for modern Go projects.
1006 It's expected that the distfile contains the package, but dependencies
1007 will be downloaded with `go get`.
1009 - `meta` For `meta-packages`, i.e packages that only install local files or simply
1010 depend on additional packages. This build style does not install
1011 dependencies to the root directory, and only checks if a binary package is
1012 available in repositories.
1014 - `R-cran` For packages that are available on The Comprehensive R Archive
1015 Network (CRAN). The build style requires the `pkgname` to start with
1016 `R-cran-` and any dashes (`-`) in the CRAN-given version to be replaced
1017 with the character `r` in the `version` variable. The `distfiles`
1018 location will automatically be set as well as the package made to depend
1019 on `R`.
1021 - `gemspec` For packages that use
1022 [gemspec](https://guides.rubygems.org/specification-reference/) files for building a ruby
1023 gem and then installing it. The gem command can be overridden by `gem_cmd`. `configure_args`
1024 can be used to pass arguments during compilation. If your package does not make use of compiled
1025 extensions consider using the `gem` build style instead.
1027 - `gem` For packages that are installed using gems from [RubyGems](https://rubygems.org/).
1028 The gem command can be overridden by `gem_cmd`.
1029 `distfiles` is set by the build style if the template does not do so. If your gem
1030 provides extensions which must be compiled consider using the `gemspec` build style instead.
1032 - `ruby-module` For packages that are ruby modules and are installable via `ruby install.rb`.
1033 Additional install arguments can be specified via `make_install_args`.
1035 - `perl-ModuleBuild` For packages that use the Perl
1036 [Module::Build](https://metacpan.org/pod/Module::Build) method.
1038 - `perl-module` For packages that use the Perl
1039 [ExtUtils::MakeMaker](http://perldoc.perl.org/ExtUtils/MakeMaker.html) build method.
1041 - `raku-dist` For packages that use the Raku `raku-install-dist` build method with rakudo.
1043 - `waf3` For packages that use the Python3 `waf` build method with python3.
1045 - `waf` For packages that use the Python `waf` method with python2.
1047 - `slashpackage` For packages that use the /package hierarchy and package/compile to build,
1048 such as `daemontools` or any `djb` software.
1050 - `qmake` For packages that use Qt5/Qt6 qmake profiles (`*.pro`), qmake arguments
1051 for the configure phase can be passed in via `configure_args`, make build arguments can
1052 be passed in via `make_build_args` and install arguments via `make_install_args`. The build
1053 target can be overridden via `make_build_target` and the install target
1054 via `make_install_target`.
1056 - `meson` For packages that use the Meson Build system, configuration options can be passed
1057 via `configure_args`, the meson command can be overridden by `meson_cmd` and the location of
1058 the out of source build by `meson_builddir`
1060 - `void-cross` For cross-toolchain packages used to build Void systems. There are no
1061 mandatory variables (target triplet is inferred), but you can specify some optional
1062 ones - `cross_gcc_skip_go` can be specified to skip `gccgo`, individual subproject
1063 configure arguments can be specified via `cross_*_configure_args` where `*` is `binutils`,
1064 `gcc_bootstrap` (early gcc), `gcc` (final gcc), `glibc` (or `musl`), `configure_args` is
1065 additionally passed to both early and final `gcc`. You can also specify custom `CFLAGS`
1066 and `LDFLAGS` for the libc as `cross_(glibc|musl)_(cflags|ldflags)`.
1068 - `zig-build` For packages using [Zig](https://ziglang.org)'s build
1069 system. Additional arguments may be passed to the `zig build` invocation using
1070 `configure_args`.
1072 For packages that use the Python module build method (`setup.py` or
1073 [PEP 517](https://www.python.org/dev/peps/pep-0517/)), you can choose one of the following:
1075 - `python2-module` to build Python 2.x modules
1077 - `python3-module` to build Python 3.x modules
1079 - `python3-pep517` to build Python 3.x modules that provide a PEP 517 build description without
1080 a `setup.py` script
1082 Environment variables for a specific `build_style` can be declared in a filename
1083 matching the `build_style` name, Example:
1085     `common/environment/build-style/gnu-configure.sh`
1087 - `texmf` For texmf zip/tarballs that need to go into /usr/share/texmf-dist. Includes
1088 duplicates handling.
1090 <a id="build_helper"></a>
1091 ### build helper scripts
1093 The `build_helper` variable specifies shell snippets to be sourced that will create a
1094 suitable environment for working with certain sets of packages.
1096 The current list of available `build_helper` scripts is the following:
1098 - `cmake-wxWidgets-gtk3` sets the `WX_CONFIG` variable which is used by FindwxWidgets.cmake
1100 - `gir` specifies dependencies for native and cross builds to deal with
1101 GObject Introspection. The following variables may be set in the template to handle
1102 cross builds which require additional hinting or exhibit problems. `GIR_EXTRA_LIBS_PATH` defines
1103 additional paths to be searched when linking target binaries to be introspected.
1104 `GIR_EXTRA_OPTIONS` defines additional options for the `g-ir-scanner-qemuwrapper` calling
1105 `qemu-<target_arch>-static` when running the target binary. You can for example specify
1106 `GIR_EXTRA_OPTIONS="-strace"` to see a trace of what happens when running that binary.
1108 - `meson` creates a cross file, `${XBPS_WRAPPERDIR}/meson/xbps_meson.cross`, which configures
1109 meson for cross builds. This is particularly useful for building packages that wrap meson
1110 invocations (e.g., `python3-pep517` packages that use a meson backend) and is added by default
1111 for packages that use the `meson` build style.
1113 - `numpy` configures the environment for cross-compilation of python packages that provide
1114 compiled extensions linking to NumPy C libraries. If the `meson` build helper is also
1115 configured, a secondary cross file, `${XBPS_WRAPPERDIR}/meson/xbps_numpy.cross`, will be
1116 written to inform meson where common NumPy components may be found.
1118 - `python3` configures the cross-build environment to use Python libraries, header files, and
1119 interpreter configurations in the target root. The `python3` helper is added by default for
1120 packages that use the `python3-module` or `python3-pep517` build styles.
1122 - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow
1123 executing cross-compiled binaries inside qemu.
1124 It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
1125 to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`.
1126 It also creates the `vtargetrun` function to wrap commands in a call to
1127 `qemu-<target_arch>-static` for the target architecture.
1129 - `qmake` creates the `qt.conf` configuration file (cf. `qmake` `build_style`)
1130 needed for cross builds and a qmake-wrapper to make `qmake` use this configuration.
1131 This aims to fix cross-builds for when the build-style is mixed: e.g. when in a
1132 `gnu-configure` style the configure script calls `qmake` or a `Makefile` in
1133 `gnu-makefile` style, respectively. This is for Qt5 packages.
1135 - `qmake6` is like `qmake` but for Qt6.
1137 - `rust` specifies environment variables required for cross-compiling crates via cargo and
1138 for compiling cargo -sys crates. This helper is added by default for packages that use the
1139 `cargo` build style.
1141 <a id="functions"></a>
1142 ### Functions
1144 The following functions can be defined to change the behavior of how the
1145 package is downloaded, compiled and installed.
1147 - `pre_fetch()` Actions to execute before `do_fetch()`.
1149 - `do_fetch()` if defined and `distfiles` is not set, use it to fetch the required sources.
1151 - `post_fetch()` Actions to execute after `do_fetch()`.
1153 - `pre_extract()` Actions to execute after `post_fetch()`.
1155 - `do_extract()` if defined and `distfiles` is not set, use it to extract the required sources.
1157 - `post_extract()` Actions to execute after `do_extract()`.
1159 - `pre_patch()` Actions to execute after `post_extract()`.
1161 - `do_patch()` if defined use it to prepare the build environment and run hooks to apply patches.
1163 - `post_patch()` Actions to execute after `do_patch()`.
1165 - `pre_configure()` Actions to execute after `post_patch()`.
1167 - `do_configure()` Actions to execute to configure the package; `${configure_args}` should
1168 still be passed in if it's a GNU configure script.
1170 - `post_configure()` Actions to execute after `do_configure()`.
1172 - `pre_build()` Actions to execute after `post_configure()`.
1174 - `do_build()` Actions to execute to build the package.
1176 - `post_build()` Actions to execute after `do_build()`.
1178 - `pre_check()` Actions to execute after `post_build()`.
1180 - `do_check()` Actions to execute to run checks for the package.
1182 - `post_check()` Actions to execute after `do_check()`.
1184 - `pre_install()` Actions to execute after `post_check()`.
1186 - `do_install()` Actions to execute to install the package files into the `fake destdir`.
1188 - `post_install()` Actions to execute after `do_install()`.
1190 - `do_clean()` Actions to execute to clean up after a successful package phase.
1192 > A function defined in a template has preference over the same function
1193 defined by a `build_style` script.
1195 Current working directory for functions is set as follows:
1197 - For pre_fetch, pre_extract, do_clean: `<masterdir>`.
1199 - For do_fetch, post_fetch: `XBPS_BUILDDIR`.
1201 - For do_extract through do_patch: `wrksrc`.
1203 - For post_patch through post_install: `build_wrksrc`
1204 if it is defined, otherwise `wrksrc`.
1206 <a id="build_options"></a>
1207 ### Build options
1209 Some packages might be built with different build options to enable/disable
1210 additional features; The XBPS source packages collection allows you to do this with some simple tweaks
1211 to the `template` file.
1213 The following variables may be set to allow package build options:
1215 - `build_options` Sets the build options supported by the source package.
1217 - `build_options_default` Sets the default build options to be used by the source package.
1219 - `desc_option_<option>` Sets the description for the build option `option`. This must match the
1220 keyword set in *build_options*. Note that if the build option is generic enough, its description
1221 should be added to `common/options.description` instead.
1223 After defining those required variables, you can check for the
1224 `build_option_<option>` variable to know if it has been set and adapt the source
1225 package accordingly. Additionally, the following functions are available:
1227 - *vopt_if()* `vopt_if <option> <if_true> [<if_false>]`
1229   Outputs `if_true` if `option` is set, or `if_false` if it isn't set.
1231 - *vopt_with()* `vopt_with <option> [<flag>]`
1233   Outputs `--with-<flag>` if the option is set, or `--without-<flag>`
1234   otherwise. If `flag` isn't set, it defaults to `option`.
1236   Examples:
1238   - `vopt_with dbus`
1239   - `vopt_with xml xml2`
1241 - *vopt_enable()* `vopt_enable <option> [<flag>]`
1243   Same as `vopt_with`, but uses `--enable-<flag>` and
1244   `--disable-<flag>` respectively.
1246 - *vopt_conflict()* `vopt_conflict <option 1> <option 2>`
1248   Emits an error and exits if both options are set at the same time.
1250 - *vopt_bool()* `vopt_bool <option> <property>`
1252   Outputs `-D<property>=true` if the option is set, or
1253   `-D<property>=false` otherwise.
1255 - *vopt_feature()* `vopt_feature <option> <property>`
1257   Same as `vopt_bool`, but uses `-D<property>=enabled` and
1258         `-D<property>=disabled` respectively.
1260 The following example shows how to change a source package that uses GNU
1261 configure to enable a new build option to support PNG images:
1264 # Template file for 'foo'
1265 pkgname=foo
1266 version=1.0
1267 revision=1
1268 build_style=gnu-configure
1269 configure_args="... $(vopt_with png)"
1270 makedepends="... $(vopt_if png libpng-devel)"
1273 # Package build options
1274 build_options="png"
1275 desc_option_png="Enable support for PNG images"
1277 # To build the package by default with the `png` option:
1279 # build_options_default="png"
1285 The supported build options for a source package can be shown with `xbps-src`:
1287     $ ./xbps-src show-options foo
1289 Build options can be enabled with the `-o` flag of `xbps-src`:
1291     $ ./xbps-src -o option,option1 <cmd> foo
1293 Build options can be disabled by prefixing them with `~`:
1295     $ ./xbps-src -o ~option,~option1 <cmd> foo
1297 Both ways can be used together to enable and/or disable multiple options
1298 at the same time with `xbps-src`:
1300     $ ./xbps-src -o option,~option1,~option2 <cmd> foo
1302 The build options can also be shown for binary packages via `xbps-query(8)`:
1304     $ xbps-query -R --property=build-options foo
1306 Permanent global package build options can be set via `XBPS_PKG_OPTIONS` variable in the
1307 `etc/conf` configuration file. Per package build options can be set via
1308 `XBPS_PKG_OPTIONS_<pkgname>`.
1310 > NOTE: if `pkgname` contains `dashes`, those should be replaced by `underscores`
1311 Example: `XBPS_PKG_OPTIONS_xorg_server=opt`.
1313 The list of supported package build options and its description is defined in the
1314 `common/options.description` file.
1316 <a id="install_remove_files"></a>
1317 ### INSTALL and REMOVE files
1319 The INSTALL and REMOVE shell snippets can be used to execute certain actions at a specified
1320 stage when a binary package is installed, updated or removed. There are some variables
1321 that are always set by `xbps` when the scripts are executed:
1323 - `$ACTION`: to conditionalize its actions: `pre` or `post`.
1324 - `$PKGNAME`: the package name.
1325 - `$VERSION`: the package version.
1326 - `$UPDATE`: set to `yes` if package is being upgraded, `no` if package is being `installed` or `removed`.
1327 - `$CONF_FILE`: full path to `xbps.conf`.
1328 - `$ARCH`: the target architecture it is running on.
1330 An example of how an `INSTALL` or `REMOVE` script shall be created is shown below:
1333 # INSTALL
1334 case "$ACTION" in
1335 pre)
1336         # Actions to execute before the package files are unpacked.
1337         ...
1338         ;;
1339 post)
1340         if [ "$UPDATE" = "yes" ]; then
1341                 # actions to execute if package is being updated.
1342                 ...
1343         else
1344                 # actions to execute if package is being installed.
1345                 ...
1346         fi
1347         ;;
1348 esac
1351 subpackages can also have their own `INSTALL` and `REMOVE` files, simply create them
1352 as `srcpkgs/<pkgname>/<subpkg>.INSTALL` or `srcpkgs/<pkgname>/<subpkg>.REMOVE` respectively.
1354 > NOTE: always use paths relative to the current working directory, otherwise if the scripts cannot
1355 be executed via `chroot(2)` won't work correctly.
1357 > NOTE: do not use INSTALL/REMOVE scripts to print messages, see the next section for
1358 more information.
1360 <a id="install_remove_files_msg"></a>
1361 ### INSTALL.msg and REMOVE.msg files
1363 The `INSTALL.msg` and `REMOVE.msg` files can be used to print a message at post-install
1364 or pre-remove time, respectively.
1366 Ideally those files should not exceed 80 chars per line.
1368 subpackages can also have their own `INSTALL.msg` and `REMOVE.msg` files, simply create them
1369 as `srcpkgs/<pkgname>/<subpkg>.INSTALL.msg` or `srcpkgs/<pkgname>/<subpkg>.REMOVE.msg` respectively.
1371 This should only be used for critical messages, like warning users of breaking changes.
1373 <a id="runtime_account_creation"></a>
1374 ### Creating system accounts/groups at runtime
1376 There's a trigger along with some variables that are specifically to create
1377 **system users and groups** when the binary package is being configured.
1378 The following variables can be used for this purpose:
1380 - `system_groups` This specifies the names of the new *system groups* to be created, separated
1381 by blanks. Optionally the **gid** can be specified by delimiting it with a
1382 colon, i.e `system_groups="_mygroup:78"` or `system_groups="_foo _blah:8000"`.
1384 - `system_accounts` This specifies the names of the new **system users/groups** to be created,
1385 separated by blanks, i.e `system_accounts="_foo _blah:22"`. Optionally the **uid** and **gid**
1386 can be specified by delimiting it with a colon, i.e `system_accounts="_foo:48"`.
1387 Additional variables for the **system accounts** can be specified to change its behavior:
1389         - `<account>_homedir` the home directory for the user. If unset defaults to `/var/empty`.
1390         - `<account>_shell` the shell for the new user. If unset defaults to `/sbin/nologin`.
1391         - `<account>_descr` the description for the new user. If unset defaults to `<account> unprivileged user`.
1392         - `<account>_groups` additional groups to be added to for the new user.
1393         - `<account>_pgroup` to set the primary group, by default primary group is set to `<account>`.
1395 The **system user** is created by using a dynamically allocated **uid/gid** in your system
1396 and it's created as a `system account`, unless the **uid** is set. A new group will be created for the
1397 specified `system account` and used exclusively for this purpose.
1399 System accounts and groups must be prefixed with an underscore to prevent clashing with names of user
1400 accounts.
1402 > NOTE: The underscore policy does not apply to old packages, due to the inevitable breakage of
1403 > changing the username only new packages should follow it.
1405 <a id="writing_runit_services"></a>
1406 ### Writing runit services
1408 Void Linux uses [runit](http://smarden.org/runit/) for booting and supervision of services.
1410 Most information about how to write them can be found in their
1411 [FAQ](http://smarden.org/runit/faq.html#create). The following are guidelines specific to
1412 Void Linux on how to write services.
1414 If the service daemon supports CLI flags, consider adding support for changing it via the
1415 `OPTS` variable by reading a file called `conf` in the same directory as the daemon.
1417 ```sh
1418 #!/bin/sh
1419 [ -r conf ] && . ./conf
1420 exec daemon ${OPTS:- --flag-enabled-by-default}
1423 If the service requires the creation of a directory under `/run` or its link `/var/run`
1424 for storing runtime information (like Pidfiles) write it into the service file. It
1425 is advised to use `install` if you need to create it with specific permissions instead
1426 of `mkdir -p`.
1428 ```sh
1429 #!/bin/sh
1430 install -d -m0700 /run/foo
1431 exec foo
1434 ```sh
1435 #!/bin/sh
1436 install -d -m0700 -o bar -g bar /run/bar
1437 exec bar
1440 If the service requires directories in parts of the system that are not generally in
1441 temporary filesystems. Then use the `make_dirs` variable in the template to create
1442 those directories when the package is installed.
1444 If the package installs a systemd service file or other unit, leave it in place as a
1445 reference point so long as including it has no negative side effects.
1447 Examples of when *not* to install systemd units:
1449 1. When doing so changes runtime behavior of the packaged software.
1450 2. When it is done via a compile time flag that also changes build dependencies.
1452 <a id="32bit_pkgs"></a>
1453 ### 32bit packages
1455 32bit packages are built automatically when the builder is x86 (32bit), but
1456 there are some variables that can change the behavior:
1458 - `lib32depends` If this variable is set, dependencies listed here will be used rather than
1459 those detected automatically by `xbps-src` and **depends**. Please note that
1460 dependencies must be specified with version comparators, Example:
1461 `lib32depends="foo>=0 blah<2.0"`.
1463 - `lib32disabled` If this variable is set, no 32bit package will be built.
1465 - `lib32files` Additional files to be added to the **32bit** package. This expect absolute
1466 paths separated by blanks, Example: `lib32files="/usr/bin/blah /usr/include/blah."`.
1468 - `lib32symlinks` Makes a symlink of the target filename stored in the `lib32` directory.
1469 This expects the basename of the target file, Example: `lib32symlinks="foo"`.
1471 - `lib32mode` If unset, only shared/static libraries and pkg-config files will be copied to the
1472 **32bit** package. If set to `full` all files will be copied to the 32bit package, unmodified.
1474 <a id="pkgs_sub"></a>
1475 ### Subpackages
1477 In the example shown above just a binary package is generated, but with some
1478 simple tweaks multiple binary packages can be generated from a single
1479 template/build, this is called `subpackages`.
1481 To create additional `subpackages` the `template` must define a new function
1482 with this naming: `<subpkgname>_package()`, Example:
1485 # Template file for 'foo'
1486 pkgname=foo
1487 version=1.0
1488 revision=1
1489 build_style=gnu-configure
1490 short_desc="A short description max 72 chars"
1491 maintainer="name <email>"
1492 license="GPL-3.0-or-later"
1493 homepage="http://www.foo.org"
1494 distfiles="http://www.foo.org/foo-${version}.tar.gz"
1495 checksum="fea0a94d4b605894f3e2d5572e3f96e4413bcad3a085aae7367c2cf07908b2ff"
1497 # foo-devel is a subpkg
1498 foo-devel_package() {
1499         short_desc+=" - development files"
1500         depends="${sourcepkg}>=${version}_${revision}"
1501         pkg_install() {
1502                 vmove usr/include
1503                 vmove "usr/lib/*.a"
1504                 vmove "usr/lib/*.so"
1505                 vmove usr/lib/pkgconfig
1506         }
1510 All subpackages need an additional symlink to the `main` pkg, otherwise dependencies
1511 requiring those packages won't find its `template` Example:
1514  /srcpkgs
1515   |- foo <- directory (main pkg)
1516   |  |- template
1517   |- foo-devel <- symlink to `foo`
1520 The main package should specify all required `build dependencies` to be able to build
1521 all subpackages defined in the template.
1523 An important point of `subpackages` is that they are processed after the main
1524 package has run its `install` phase. The `pkg_install()` function specified on them
1525 commonly is used to move files from the `main` package destdir to the `subpackage` destdir.
1527 The helper functions `vinstall`, `vmkdir`, `vcopy` and `vmove` are just wrappers that simplify
1528 the process of creating, copying and moving files/directories between the `main` package
1529 destdir (`$DESTDIR`) to the `subpackage` destdir (`$PKGDESTDIR`).
1531 Subpackages are processed always in alphabetical order; To force a custom order,
1532 the `subpackages` variable can be declared with the wanted order.
1534 <a id="pkgs_classes"></a>
1535 ### Some package classes
1537 <a id="pkgs_development"></a>
1538 #### Development packages
1540 A development package, commonly generated as a subpackage, shall only contain
1541 files required for development, that is, headers, static libraries, shared
1542 library symlinks, pkg-config files, API documentation or any other script
1543 that is only useful when developing for the target software.
1545 A development package should depend on packages that are required to link
1546 against the provided shared libraries, i.e if `libfoo` provides the
1547 `libfoo.so.2` shared library and the linking needs `-lbar`, the package
1548 providing the `libbar` shared library should be added as a dependency;
1549 and most likely it shall depend on its development package.
1551 If a development package provides a `pkg-config` file, you should verify
1552 what dependencies the package needs for dynamic or static linking, and add
1553 the appropriate `development` packages as dependencies.
1555 Development packages for the C and C++ languages usually `vmove` the
1556 following subset of files from the main package:
1558 * Header files `usr/include`
1559 * Static libraries `usr/lib/*.a`
1560 * Shared library symbolic links `usr/lib/*.so`
1561 * Cmake rules `usr/lib/cmake` `usr/share/cmake`
1562 * Package config files `usr/lib/pkgconfig` `usr/share/pkgconfig`
1563 * Autoconf macros `usr/share/aclocal`
1564 * Gobject introspection XML files `usr/share/gir-1.0`
1565 * Vala bindings `usr/share/vala`
1567 <a id="pkgs_data"></a>
1568 #### Data packages
1570 Another common subpackage type is the `-data` subpackage. This subpackage
1571 type used to split architecture independent, big(ger) or huge amounts
1572 of data from a package's main and architecture dependent part. It is up
1573 to you to decide, if a `-data` subpackage makes sense for your package.
1574 This type is common for games (graphics, sound and music), part libraries (CAD)
1575 or card material (maps).
1576 The main package must then have `depends="${pkgname}-data-${version}_${revision}"`,
1577 possibly in addition to other, non-automatic depends.
1579 <a id="pkgs_documentation"></a>
1580 #### Documentation packages
1582 Packages intended for user interaction do not always unconditionally require
1583 their documentation part. A user who does not want to e.g. develop
1584 with Qt5 will not need to install the (huge) qt5-doc package.
1585 An expert may not need it or opt to use an online version.
1587 In general a `-doc` package is useful, if the main package can be used both with
1588 or without documentation and the size of the documentation isn't really small.
1589 The base package and the `-devel` subpackage should be kept small so that when
1590 building packages depending on a specific package there is no need to install large
1591 amounts of documentation for no reason. Thus the size of the documentation part should
1592 be your guidance to decide whether or not to split off a `-doc` subpackage.
1594 <a id="pkgs_python"></a>
1595 #### Python packages
1597 Python packages should be built with the `python{,2,3}-module` build style, if possible.
1598 This sets some environment variables required to allow cross compilation. Support to allow
1599 building a python module for multiple versions from a single template is also possible.
1600 The `python3-pep517` build style provides means to build python packages that provide a build-system
1601 definition compliant with [PEP 517](https://www.python.org/dev/peps/pep-0517/) without a traditional
1602 `setup.py` script. The `python3-pep517` build style does not provide a specific build backend, so
1603 packages will need to add an appropriate backend provider to `hostmakedepends`.
1605 Python packages that rely on `python3-setuptools` should generally map `setup_requires`
1606 dependencies in `setup.py` to `hostmakedepends` in the template and `install_requires`
1607 dependencies to `depends` in the template; include `python3` in `depends` if there are no other
1608 python dependencies. If the package includes a compiled extension, the `python3-devel` packages
1609 should be added to `makedepends`, as should any python packages that also provide native libraries
1610 against which the extension will be linked (even if that package is also included in
1611 `hostmakedepends` to satisfy `setuptools`).
1613 **NB**: Python `setuptools` will attempt to use `pip` or `EasyInstall` to fetch any missing
1614 dependencies at build time. If you notice warnings about `EasyInstall` deprecation or python eggs
1615 present in `${wrksrc}/.eggs` after building the package, then those packages should be added to
1616 `hostmakedepends`.
1618 The following variables may influence how the python packages are built and configured
1619 at post-install time:
1621 - `pycompile_module`: By default, files and directories installed into
1622 `usr/lib/pythonX.X/site-packages`, excluding `*-info` and `*.so`, are byte-compiled
1623 at install time as python modules.  This variable expects subset of them that
1624 should be byte-compiled, if default is wrong.  Multiple python modules may be specified separated
1625 by blanks, Example: `pycompile_module="foo blah"`. If a python module installs a file into
1626 `site-packages` rather than a directory, use the name of the file, Example:
1627 `pycompile_module="fnord.py"`.
1629 - `pycompile_dirs`: this variable expects the python directories that should be `byte-compiled`
1630 recursively by the target python version. This differs from `pycompile_module` in that any
1631 path may be specified, Example: `pycompile_dirs="usr/share/foo"`.
1633 - `python_version`: this variable expects the supported Python major version.
1634 In most cases version is inferred from shebang, install path or build style.
1635 Only required for some multi-language
1636 applications (e.g., the application is written in C while the command is
1637 written in Python) or just single Python file ones that live in `/usr/bin`.
1638 If `python_version` is set to `ignore`, python-containing shebangs will not be rewritten.
1639 Use this only if a package should not be using a system version of python.
1641 Also, a set of useful variables are defined to use in the templates:
1643 | Variable    | Value                            |
1644 |-------------|----------------------------------|
1645 | py2_ver     | 2.X                              |
1646 | py2_lib     | usr/lib/python2.X                |
1647 | py2_sitelib | usr/lib/python2.X/site-packages  |
1648 | py2_inc     | usr/include/python2.X            |
1649 | py3_ver     | 3.X                              |
1650 | py3_lib     | usr/lib/python3.X                |
1651 | py3_sitelib | usr/lib/python3.X/site-packages  |
1652 | py3_inc     | usr/include/python3.Xm           |
1654 > NOTE: it's expected that additional subpkgs must be generated to allow packaging for multiple
1655 python versions.
1657 <a id="pkgs_go"></a>
1658 #### Go packages
1660 Go packages should be built with the `go` build style, if possible.
1661 The `go` build style takes care of downloading Go dependencies and
1662 setting up cross compilation.
1664 The following template variables influence how Go packages are built:
1666 - `go_import_path`: The import path of the package included in the
1667   distfile, as it would be used with `go get`. For example, GitHub's
1668   `hub` program has the import path `github.com/github/hub`. This
1669   variable is required.
1670 - `go_package`: A space-separated list of import paths of the packages
1671   that should be built. Defaults to `go_import_path`.
1672 - `go_build_tags`: An optional, space-separated list of build tags to
1673   pass to Go.
1674 - `go_mod_mode`: The module download mode to use. May be `off` to ignore
1675   any go.mod files, `default` to use Go's default behavior, or anything
1676   accepted by `go build -mod MODE`.  Defaults to `vendor` if there's
1677   a vendor directory, otherwise `default`.
1678 - `go_ldflags`: Arguments to pass to the linking steps of go tool.
1680 The following environment variables influence how Go packages are built:
1682 - `XBPS_MAKEJOBS`: Value passed to the `-p` flag of `go install`, to
1683   control the parallelism of the Go compiler.
1685 Occasionally it is necessary to perform operations from within the Go
1686 source tree.  This is usually needed by programs using go-bindata or
1687 otherwise preping some assets.  If possible do this in pre_build().
1688 The path to the package's source inside `$GOPATH` is available as
1689 `$GOSRCPATH`.
1691 <a id="pkgs_haskell"></a>
1692 #### Haskell packages
1694 We build Haskell package using `stack` from
1695 [Stackage](http://www.stackage.org/), generally the LTS versions.
1696 Haskell templates need to have host dependencies on `ghc` and `stack`,
1697 and set build style to `haskell-stack`.
1699 The following variables influence how Haskell packages are built:
1701 - `stackage`: The Stackage version used to build the package, e.g.
1702   `lts-3.5`. Alternatively:
1703   - You can prepare a `stack.yaml` configuration for the project and put it
1704     into `files/stack.yaml`.
1705   - If a `stack.yaml` file is present in the source files, it will be used
1706 - `make_build_args`: This is passed as-is to `stack build ...`, so
1707   you can add your `--flag ...` parameters there.
1709 <a id="pkgs_font"></a>
1710 #### Font packages
1712 Font packages are very straightforward to write, they are always set with the
1713 following variables:
1715 - `depends="font-util"`: because they are required for regenerating the font
1716 cache during the install/removal of the package
1717 - `font_dirs`: which should be set to the directory where the package
1718 installs its fonts
1720 <a id="pkg_rename"></a>
1721 ### Renaming a package
1723 - Create empty package of old name, depending on new package. This is
1724 necessary to provide updates to systems where old package is already
1725 installed. This should be a subpackage of new one, except when version
1726 number of new package decreased: then create a separate template using
1727 old version and increased revision.
1728 - Edit references to package in other templates and common/shlibs.
1729 - Don't set `replaces=`, it can result in removing both packages from
1730 systems by xbps.
1732 <a id="pkg_remove"></a>
1733 ### Removing a package
1735 Follows a list of things that should be done to help guarantee that a
1736 package template removal and by extension its binary packages from
1737 Void Linux's repositories goes smoothly.
1739 Before removing a package template:
1741 - Guarantee that no package depends on it or any of its subpackages.
1742 For that you can search the templates for references to the package
1743 with `grep -r '\bpkg\b' srcpkgs/`.
1744 - Guarantee that no package depends on shlibs provided by it.
1746 When removing the package template:
1748 - Remove all symlinks that point to the package.
1749 `find srcpkgs/ -lname <pkg>` should be enough.
1750 - If the package provides shlibs make sure to remove them from
1751 common/shlibs.
1752 - Some packages use patches and files from other packages using symlinks,
1753 generally those packages are the same but have been split as to avoid
1754 cyclic dependencies. Make sure that the package you're removing is not
1755 the source of those patches/files.
1756 - Remove package template.
1757 - Add `pkgname<=version_revision` to `replaces` variable of `removed-packages`
1758 template.  All removed subpkgs should be added too.
1759 This will uninstall package from systems where it is installed.
1760 - Remove the package from the repository index
1761 or contact a team member that can do so.
1763 <a id="xbps_triggers"></a>
1764 ### XBPS Triggers
1766 XBPS triggers are a collection of snippets of code, provided by the `xbps-triggers`
1767 package, that are added to the INSTALL/REMOVE scripts of packages either manually
1768 by setting the `triggers` variable in the template, or automatically, when specific
1769 conditions are met.
1771 The following is a list of all available triggers, their current status, what each
1772 of them does and what conditions need to be for it to be included automatically on a
1773 package.
1775 This is not a complete overview of the package. It is recommended to read the variables
1776 referenced and the triggers themselves.
1778 <a id="triggers_appstream_cache"></a>
1779 #### appstream-cache
1781 The appstream-cache trigger is responsible for rebuilding the appstream metadata cache.
1783 During installation it executes `appstreamcli refresh-cache --verbose --force --datapath
1784 $APPSTREAM_PATHS --cachepath var/cache/app-info/gv`. By default APPSTREAM_PATHS are all the
1785 paths that appstreamcli will look into for metadata files.
1787 The directories searched by appstreamcli are:
1789 - `usr/share/appdata`
1790 - `usr/share/app-info`
1791 - `var/lib/app-info`
1792 - `var/cache/app-info`
1794 During removal of the `AppStream` package it will remove the `var/cache/app-info/gv`
1795 directory.
1797 It is automatically added to packages that have XML files under one of the directories
1798 searched by appstreamcli.
1800 <a id="triggers_binfmts"></a>
1801 #### binfmts
1803 The binfmts trigger is responsible for registration and removal of arbitrary
1804 executable binary formats, know as binfmts.
1806 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
1807 to register/remove entries from the arbitrary executable binary formats database.
1809 It is automatically added to packages that contain files in `usr/share/binfmts`.
1810 These files should be `update-binfmts` format files and will be imported with
1811 `update-binfmts --import`.
1813 While it is not preferred, the trigger can also be added by using the `binfmts` variable,
1814 which should contain lines defining binfmts to register:
1817 /path/to/interpreter [update-binfmts binary format specification arguments ...]
1821 See [`update-binfmts(8)`](https://man.voidlinux.org/man8/update-binfmts.8) for more details.
1823 <a id="triggers_dkms"></a>
1824 #### dkms
1826 The dkms trigger is responsible for compiling and removing dynamic kernel modules of a
1827 package.
1829 During installation the trigger compiles and installs the dynamic module for all `linux`
1830 packages that have their corresponding linux-headers package installed. During removal
1831 the corresponding module will be removed
1833 To include the trigger use the `dkms_modules` variable, as the trigger won't do anything
1834 unless it is defined.
1836 <a id="triggers_gconf_schemas"></a>
1837 #### gconf-schemas
1839 The gconf-schemas trigger is responsible for registering and removing .schemas and
1840 .entries files into the schemas database directory
1842 During installation it uses `gconftool-2` to install .schemas and .entries files into
1843 `usr/share/gconf/schemas`. During removal it uses `gconftool-2` to remove the entries
1844 and schemas belonging to the package that is being removed from the database.
1846 To include it add `gconf-schemas` to `triggers` and add the appropriate .schemas in
1847 the `gconf_schemas` variable and .entries in `gconf_entries`.
1849 It is automatically added to packages that have `/usr/share/gconf/schemas` present
1850 as a directory. All files with the schemas file extension under that directory
1851 are passed to the trigger.
1853 <a id="triggers_gdk_pixbuf_loaders"></a>
1854 #### gdk-pixbuf-loaders
1856 The gdk-pixbuf-loaders trigger is responsible for maintaining the GDK Pixbuf loaders cache.
1858 During installation it runs `gdk-pixbuf-query-loaders --update-cache` and also deletes
1859 the obsolete `etc/gtk-2.0/gdk-pixbuf.loaders` file if present. During removal of the
1860 gdk-pixbuf package it removes the cache file if present. Normally at
1861 `usr/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache`.
1863 It can be added by defining `gdk-pixbuf-loaders` in the `triggers` variable. It is also
1864 added automatically to any package that has the path `usr/lib/gdk-pixbuf-2.0/2.10.0/loaders`
1865 available as a directory.
1867 <a id="triggers_gio_modules"></a>
1868 #### gio-modules
1870 The gio-modules trigger is responsible for updating the Glib GIO module cache with
1871 `gio-querymodules` from the `glib` package
1873 During install and removal it just runs `gio-querymodules` to update the cache file
1874 present under `usr/lib/gio/modules`.
1876 It is automatically added to packages that have `/usr/lib/gio/modules` present
1877 as a directory.
1879 <a id="triggers_gsettings_schemas"></a>
1880 #### gsettings-schemas
1882 The gsettings-schemas trigger is responsible for compiling Glib's GSettings XML
1883 schema files during installation and removing the compiled files during removal.
1885 During installation it uses `glib-compile-schemas` from `glib` to compile the
1886 schemas into files with the suffix .compiled into `/usr/share/glib-2.0/schemas`.
1888 During removal of the glib package it deletes all files inside
1889 `/usr/share/glib-2.0/schemas` that end with .compiled.
1891 It is automatically added to packages that have `/usr/share/glib-2.0/schemas` present
1892 as a directory.
1894 <a id="triggers_gtk_icon_cache"></a>
1895 #### gtk-icon-cache
1897 The gtk-icon-cache trigger is responsible for updating the gtk+ icon cache.
1899 During installation it uses `gtk-update-icon-cache` to update the icon cache.
1901 During removal of the gtk+ package it deletes the `icon-theme.cache` file
1902 in the directories defined by the variable `gtk_iconcache_dirs`.
1904 It is automatically added on packages that have `/usr/share/icons` available
1905 as a directory, all directories under that directory have their absolute path
1906 passed to the trigger.
1908 <a id="triggers_gtk_immodules"></a>
1909 #### gtk-immodules
1911 The gtk-immodules trigger is responsible for updating the IM (Input Method) modules
1912 file for gtk+.
1914 During installation it uses `gtk-query-immodules-2.0 --update-cache` to update the
1915 cache file. It also removes the obsolete configuration file  `etc/gtk-2.0/gtk.immodules`
1916 if present.
1918 During removal of the `gtk+` package it removes the cache file which is located at
1919 `usr/lib/gtk-2.0/2.10.0/immodules.cache`.
1921 It is automatically added to packages that have `/usr/lib/gtk-2.0/2.10.0/immodules`
1922 present as a directory.
1924 <a id="triggers_gtk_pixbuf_loaders"></a>
1925 #### gtk-pixbuf-loaders
1927 gtk-pixbuf-loaders is the old name for the current `gdk-pixbuf-loaders` trigger and is
1928 in the process of being removed. It currently re-execs into `gdk-pixbuf-loaders` as a
1929 compatibility measure.
1931 For information about how it works refer to [gdk-pixbuf-loaders](#triggers_gdk_pixbuf_loaders).
1933 <a id="triggers_gtk3_immodules"></a>
1934 #### gtk3-immodules
1936 The gtk3-immodules trigger is responsible for updating the IM (Input Method) modules
1937 file for gtk+3.
1939 During installation it executes `gtk-query-immodules-3.0 --update-cache` to update the
1940 cache file. It also removes the obsolete configuration file  `etc/gtk-3.0/gtk.immodules`
1941 if present.
1943 During removal of the `gtk+3` package it removes the cache file which is located at
1944 `usr/lib/gtk-3.0/3.0.0/immodules.cache`.
1946 It is automatically added to packages that have `/usr/lib/gtk-3.0/3.0.0/immodules`
1947 present as a directory.
1949 <a id="triggers_hwdb.d_dir"></a>
1950 #### hwdb.d-dir
1952 The hwdb.d-dir trigger is responsible for updating the hardware database.
1954 During installation and removal it runs `usr/bin/udevadm hwdb --root=. --update`.
1956 It is automatically added to packages that have `/usr/lib/udev/hwdb.d` present
1957 as a directory.
1959 <a id="triggers_info_files"></a>
1960 #### info-files
1962 The info-files trigger is responsible for registering and unregistering the GNU info
1963 files of a package.
1965 It checks the existence of the info files presented to it and if it is running under
1966 another architecture.
1968 During installation it uses `install-info` to register info files into
1969 `usr/share/info`.
1971 During removal it uses `install-info --delete` to remove the info files from the
1972 registry located at `usr/share/info`.
1974 If it is running under another architecture it tries to use the host's `install-info`
1975 utility.
1977 <a id="triggers_initramfs_regenerate"></a>
1978 #### initramfs-regenerate
1980 The initramfs-regenerate trigger will trigger the regeneration of all kernel
1981 initramfs images after package installation or removal. The trigger must be
1982 manually requested.
1984 This hook is probably most useful for DKMS packages because it will provide a
1985 means to include newly compiled kernel modules in initramfs images for all
1986 currently available kernels. When used in a DKMS package, it is recommended to
1987 manually include the `dkms` trigger *before* the `initramfs-regenerate` trigger
1988 using, for example,
1990     ```
1991     triggers="dkms initramfs-regenerate"
1992     ```
1994 Although `xbps-src` will automatically include the `dkms` trigger whenever
1995 `dkms_modules` is installed, the automatic addition will come *after*
1996 `initramfs-regenerate`, which will cause initramfs images to be recreated
1997 before the modules are compiled.
1999 By default, the trigger uses `dracut --regenerate-all` to recreate initramfs
2000 images. If `/etc/default/initramfs-regenerate` exists and defines
2001 `INITRAMFS_GENERATOR=mkinitcpio`, the trigger will instead use `mkinitcpio` and
2002 loop over all kernel versions for which modules appear to be installed.
2003 Alternatively, setting `INITRAMFS_GENERATOR=none` will disable image
2004 regeneration entirely.
2006 <a id="triggers_kernel_hooks"></a>
2007 #### kernel-hooks
2009 The kernel-hooks trigger is responsible for running scripts during installation/removal
2010 of kernel packages.
2012 The available targets are pre-install, pre-remove, post-install and post-remove.
2014 When run it will try to run all executables found under `etc/kernel.d/$TARGET`. The
2015 `TARGET` variable is one of the 4 targets available for the trigger. It will also
2016 create the directory if it isn't present.
2018 During updates it won't try to run any executables when running with the pre-remove
2019 target.
2021 It is automatically added if the helper variable `kernel_hooks_version` is defined.
2022 However it is not obligatory to have it defined.
2024 <a id="triggers_mimedb"></a>
2025 #### mimedb
2027 The mimedb trigger is responsible for updating the shared-mime-info database.
2029 In all runs it will just execute `update-mime-database -n usr/share/mime`.
2031 It is automatically added to packages that have `/usr/share/mime` available as
2032 a directory.
2034 <a id="triggers_mkdirs"></a>
2035 #### mkdirs
2037 The mkdirs trigger is responsible for creating and removing directories dictated
2038 by the `make_dirs` variable.
2040 During installation it takes the `make_dirs` variable and splits it into groups of
2041 4 variables.
2043 - dir = full path to the directory
2044 - mode = Unix permissions for the directory
2045 - uid = name of the owning user
2046 - gid = name of the owning group
2048 It will continue to split the values of `make_dirs` into groups of 4 until the values
2049 end.
2051 During installation it will create a directory with `dir` then set mode with `mode`
2052 and permission with `uid:gid`.
2054 During removal it will delete the directory using `rmdir`.
2056 To include this trigger use the `make_dirs` variable, as the trigger won't do anything
2057 unless it is defined.
2059 <a id="triggers_pango_module"></a>
2060 #### pango-modules
2062 The pango-modules trigger is currently being removed since upstream has removed the
2063 code responsible for it.
2065 It used to update the pango modules file with `pango-modulesquery` during installation
2066 of any package.
2068 Currently it removes `etc/pango/pango.modules` file during removal of the pango package.
2070 It can be added by defining `pango-modules` in the `triggers` variable and has no way to get
2071 added automatically to a package.
2073 <a id="triggers_pycompile"></a>
2074 #### pycompile
2076 The pycompile trigger is responsible for compiling python code into native
2077 bytecode and removing generated bytecode.
2079 During installation it will compile all python code under the paths it is given by
2080 `pycompile_dirs` and all modules described in `pycompile_module` into native bytecode and
2081 update the ldconfig(8) cache.
2083 During removal it will remove all the native bytecode and update the ldconfig(8) cache.
2085 To include this trigger use the variables `pycompile_dirs` and `pycompile_module`. The
2086 trigger won't do anything unless at least one of those variables is defined.
2088 A `python_version` variable can be set to direct behaviour of the trigger.
2090 <a id="triggers_register_shell"></a>
2091 #### register-shell
2093 The register-shell trigger is responsible for registering and removing shell entries
2094 into `etc/shells`.
2096 During installation it will append the `etc/shells` file with the new shell and also
2097 change the permissions to `644` on the file.
2099 During removal it will use `sed` to delete the shell from the file.
2101 To include this trigger use the `register_shell` variable, as the trigger won't do
2102 anything unless it is defined.
2104 <a id="triggers_system_accounts"></a>
2105 #### system-accounts
2107 The system-accounts trigger is responsible for creating and disabling system accounts
2108 and groups.
2110 During removal it will disable the account by setting the Shell to /bin/false,
2111 Home to /var/empty, and appending ' - for uninstalled package $pkgname' to the
2112 Description.
2113 Example: `transmission unprivileged user - for uninstalled package transmission`
2115 This trigger can only be used by using the `system_accounts` variable.
2117 <a id="triggers_texmf_dist"></a>
2118 #### texmf-dist
2120 The texmf-dist trigger is responsible for regenerating TeXLive's texmf databases.
2122 During both installation and removal, it regenerates both the texhash and format
2123 databases using `texhash` and `fmtutil-sys`, to add or remove any new hashes or
2124 formats.
2126 It runs on every package that changes /usr/share/texmf-dist. This is likely overkill,
2127 but it is much cleaner rather than checking each format directory and each directory
2128 that is hashed. In addition, it is very likely any package touching /usr/share/texmf-dist
2129 requires one of these triggers anyway.
2131 <a id="triggers_update_desktopdb"></a>
2132 #### update-desktopdb
2134 The update-desktopdb trigger is responsible for updating the system's MIME database.
2136 During installation it will execute `update-desktop-database usr/share/applications`
2137 which will result in a cache file being created at `usr/share/applications/mimeinfo.cache`.
2139 During removal of the `desktop-file-utils` package it will remove the cache file that
2140 was created during installation.
2142 It is automatically added to packages that have `/usr/share/applications` available as
2143 a directory.
2145 <a id="triggers_x11_fonts"></a>
2146 #### x11-fonts
2148 The x11-fonts trigger is responsible for rebuilding the fonts.dir and fonts.scale files
2149 for packages that install X11 fonts, and update fontconfig's cache for these fonts.
2151 During installation and removal it executes `mkfontdir`, `mkfontscale` and `fc-cache` for
2152 all font directories it was given via the `font_dirs` variable.
2154 To include this trigger use the `font_dirs` variable, as the trigger won't do anything
2155 unless it is defined.
2157 <a id="triggers_xml_catalog"></a>
2158 #### xml-catalog
2160 The xml-catalog trigger is responsible for registering and removing SGML/XML catalog entries.
2162 During installation it uses `xmlcatmgr` to register all catalogs, passed to it by the
2163 `sgml_entries` and `xml_entries` variables, in `usr/share/sgml/catalog` and
2164 `usr/share/xml/catalog` respectively.
2166 During removal it uses `xmlcatmgr` to remove all catalogs passed to it by the
2167 `sgml_entries` and `xml_entries` variables, in `usr/share/sgml/catalog` and
2168 `usr/share/xml/catalog` respectively.
2170 To include this trigger use the `sgml_entries` variable or/and the `xml_entries` variable,
2171 as the trigger won't do anything unless either of them are defined.
2173 <a id="documentation"></a>
2174 ### Void specific documentation
2176 When you want document details of package's configuration and usage specific to Void Linux,
2177 not covered by upstream documentation, put notes into
2178 `srcpkgs/<pkgname>/files/README.voidlinux` and install with
2179 `vdoc "${FILESDIR}/README.voidlinux"`.
2181 <a id="notes"></a>
2182 ### Notes
2184 - Make sure that all software is configured to use the `/usr` prefix.
2186 - Binaries should always be installed at `/usr/bin`.
2188 - Manual pages should always be installed at `/usr/share/man`.
2190 - If a software provides **shared libraries** and headers, probably you should
2191 create a `development package` that contains `headers`, `static libraries`
2192 and other files required for development (not required at runtime).
2194 - If you are updating a package please be careful with SONAME bumps, check
2195 the installed files (`./xbps-src show-files pkg`) before pushing new updates.
2197 - Make sure that binaries are not stripped by the software, let xbps-src do this;
2198 otherwise the `debug` packages won't have debugging symbols.
2200 <a id="contributing"></a>
2201 ### Contributing via git
2203 To get started, [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) the void-linux `void-packages` git repository on GitHub and clone it:
2205     $ git clone git@github.com:<user>/void-packages.git
2207 See [CONTRIBUTING.md](./CONTRIBUTING.md) for information on how to format your
2208 commits and other tips for contributing.
2210 Once you've made changes to your `forked` repository, submit
2211 a github pull request.
2213 To keep your forked repository always up to date, setup the `upstream` remote
2214 to pull in new changes:
2216     $ git remote add upstream https://github.com/void-linux/void-packages.git
2217     $ git pull --rebase upstream master
2219 <a id="help"></a>
2220 ### Help
2222 If after reading this `manual` you still need some kind of help, please join
2223 us at `#xbps` via IRC at `irc.libera.chat`.