Build a package by specifying the `pkg` target and the package name:
```
$ ./xbps-src pkg <package_name>
```
Use `./xbps-src -h` to list all available targets and options.
To build packages marked as 'restricted', modify `etc/conf`:
```
$ echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
```
Once built, the package will be available in `hostdir/binpkgs` or an appropriate subdirectory (e.g. `hostdir/binpkgs/nonfree`). To install the package:
Alternatively, packages can be installed with the `xi` utility, from the `xtools` package. `xi` takes the repository of the current working directory into account.
```
$ xi <package_name>
```
<aname="chroot-methods"></a>
### chroot methods
#### xbps-uunshare(1) (default)
XBPS utility that uses `user_namespaces(7)` (part of xbps, default without `-t` flag).
This utility requires these Linux kernel options:
- CONFIG\_NAMESPACES
- CONFIG\_IPC\_NS
- CONFIG\_UTS\_NS
- CONFIG\_USER\_NS
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)`.
#### xbps-uchroot(1)
XBPS utility that uses `namespaces` and must be `setgid` (part of xbps).
> NOTE: This is the only method that implements functionality of `xbps-src -t`, therefore the
flag ignores the choice made in configuration files and enables `xbps-uchroot`.
This utility requires these Linux kernel options:
- CONFIG\_NAMESPACES
- CONFIG\_IPC\_NS
- CONFIG\_PID\_NS
- CONFIG\_UTS\_NS
Your user must be added to a special group to be able to use `xbps-uchroot(1)` and the
executable must be `setgid`:
# chown root:<group> xbps-uchroot
# chmod 4750 xbps-uchroot
# usermod -a -G <group><user>
> NOTE: by default in void you shouldn't do this manually, your user must be a member of
the `xbuilder` group.
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 `group` and that `xbps-uchroot(1)` utility has the
proper permissions and owner/group as explained above.
#### bwrap(1)
bubblewrap, sandboxing tool for unprivileged users that uses
user namespaces or setuid.
See <https://github.com/containers/bubblewrap>.
#### ethereal
Destroys host system it runs on. Only useful for one-shot containers, i.e docker (used with CI).
<aname="install-bootstrap"></a>
### Install the bootstrap packages
There is a set of packages that makes up the initial build container, called the `bootstrap`.
These packages are installed into the `masterdir` in order to create the container.
The primary and recommended way to set up this container is using the `binary-bootstrap`
command. This will use pre-existing binary packages, either from remote `xbps` repositories
or from your local repository.
There is also the `bootstrap` command, which will build all necessary `bootstrap` packages 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
`bootstrap` packages again, then use `binary-bootstrap` (stage 1) and rebuild the `bootstrap`
packages once more (to gain stage 2, and then use `binary-bootstrap` again). Once you've done
that, you will have a `bootstrap` set equivalent to using `binary-bootstrap` in the first place.
Also keep in mind that a full source `bootstrap` is time consuming and will require having an
assortment of utilities installed in your host system, such as `binutils`, `gcc`, `perl`,
`texinfo` and others.
### Configuration
The `etc/defaults.conf` file contains the possible settings that can be overridden
through the `etc/conf` configuration file for the `xbps-src` utility; if that file
does not exist, will try to read configuration settings from `$XDG_CONFIG_HOME/xbps-src.conf`, `~/.config/xbps-src.conf`, `~/.xbps-src.conf`.
If you want to customize default `CFLAGS`, `CXXFLAGS` and `LDFLAGS`, don't override
those defined in `etc/defaults.conf`, set them on `etc/conf` instead i.e:
and `xbps-src` should be fully functional; just start the `bootstrap` process, i.e:
$ ./xbps-src binary-bootstrap
The default masterdir is created in the current working directory, i.e. `void-packages/masterdir-<arch>`, where `<arch>` for the default masterdir is is the native xbps architecture.
<aname="remaking-masterdir"></a>
### Remaking the masterdir
If for some reason you must update xbps-src and the `bootstrap-update` target is not enough, it's possible to recreate a masterdir with two simple commands (please note that `zap` keeps your `ccache/distcc/host` directories intact):
$ ./xbps-src zap
$ ./xbps-src binary-bootstrap
<aname="updating-masterdir"></a>
### Keeping your masterdir uptodate
Sometimes the bootstrap packages must be updated to the latest available version in repositories, this is accomplished with the `bootstrap-update` target:
$ ./xbps-src bootstrap-update
<aname="building-32bit"></a>
### Building 32bit packages on x86_64
Two ways are available to build 32bit packages on x86\_64:
- native mode with a 32bit masterdir (recommended, used in official repository)
- cross compilation mode to i686 [target](#cross-compiling)
The canonical mode (native) needs a new x86 `masterdir`:
$ ./xbps-src -A i686 binary-bootstrap
$ ./xbps-src -A i686 ...
<aname="building-for-musl"></a>
### Building packages natively for the musl C library
The canonical way of building packages for same architecture but different C library is through a dedicated masterdir by using the host architecture flag `-A`.
To build for x86_64-musl on glibc x86_64 system, prepare a new masterdir with the musl packages:
$ ./xbps-src -A x86_64-musl binary-bootstrap
This will create and bootstrap a new masterdir called `masterdir-x86_64-musl` that will be used when `-A x86_64-musl` is specified.
Your new masterdir is now ready to build packages natively for the musl C library:
$ ./xbps-src -A x86_64-musl pkg ...
<aname="building-base-system"></a>
### Building void base-system from scratch
To rebuild all packages in `base-system` for your native architecture:
$ ./xbps-src -N pkg base-system
It's also possible to cross compile everything from scratch:
$ ./xbps-src -a <target> -N pkg base-system
Once the build has finished, you can specify the path to the local repository to `void-mklive`, i.e: