In this tutorial we will learn how to have a working gitian-builder for dash under Debian Jessie.
Remark: Having grsec patch will surely mess with LXC and give you headaches with gitian-builder. Avoid...
Prerequisites
You need a working Debian Jessie installation. This is out of scope of this tutorial.
Create user gitian and add it to the sudo group (or at least give it sudo power).
Setting up Debian Jessie for gitian building
In this section we will be setting up the Debian installation for Gitian building.
First we need to log in as root to set up dependencies and make sure that our user can use the sudo command. Type/paste the following in the terminal:
When you get a colorful screen with a question about the 'LXC directory', just go with the default (/var/lib/lxc).
Then set up LXC and the rest with the following, which is a complex jumble of settings and workarounds:
The reboot at the end is just so that cgroup and br0 are mounted/created. Just do it by hand if you wish to avoid a reboot.
Of course all those steps only need to be performed once.
Installing gitian
Re-login as the user gitian that was created during installation. The rest of the steps in this guide will be performed as that user.
There is no python-vm-builder package in Debian, so we need to install it from source ourselves,
Note: When sudo asks for a password, enter the password for the user gitian not for root.
Clone the git repositories for bitcoin and gitian.
Setting up the gitian image
Gitian needs a virtual image of the operating system to build in. Currently this is Ubuntu Precise x86_64. This image will be copied and used every time that a build is started to make sure that the build is deterministic. Creating the image will take a while, but only has to be done once.
IMPORTANT: The default bin/make-base-vm will fail with Debian Jessie.
Fixing it is easy, just add sudo before the mkfs.ext4 at line 114:
Execute the following as user debian:
There will be a lot of warnings printed during build of the image. These can be ignored.
Note: When sudo asks for a password, enter the password for the user gitian not for root.
Getting and building the inputs
First we need to retrieve the dependencies in order to be able to build the dash binaries in gitian-builder.
As gitian user:
You can run this before every build to be sure you are not missing dependencies. It will only download new files.
IMPORTANT: In order to compile the Mac OSX binaries you will need to place the
MacOSX10.7.sdk.tar.gz file in the gitian-builder/inputs folder.
Find out the steps to create this file from the bitcoin documentation.
Building dash binaries
Now you only need to start compiling dash.
REMARK: The first time you run the following commands it will update the base image and compile the full dependencies and it will take A LOT of time. You can monitor the install and build by using:
Or:
If no errors during the build process the output files will be in build/out directory.
Don't forget to move them before building something else or they will be deleted.
Linux:
Go to gitian-builder directory and to build latest version from master:
To build a specific commit or branch (here v0.12.0.x branch):
Windows:
Go to gitian-builder directory and to build latest version from master:
To build a specific commit or branch (here v0.12.0.x branch):
Mac OSX:
Go to gitian-builder directory and to build latest version from master:
To build a specific commit or branch (here v0.12.0.x branch):
Remark: Having grsec patch will surely mess with LXC and give you headaches with gitian-builder. Avoid...
Prerequisites
You need a working Debian Jessie installation. This is out of scope of this tutorial.
Create user gitian and add it to the sudo group (or at least give it sudo power).
Setting up Debian Jessie for gitian building
In this section we will be setting up the Debian installation for Gitian building.
First we need to log in as root to set up dependencies and make sure that our user can use the sudo command. Type/paste the following in the terminal:
Code:
apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils
adduser gitian sudo
When you get a colorful screen with a question about the 'LXC directory', just go with the default (/var/lib/lxc).
Then set up LXC and the rest with the following, which is a complex jumble of settings and workarounds:
Code:
# add cgroup for LXC
echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
# make /etc/rc.local script that sets up bridge between guest and host
echo '#!/bin/sh -e' > /etc/rc.local
echo 'brctl addbr br0' >> /etc/rc.local
echo 'ifconfig br0 10.0.3.2/24 up' >> /etc/rc.local
echo 'exit 0' >> /etc/rc.local
# make sure that USE_LXC is always set when logging in as gitian,
# and configure LXC IP addresses
echo 'export USE_LXC=1' >> /home/gitian/.profile
echo 'export GITIAN_HOST_IP=10.0.3.2' >> /home/gitian/.profile
echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/gitian/.profile
reboot
The reboot at the end is just so that cgroup and br0 are mounted/created. Just do it by hand if you wish to avoid a reboot.
Of course all those steps only need to be performed once.
Installing gitian
Re-login as the user gitian that was created during installation. The rest of the steps in this guide will be performed as that user.
There is no python-vm-builder package in Debian, so we need to install it from source ourselves,
Code:
wget http://archive.ubuntu.com/ubuntu/pool/universe/v/vm-builder/vm-builder_0.12.4+bzr489.orig.tar.gz
echo "ec12e0070a007989561bfee5862c89a32c301992dd2771c4d5078ef1b3014f03 vm-builder_0.12.4+bzr489.orig.tar.gz" | sha256sum -c
# (verification -- must return OK)
tar -zxvf vm-builder_0.12.4+bzr489.orig.tar.gz
cd vm-builder-0.12.4+bzr489
sudo python setup.py install
cd ..
Note: When sudo asks for a password, enter the password for the user gitian not for root.
Clone the git repositories for bitcoin and gitian.
Code:
git clone https://github.com/devrandom/gitian-builder.git
git clone https://github.com/dashpay/dash
Setting up the gitian image
Gitian needs a virtual image of the operating system to build in. Currently this is Ubuntu Precise x86_64. This image will be copied and used every time that a build is started to make sure that the build is deterministic. Creating the image will take a while, but only has to be done once.
IMPORTANT: The default bin/make-base-vm will fail with Debian Jessie.
Fixing it is easy, just add sudo before the mkfs.ext4 at line 114:
Code:
$ git diff
diff --git a/bin/make-base-vm b/bin/make-base-vm
index 7fc7818..e51b1a2 100755
--- a/bin/make-base-vm
+++ b/bin/make-base-vm
@@ -114,7 +114,7 @@ if [ $LXC = "1" ]; then
# Need universe for lxc in lucid
env -i LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 sudo debootstrap --arch=$ARCH --include=$addpkg --exclude=$removepkg --components=main,universe $SUITE $OUT-bootstrap $MIRROR
dd if=/dev/zero of=$OUT-lxc bs=1M count=1 seek=10240
- mkfs.ext4 -F $OUT-lxc
+ sudo mkfs.ext4 -F $OUT-lxc
t=`mktemp -d gitian.XXXXXXXX`
sudo mount $OUT-lxc $t
sudo cp -a $OUT-bootstrap/* $t
Execute the following as user debian:
Code:
cd gitian-builder
bin/make-base-vm --lxc --arch amd64 --suite precise
There will be a lot of warnings printed during build of the image. These can be ignored.
Note: When sudo asks for a password, enter the password for the user gitian not for root.
Getting and building the inputs
First we need to retrieve the dependencies in order to be able to build the dash binaries in gitian-builder.
As gitian user:
Code:
cd ~gitian/dash
git pull
cd ~gitian/gitian-builder
make -C ../dash/depends download SOURCES_PATH=`pwd`/cache/common
You can run this before every build to be sure you are not missing dependencies. It will only download new files.
IMPORTANT: In order to compile the Mac OSX binaries you will need to place the
MacOSX10.7.sdk.tar.gz file in the gitian-builder/inputs folder.
Find out the steps to create this file from the bitcoin documentation.
Building dash binaries
Now you only need to start compiling dash.
REMARK: The first time you run the following commands it will update the base image and compile the full dependencies and it will take A LOT of time. You can monitor the install and build by using:
Code:
tail -f var/install.log
Code:
tail -f var/build.log
If no errors during the build process the output files will be in build/out directory.
Don't forget to move them before building something else or they will be deleted.
Linux:
Go to gitian-builder directory and to build latest version from master:
Code:
./bin/gbuild --commit dash ../dash/contrib/gitian-descriptors/gitian-linux.yml
To build a specific commit or branch (here v0.12.0.x branch):
Code:
./bin/gbuild --commit dash=v0.12.0.x ../dash/contrib/gitian-descriptors/gitian-linux.yml
Windows:
Go to gitian-builder directory and to build latest version from master:
Code:
./bin/gbuild --commit dash ../dash/contrib/gitian-descriptors/gitian-win.yml
To build a specific commit or branch (here v0.12.0.x branch):
Code:
./bin/gbuild --commit dash=v0.12.0.x ../dash/contrib/gitian-descriptors/gitian-win.yml
Mac OSX:
Go to gitian-builder directory and to build latest version from master:
Code:
./bin/gbuild --commit dash ../dash/contrib/gitian-descriptors/gitian-osx.yml
To build a specific commit or branch (here v0.12.0.x branch):
Code:
./bin/gbuild --commit dash=v0.12.0.x ../dash/contrib/gitian-descriptors/gitian-osx.yml
Last edited by a moderator: