Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HowTo: create a Bitcoin Core Gitian Build (using: Debian VM on VirtualBox + gitian-build.sh)
#References:
#https://github.com/bitcoin-core/docs/blob/master/gitian-building.md
#https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md
#https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md (actually not used in this guide, but useful as a reference)
1) Create a Debian VM as a building environment (it will be accessed via SSH)
------------------------------------------------------------------------------------------------------
Follow the instructions at:
https://github.com/bitcoin-core/docs/blob/master/gitian-building/gitian-building-create-vm-debian.md
2) Setup Gitian
------------------------------------------------------------------------------------------------------
Instructions taken from:
https://github.com/bitcoin-core/docs/blob/master/gitian-building/gitian-building-setup-gitian-debian.md
- 2.1) (as root)
---------------------------------------------------
ssh root@localhost -p 22222
apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils make ubuntu-archive-keyring curl
adduser gitianuser sudo
echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc
echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-execute" >> /etc/sudoers.d/gitian-lxc
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 'iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE' >> /etc/rc.local
echo 'echo 1 > /proc/sys/net/ipv4/ip_forward' >> /etc/rc.local
echo 'exit 0' >> /etc/rc.local
echo 'export USE_LXC=1' >> /home/gitianuser/.profile
echo 'export GITIAN_HOST_IP=10.0.3.2' >> /home/gitianuser/.profile
echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/gitianuser/.profile
reboot
- 2.2) (as gitianuser)
---------------------------------------------------
ssh gitianuser@localhost -p 22222
# Install python-vm-builder
# Note: When sudo asks for a password, enter the password for the user gitianuser not for root
wget http://archive.ubuntu.com/ubuntu/pool/universe/v/vm-builder/vm-builder_0.12.4+bzr494.orig.tar.gz
echo "76cbf8c52c391160b2641e7120dbade5afded713afaa6032f733a261f13e6a8e vm-builder_0.12.4+bzr494.orig.tar.gz" | sha256sum -c
# (verification -- must return OK)
tar -zxvf vm-builder_0.12.4+bzr494.orig.tar.gz
cd vm-builder-0.12.4+bzr494
sudo python setup.py install
cd ..
#Clone Bitcoin + Gitian repos
git clone https://github.com/devrandom/gitian-builder.git
git clone https://github.com/bitcoin/bitcoin
git clone https://github.com/bitcoin-core/gitian.sigs.git
#Build the Gitian VM (used for the real building process)
cd gitian-builder
bin/make-base-vm --lxc --arch amd64 --suite trusty
3) Actual build
------------------------------------------------------------------------------------------------------
#Keep using gitianuser
#Replace SIGNER with your name and VERSION with the version/branch you want to build (version numbers didn't work in my case)
#Useful gitian-build.sh options (use --help for more):
# -o|--os Specify which Operating Systems the build is for. Default is lwx. l for linux, w for windows, x for osx
# --no-commit Do not commit anything to git
# (this is necessary when you're compiling the original source but you're not a releaser)
# -c|--commit Indicate that the version argument is for a commit or branch
# (in my case this was necessary since for some reason the script could recognize any version number)
# -u|--url Specify the URL of the repository (if you want to compile your own fork).
export SIGNER=username
export VERSION=master
../bitcoin/contrib/gitian-build.sh --setup -c $SIGNER $VERSION
#This command build Bitcoin for Linux only
./bitcoin/contrib/gitian-build.sh --build --os l -c --no-commit $SIGNER $VERSION
###############################################################################
You will find the binaries in tarball files stored in:
/home/gitianuser/vm-builder-0.12.4+bzr494/bitcoin-binaries/$VERSION
- To copy the created tarball(s) you can use SCP:
e.g.: ($VERSION=master)
scp -P 22222 gitianuser@localhost://home/gitianuser/vm-builder-0.12.4+bzr494/bitcoin-binaries/master/bitcoin-0.15.99-aarch64-linux-gnu.tar.gz ./dev/my-local-testnet/
################################################################################
@leegod

This comment has been minimized.

Copy link

commented Feb 8, 2018

too complicated... Why bitcoin source compiling and making windows runnable build file is so hard ?

@akshaynexus

This comment has been minimized.

Copy link

commented Mar 6, 2018

true that @leegod

@phantanthanh1996

This comment has been minimized.

Copy link

commented Apr 5, 2018

Hi sir, i am trying to build bitcoin wallet with your instruction but a i run when call ../bitcoin/contrib/gitian-build.sh --setup -c $SIGNER $VERSION

@phantanthanh1996

This comment has been minimized.

Copy link

commented Apr 5, 2018

Cannot build for OSX, SDK does not exist. Will build for other OSes
master
[sudo] password for gitianuser:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-vm-builder
fatal: destination path 'gitian.sigs' already exists and is not an empty directory.
fatal: destination path 'bitcoin-detached-sigs' already exists and is not an empty directory.
fatal: destination path 'gitian-builder' already exists and is not an empty directory.
~/gitian-builder/gitian-builder ~/gitian-builder ~/gitian-builder
Reading package lists... Done
Building dependency tree
Reading state information... Done
lxc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
base-trusty-amd64 already exists, please remove it first
~/gitian-builder ~/gitian-builder
~/bitcoin ~/gitian-builder ~/gitian-builder
M contrib/gitian-build.sh
Already on 'master'
Your branch is up-to-date with 'origin/master'.
~/gitian-builder ~/gitian-builder
~/gitian-builder/gitian-builder ~/gitian-builder ~/gitian-builder

Signing master Windows

/usr/lib/ruby/2.1.0/psych.rb:464:in initialize': No such file or directory @ rb_sysopen - ../bitcoin/contrib/gitian-descriptors/gitian-win-signer.yml (Errno::ENOENT) from /usr/lib/ruby/2.1.0/psych.rb:464:in open'
from /usr/lib/ruby/2.1.0/psych.rb:464:in load_file' from ./bin/gbuild:215:in

'
/usr/lib/ruby/2.1.0/psych.rb:464:in initialize': No such file or directory @ rb_sysopen - ../bitcoin/contrib/gitian-descriptors/gitian-win-signer.yml (Errno::ENOENT) from /usr/lib/ruby/2.1.0/psych.rb:464:in open'
from /usr/lib/ruby/2.1.0/psych.rb:464:in load_file' from ./bin/gsign:58:in '
mv: cannot stat ‘build/out/bitcoin-*win64-setup.exe’: No such file or directory
mv: cannot stat ‘build/out/bitcoin-*win32-setup.exe’: No such file or directory
~/gitian-builder ~/gitian-builder
~/gitian-builder/gitian.sigs ~/gitian-builder ~/gitian-builder

Committing master Signed Sigs

fatal: pathspec 'master-win-signed/thanhpt' did not match any files
fatal: pathspec 'master-osx-signed/thanhpt' did not match any files
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

@phantanthanh1996

This comment has been minimized.

Copy link

commented Apr 5, 2018

../bitcoin/contrib/gitian-build.sh: line 247: pushd: ./bitcoin: No such file or directory
error: pathspec '0.16.0' did not match any file(s) known to git.
../bitcoin/contrib/gitian-build.sh: line 250: popd: directory stack empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.