Set up Virtualbox
Download the newest version of Virtualbox. Right now this is Virtualbox 6.1.18 and I’ll use Windows 10 as a host system. After that check the integritry of the downloaded file and install it. The installation process is really straight forward. The standard settings are fine. Once installed, start it and select “New”.
As name choose “Bitcoinbuild”, type “Linux” and version “Ubuntu (64-bit)”. Click on “Continue”. Choose at least 4096 MB for the main memory. Click again on “Continue”.
On the hard drive screen click on “Create”.
Choose “VDI (VirtualBox Disk Drive)” and click on “Continue”.
Choose “dynamically allocated” and click on “Continue”.
Choose at least “40 GB” for the drive and click on “Create”. Select the created virtual machine and type Ctrl+S or do a right click and choose edit. In “System” > “Processors” increase the number of processors as long as it is still green. Feel free to select “PAE/NX” and “Nested VT-x/AMD-V”.
In “Network” > “Adapter 1” activate “Extended” and click on “Port Forwarding”. Create a new port forwarding with the Name “SSH”, protocol “TCP”, host port “22222” and guest port “22”. Click on “OK”.
Install Ubuntu 20.04
Now move on and download Ubuntu 20.04 from the Ubuntu website. Once downloaded check the integrity of the file. Right click on the virtual machine and choose “Edit”. Select “Mass Storage” and add the downloaded .iso. Start the virtual machine. Select a language, click on “Install Ubuntu” and then “Next”. Select “Minimum Installation” and allow the download of updates and third party software. Click on “Continue”.
Select “Delete hard drive and install Ubuntu”. Next click on “Install Now”. Click on “Continue”. Click on “Continue”.
Insert “gitianuser” for the name, “gitianuser” for the computer and “gitianuser” for the user. Insert any password. Select “Password required for login” and click on “Continue”.
Remove the installation medium and click on “Reboot Now”.
Login as “gitianuser” with the right password and click on “Skip”, “Continue”, “Continue” and again on “Continue”. Update the virtual machine either via Terminal or the update manager. If you use the update manager just click on “Install Now”. The update may require a reboot.
Install OpenSSH server
To communicate with the virtual machine the ssh port should be available and an OpenSSH server needs to be installed.
gitianuser@gitianuser:~$ sudo ufw allow ssh
gitianuser@gitianuser:~$ sudo apt-get install openssh-server
SSH into the virtual machine:
Open a windows terminal and connect to the virtual machine.
C:\Users>ssh -l gitianuser 127.0.0.1 -p 22222
Prepare Ubuntu for Gitian
Some packages need to be installed.
gitianuser@gitianuser:~$ sudo apt-get install git ruby apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils make curl firewalld
The python-vm-builder needs to be build.
gitianuser@gitianuser:~$ sudo apt-get install python
gitianuser@gitianuser:~$ cd Downloads/
gitianuser@gitianuser:~/Downloads$ wget http://archive.ubuntu.com/ubuntu/pool/universe/v/vm-builder/vm-builder_0.12.4+bzr494.orig.tar.gz
gitianuser@gitianuser:~/Downloads$ echo "76cbf8c52c391160b2641e7120dbade5afded713afaa6032f733a261f13e6a8e vm-builder_0.12.4+bzr494.orig.tar.gz" | sha256sum -c
# (verification -- must return OK)
gitianuser@gitianuser:~/Downloads$ tar -zxvf vm-builder_0.12.4+bzr494.orig.tar.gz
gitianuser@gitianuser:~/Downloads$ cd vm-builder-0.12.4+bzr494
gitianuser@gitianuser:~/Downloads$ sudo python setup.py install
gitianuser@gitianuser:~$ cd ..
LXC needs to be set up.
gitianuser@gitianuser:~$ sudo -s
# the version of lxc-start in Ubuntu needs to run as root, so make sure
# that the build script can execute it without providing a password
root@gitianuser:/home/gitianuser# echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc
root@gitianuser:/home/gitianuser# echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-execute" >> /etc/sudoers.d/gitian-lxc
# make /etc/rc.local script that sets up bridge between guest and host
root@gitianuser:/home/gitianuser# echo '#!/bin/sh -e' > /etc/rc.local
root@gitianuser:/home/gitianuser# echo 'brctl addbr br0' >> /etc/rc.local
root@gitianuser:/home/gitianuser# echo 'ip addr add 10.0.3.1/24 broadcast 10.0.3.255 dev br0' >> /etc/rc.local
root@gitianuser:/home/gitianuser# echo 'ip link set br0 up' >> /etc/rc.local
root@gitianuser:/home/gitianuser# echo 'firewall-cmd --zone=trusted --add-interface=br0' >> /etc/rc.local
root@gitianuser:/home/gitianuser# echo 'exit 0' >> /etc/rc.local
root@gitianuser:/home/gitianuser# chmod +x /etc/rc.local
# make sure that USE_LXC is always set when logging in as gitianuser,
# and configure LXC IP addresses
root@gitianuser:/home/gitianuser# echo 'export USE_LXC=1' >> /home/gitianuser/.profile
root@gitianuser:/home/gitianuser# echo 'export GITIAN_HOST_IP=10.0.3.1' >> /home/gitianuser/.profile
root@gitianuser:/home/gitianuser# echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/gitianuser/.profile
root@gitianuser:/home/gitianuser# reboot
After the reboot connect again to the virtual machine.
C:\Users>ssh -l gitianuser 127.0.0.1 -p 22222
Clone the git repositories for Bitcoin and Gitian
gitianuser@gitianuser:~$ cd Downloads/
gitianuser@gitianuser:~/Downloads$ git clone https://github.com/devrandom/gitian-builder.git
gitianuser@gitianuser:~/Downloads$ git clone https://github.com/bitcoin/bitcoin
Build the images for Linux
gitianuser@gitianuser:~/Downloads$ cd gitian-builder
gitianuser@gitianuser:~/Downloads/gitian-builder$ bin/make-base-vm --lxc --arch amd64 --suite bionic # For supported releases before 22.0
gitianuser@gitianuser:~/Downloads/gitian-builder$ cd ..
gitianuser@gitianuser:~/Downloads$ cp bitcoin/contrib/gitian-build.py .
gitianuser@gitianuser:~/Downloads$ ./gitian-build.py --setup
gitianuser@gitianuser:~/Downloads$ mkdir -p gitian-builder/inputs
# to build for macOS the SDK-file for macOS would need to be copied
# gitianuser@gitianuser:~/Downloads$ cp 'path/to/extracted-SDK-file for macOS' gitian-builder/inputs
gitianuser@gitianuser:~/Downloads$ export NAME=satoshi
gitianuser@gitianuser:~/Downloads$ export VERSION=0.21.0
gitianuser@gitianuser:~/Downloads$ ./gitian-build.py -j 1 -m 4000 --detach-sign --no-commit -b $NAME $VERSION
After everything worked as expected your binaries should be ready and have the same hashes as the officially published ones.