The Void source packages collection
This repository contains the XBPS source packages collection to build binary packages for the Void Linux distribution.
xbps-srcscript will fetch and compile the sources, and install its files into a
fake destdirto generate XBPS binary packages that can be installed or queried through the
For bootstrapping additionally: - flock(1) - util-linux - bsdtar or GNU tar (in that order of preference) - install(1) - GNU coreutils - objcopy(1), objdump(1), strip(1): binutils
xbps-srcrequires a utility to chroot and bind mount existing directories into a
masterdirthat is used as its main
xbps-srcsupports multiple utilities to accomplish this task:
bwrap- bubblewrap, see https://github.com/projectatomic/bubblewrap.
ethereal- only useful for one-shot containers, i.e docker (used with CI).
xbps-uunshare(1)- XBPS utility that uses
user_namespaces(7)(part of xbps, default).
xbps-uchroot(1)- XBPS utility that uses
namespacesand must be
setgid(part of xbps).
NOTE:xbps-srcdoes not allow building as root anymore. Use one of the chroot methods shown above.
void-packagesgit repository and install the bootstrap packages:
$ git clone git://github.com/void-linux/void-packages.git $ cd void-packages $ ./xbps-src binary-bootstrap
Build a package by specifying the
pkgtarget and the package name:
$ ./xbps-src pkg
./xbps-src -hto list all available targets and options.
To build packages marked as 'restricted', modify
$ echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
Once built, the package will be available in
hostdir/binpkgsor an appropriate subdirectory (e.g.
hostdir/binpkgs/nonfree). To install the package:
# xbps-install --repository hostdir/binpkgs
Alternatively, packages can be installed with the
xiutility, from the
xitakes the repository of the current working directory into account.
This utility requires these Linux kernel options:
This is the default method, and if your system does not support any of the required kernel options it will fail with
EINVAL (Invalid argument).
This utility requires these Linux kernel options:
Your user must be added to a special group to be able to use
xbps-uchroot(1)and the executable must be
# chown root: xbps-uchroot # chmod 4750 xbps-uchroot # usermod -a -G
NOTE: by default in void you shouldn't do this manually, your user must be a member of thexbuildergroup.
To enable it:
$ cd void-packages $ echo XBPS_CHROOT_CMD=uchroot >> etc/conf
If for some reason it's erroring out as
ERROR clone (Operation not permitted), check that your user is a member of the required
xbps-uchroot(1)utility has the proper permissions and owner/group as explained above.
There is a set of packages that makes up the initial build container, called the
bootstrap. These packages are installed into the
masterdirin order to create the container.
The primary and recommended way to set up this container is using the
binary-bootstrapcommand. This will use pre-existing binary packages, either from remote
xbpsrepositories or from your local repository.
There is also the
bootstrapcommand, which will build all necessary
bootstrappackages from scratch. This is usually not recommended, since those packages are built using your host system's toolchain and are neither fully featured nor reproducible (your host system may influence the build) and thus should only be used as a stage 0 for bootstrapping new Void systems.
If you still choose to use
bootstrap, use the resulting stage 0 container to rebuild all
bootstrappackages again, then use
binary-bootstrap(stage 1) and rebuild the
bootstrappackages once more (to gain stage 2, and then use
binary-bootstrapagain). Once you've done that, you will have a
bootstrapset equivalent to using
binary-bootstrapin the first place.
Also keep in mind that a full source
bootstrapis time consuming and will require having an assortment of utilities installed in your host system, such as
etc/defaults.conffile contains the possible settings that can be overridden through the
etc/confconfiguration file for the
xbps-srcutility; if that file does not exist, will try to read configuration settings from
If you want to customize default
LDFLAGS, don't override those defined in
etc/defaults.conf, set them on
$ echo 'XBPS_CFLAGS="your flags here"' >> etc/conf $ echo 'XBPS_LDFLAGS="your flags here"' >> etc/conf
Native and cross compiler/linker flags are set per architecture in
common/cross-profilesrespectively. Ideally those settings are good enough by default, and there's no need to set your own unless you know what you are doing.
etc/defaults.virtualfile contains the default replacements for virtual packages, used as dependencies in the source packages tree.
If you want to customize those replacements, copy
etc/virtualand edit it accordingly to your needs.
The following directory hierarchy is used with a default configuration file:
/void-packages |- common |- etc |- srcpkgs | |- xbps | |- template | |- hostdir | |- binpkgs ... | |- ccache ... | |- distcc- ... | |- repocache ... | |- sources ... | |- masterdir | |- builddir -> ... | |- destdir -> ... | |- host -> bind mounted from | |- void-packages -> bind mounted from
The description of these directories is as follows:
masterdir: master directory to be used as rootfs to build/install packages.
builddir: to unpack package source tarballs and where packages are built.
destdir: to install packages, aka fake destdir.
hostdir/ccache: to store ccache data if the
XBPS_CCACHEoption is enabled.
hostdir/distcc-: to store distcc data if the
XBPS_DISTCCoption is enabled.
hostdir/repocache: to store binary packages from remote repositories.
hostdir/sources: to store package sources.
hostdir/binpkgs: local repository to store generated binary packages.
The simplest form of building package is accomplished by running the
$ cd void-packages $ ./xbps-src pkg
When the package and its required dependencies are built, the binary packages will be created and registered in the default local repository at
hostdir/binpkgs; the path to this local repository can be added to any xbps configuration file (see xbps.d(5)) or by explicitly appending them via cmdline, i.e:
$ xbps-install --repository=hostdir/binpkgs ... $ xbps-query --repository=hostdir/binpkgs ...
By default xbps-src will try to resolve package dependencies in this order:
It is possible to avoid using remote repositories completely by using the
The default local repository may contain multiple sub-repositories:debug,multilib, etc.
The supported build options for a source package can be shown with
$ ./xbps-src show-options foo
Build options can be enabled with the
$ ./xbps-src -o option,option1 pkg foo
Build options can be disabled by prefixing them with
$ ./xbps-src -o ~option,~option1 pkg foo
Both ways can be used together to enable and/or disable multiple options at the same time with
$ ./xbps-src -o option,~option1,~option2 pkg foo
The build options can also be shown for binary packages via
$ xbps-query -R --property=build-options foo
NOTE: if you build a package with a custom option, and that package is available in an official void repository, an update will ignore those options. Put that package onholdmode viaxbps-pkgdb(1), i.exbps-pkgdb -m hold footo ignore updates withxbps-install -u. Once the package is onhold, the only way to update it is by declaring it explicitly:xbps-install -u foo.
Permanent global package build options can be set via
XBPS_PKG_OPTIONSvariable in the
etc/confconfiguration file. Per package build options can be set via
NOTE: ifpkgnamecontainsdashes, those should be replaced byunderscoresi.eXBPS_PKG_OPTIONS_xorg_server=opt.
The list of supported package build options and its description is defined in the
common/options.descriptionfile or in the
To share a local repository remotely it's mandatory to sign it and the binary packages stored on it. This is accomplished with the
First a RSA key must be created with
$ openssl genrsa -des3 -out privkey.pem 4096
$ ssh-keygen -t rsa -b 4096 -m PEM -f privkey.pem
Only RSA keys in PEM format are currently accepted by xbps.
Once the RSA private key is ready you can use it to initialize the repository metadata:
$ xbps-rindex --sign --signedby "I'm Groot" --privkey privkey.pem $PWD/hostdir/binpkgs
And then make a signature per package:
$ xbps-rindex --sign-pkg --privkey privkey.pem $PWD/hostdir/binpkgs/*.xbps
If --privkey is unset, it defaults to~/.ssh/id_rsa.
If the RSA key was protected with a passphrase you'll have to type it, or alternatively set it via the
Once the binary packages have been signed, check the repository contains the appropriate
$ xbps-query --repository=hostdir/binpkgs -vL ...
Each time a binary package is created, a package signature must be created with
It is not possible to sign a repository with multiple RSA keys.
If for whatever reason a package has been built and it is available in your local repository and you have to rebuild it without bumping its
revisionfields, it is possible to accomplish this task easily with
$ ./xbps-src -f pkg xbps
Reinstalling this package in your target
rootdircan be easily done too:
$ xbps-install --repository=/path/to/local/repo -yff xbps-0.25_1
Please note that thepackage expressionmust be properly defined to explicitly pick up the package from the desired repository.
Setup the slaves (machines that will compile the code):
# xbps-install -Sy distcc
Modify the configuration to allow your local network machines to use distcc (e.g.
# echo "192.168.2.0/24" >> /etc/distcc/clients.allow
Enable and start the
# ln -s /etc/sv/distccd /var/service
Install distcc on the host (machine that executes xbps-src) as well. Unless you want to use the host as slave from other machines, there is no need to modify the configuration.
On the host you can now enable distcc in the
XBPS_DISTCC=yes XBPS_DISTCC_HOSTS="localhost/2 --localslots_cpp=24 192.168.2.101/9 192.168.2.102/2" XBPS_MAKEJOBS=16
The example values assume a localhost CPU with 4 cores of which at most 2 are used for compiler jobs. The number of slots for preprocessor jobs is set to 24 in order to have enough preprocessed data for other CPUs to compile. The slave 192.168.2.101 has a CPU with 8 cores and the /9 for the number of jobs is a saturating choice. The slave 192.168.2.102 is set to run at most 2 compile jobs to keep its load low, even if its CPU has 4 cores. The XBPS_MAKEJOBS setting is increased to 16 to account for the possible parallelism (2 + 9 + 2 + some slack).
In etc/conf you may optionally define a mirror or a list of mirrors to search for distfiles.
$ echo 'XBPS_DISTFILES_MIRROR="ftp://192.168.100.5/gentoo/distfiles"' >> etc/conf
If more than one mirror is to be searched, you can either specify multiple URLs separated with blanks, or add to the variable like this
$ echo 'XBPS_DISTFILES_MIRROR+=" https://sources.voidlinux.org/"' >> etc/conf
Make sure to put the blank after the first double quote in this case.
The mirrors are searched in order for the distfiles to build a package until the checksum of the downloaded file matches the one specified in the template.
Ultimately, if no mirror carries the distfile, or in case all downloads failed the checksum verification, the original download location is used.
If you use
uchrootfor your XBPSCHROOTCMD, you may also specify a local path using the
file://prefix or simply an absolute path on your build host (e.g. /mnt/distfiles). Mirror locations specified this way are bind mounted inside the chroot environment under $XBPS_MASTERDIR and searched for distfiles just the same as remote locations.
xbps-srccan cross build packages for some target architectures with a cross compiler. The supported target is shown with
If a source package has been adapted to be cross buildable
xbps-srcwill automatically build the binary package(s) with a simple command:
$ ./xbps-src -a pkg
If the build for whatever reason fails, might be a new build issue or simply because it hasn't been adapted to be cross compiled.
xbps-src can be used in any recent Linux distribution matching the CPU architecture.
To use xbps-src in your Linux distribution use the following instructions. Let's start downloading the xbps static binaries:
$ wget http://alpha.de.repo.voidlinux.org/static/xbps-static-latest.-musl.tar.xz $ mkdir ~/XBPS $ tar xvf xbps-static-latest.-musl.tar.xz -C ~/XBPS $ export PATH=~/XBPS/usr/bin:$PATH
If your system does not support
user namespaces, a privileged group is required to be able to use
xbps-uchroot(1)with xbps-src, by default it's set to the
xbuildergroup, change this to your desired group:
# chown root: ~/XBPS/usr/bin/xbps-uchroot.static # chmod 4750 ~/XBPS/usr/bin/xbps-uchroot.static
$ git clone git://github.com/void-linux/void-packages
xbps-srcshould be fully functional; just start the
$ ./xbps-src binary-bootstrap
The default masterdir is created in the current working directory, i.e
If for some reason you must update xbps-src and the
bootstrap-updatetarget is not enough, it's possible to recreate a masterdir with two simple commands (please note that
$ ./xbps-src zap $ ./xbps-src binary-bootstrap
Sometimes the bootstrap packages must be updated to the latest available version in repositories, this is accomplished with the
$ ./xbps-src bootstrap-update
Two ways are available to build 32bit packages on x86_64:
The first mode (cross compilation) is as easy as:
$ ./xbps-src -a i686 pkg ...
The second mode (native) needs a new x86
$ ./xbps-src -m masterdir-x86 binary-bootstrap i686 $ ./xbps-src -m masterdir-x86 ...
Canonical way of building packages for same architecture but different C library is through dedicated masterdir. To build for x8664-musl on glibc x8664 system, prepare a new masterdir with the musl packages:
$ ./xbps-src -m masterdir-x86_64-musl binary-bootstrap x86_64-musl
Your new masterdir is now ready to build packages natively for the musl C library:
$ ./xbps-src -m masterdir-x86_64-musl pkg ...
To rebuild all packages in
base-systemfor your native architecture:
$ ./xbps-src -N pkg base-system
It's also possible to cross compile everything from scratch:
$ ./xbps-src -a -N pkg base-system
Once the build has finished, you can specify the path to the local repository to
# cd void-mklive # make # ./mklive.sh ... -r /path/to/hostdir/binpkgs