|
Monero
|

Files | |
| gitian-build.py | |
Setup instructions for a Gitian build of Monero.
Gitian is the deterministic build process that is used to build the Monero CLI executables. It provides a way to be reasonably sure that the executables are really built from the git source. It also makes sure that the same, tested dependencies are used and statically built into the executable.
Multiple developers build the source code by following a specific descriptor ("recipe"), cryptographically sign the result, and upload the resulting signature. These results are compared and only if they match, the build is accepted and provided for download.
Gitian runs compilation steps in an isolated container. It is flexible and gives you full control over the build environment, while still ensuring reproducibility and consistent output formats.
More independent Gitian builders are needed, which is why this guide exists. It is preferred you follow these steps yourself instead of using someone else's VM image to avoid 'contaminating' the build.
The first step is to prepare the host environment that will be used to perform the Gitian builds. This guide explains how to set up the environment, and how to start the builds.
You need to create a new user called gitianuser and be logged in as that user. The user needs sudo access.
LXC builds should be run on Ubuntu 18.04 "Bionic Beaver".
Note that a version of lxc-execute higher or equal to 2.1.1 is required. You can check the version with lxc-execute --version.
First we need to set up dependencies. Type/paste the following in the terminal:
Then set up LXC and the rest with the following, which is a complex jumble of settings and workarounds:
This setup is required to enable networking in the container.
Prepare for building with docker:
Consider adding gitianuser to the docker group after reading about the security implications:
Optionally add yourself to the docker group. Note that this will give docker root access to your system.
The script automatically installs some packages with apt. If you are not running it on a debian-like system, pass --no-apt along with the other arguments to it. It calls all available .yml descriptors, which in turn pass the build configurations for different platforms to gitian. The instructions below use the automated script gitian-build.py which is tested to work on Ubuntu.
It calls all available .yml descriptors, which in turn pass the build configurations for different platforms to gitian. Help for the build steps taken can be accessed with ./gitian-build.py --help.
The gitian-build.py script will checkout different release tags, so it's best to copy it to the top level directory:
Common setup part:
Where GH_USER is your GitHub user name and VERSION is the version tag you want to build. The gitian-build.py's --setup switch will also refresh the environment of any stale files and submodules.
Setup for LXC:
Setup for docker:
While gitian and this build script does provide a way for you to sign the build directly, it is recommended to sign in a separate step. This script is only there for convenience. Separate steps for building can still be taken. In order to sign gitian builds on your host machine, which has your PGP key, fork the gitian.sigs repository and clone it on your host machine, or pass the signed assert file back to your build machine.
To build the most recent tag (pass in --docker if using docker):
To speed up the build, use -j 5 --memory 10000 as the first arguments, where 5 is the number of CPU's you allocated to the VM plus one, and 10000 is a little bit less than then the MB's of RAM you allocated. If there is memory corruption on your machine, try to tweak these values. A good rule of thumb is, that Monero currently needs about 2 GB of RAM per core.
A full example for docker would look like the following:
If all went well, this produces a number of (uncommitted) .assert files in the gitian.sigs directory.
Take a look in the assert files and note the SHA256 checksums listed there.
You should verify that the checksum that is listed matches each of the binaries you actually built. This may be done on Linux using the sha256sum command or on MacOS using shasum --algorithm 256 for example. An example script to verify the checksums would be:
Don't ignore the incorrect formatting of the found assert files. These files you'll have to compare manually (currently OSX and FreeBSD).
You can also look in the gitian.sigs repo and / or getmonero.org release checksums to see if others got the same checksum for the same version tag. If there is ever a mismatch – STOP! Something is wrong. Contact others on IRC / github to figure out what is going on.
If you chose to do detached signing using --detach-sign above (recommended), you need to copy these uncommitted changes to your host machine, then sign them using your gpg key like so:
This will create a .sig file for each .assert file above (2 files for each platform).
Make a pull request (both the .assert and .assert.sig files) to the monero-project/gitian.sigs repository:
Note: Please ensure your gpg public key is available to check signatures by adding it to the gitian.sigs/gitian-pubkeys/ directory in a pull request.
You can choose your own remote and commit hash by running for example:
Note that you won't be able to build commits authored before the gitian scripts were added. Gitian clones the source files from the given url, be sure to push to the remote you provide before building. To get all build options run:
If you need to do multiple iterations (while developing/testing) you can use the --rebuild option instead of --build on subsequent iterations. This skips the initial check for the freshness of the depends tools. In particular, doing this check all the time prevents rebuilding when you have no network access.
If you need to run builds while disconnected from the internet, make sure you have local up-to-date repos in advance. Then specify your local repo using the --url option when building. This will avoid attempts to git pull across a network.