News:

Are you new to Groestlcoin and have questions you are afraid to ask?
Check out the New Users board and post there.
Welcome to all newcomers.

Main Menu

How to build Groestlcoin Core with Gitian

Started by jackielove4u, January 23, 2020, 09:26:49 PM

Previous topic - Next topic

jackielove4u

The following were tested in Debian 9.7 and Debian 10.2, some dependencies can be different in other distros.
If you have issues make sure:
     - HyperVM is enabled in bios (to enable 64bit in virtualbox)
     - Hyper V is uninstalled on Windows
     - Disable mcafee anti-virus, Malwarebytes and roquekiller
     - Disable sleep/hibernate mode on windows

Create a Debian VM as a building environment (it will be accessed via SSH) Follow the instructions at: https://github.com/Groestlcoin/docs/blob/master/gitian-building/gitian-building-create-vm-debian.md however use Debian 9.7 or Debian 10.2 instead of Debian 8. Also change memory to 10240MB

(below as root) Note: When sudo asks for a password, enter the password for the user gitianuser not for root
ssh root@localhost -p 22222
sudo -s
sudo apt-get install git ruby apt-cacher-ng qemu-utils lxc debootstrap python-cheetah parted kpartx bridge-utils make ubuntu-archive-keyring curl firewalld -y
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 'ip addr add 10.0.3.1/24 broadcast 10.0.3.255 dev br0' >> /etc/rc.local
echo 'ip link set br0 up' >> /etc/rc.local
echo 'firewall-cmd --zone=trusted --add-interface=br0' >> /etc/rc.local
echo 'exit 0' >> /etc/rc.local
chmod +x /etc/rc.local
echo 'export USE_LXC=1' >> /home/gitianuser/.profile
echo 'export GITIAN_HOST_IP=10.0.3.1' >> /home/gitianuser/.profile
echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/gitianuser/.profile
reboot

(below as gitianuser) Note: When sudo asks for a password, enter the password for the user gitianuser not for root
ssh gitianuser@localhost -p 22222
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
tar -zxvf vm-builder_0.12.4+bzr494.orig.tar.gz
cd vm-builder-0.12.4+bzr494
sudo python setup.py install
cd ..

sudo apt-get install autoconf automake pkg-config libcap-dev libtool -y
git clone https://github.com/lxc/lxc.git
cd lxc
git checkout lxc-3.0.3
./autogen.sh
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu --with-rootfs-path=/usr/lib/x86_64-linux-gnu/lxc
sudo make install
cd ..
wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.95.tar.gz
tar -zxvf debootstrap_1.0.95.tar.gz
cd debootstrap-1.0.95
sudo make install
cd ..

#Export your key (or export private key on Kleopatra):
gpg --export-secret-keys $ID > my-private-key.asc
# Copy the key to the VM. To copy the exported secret-keys you can use SFTP client on portnumber 22222
#To import the key, run:
gpg --import my-private-key.asc.
#Setup a passphrase for the secret key when asked
gpg --edit-key $ID
passwd #Enter existing passphrase then press enter twice and consider the warnings from the tool and its implications before proceeding.
quit

git clone https://github.com/devrandom/gitian-builder
cd gitian-builder
bin/make-base-vm --lxc --arch amd64 --suite bionic

Replace SIGNER with your signing name and VERSION with the branch you want to build
Useful gitian-build.py options (use --help for more):
-o|--os      Specify which Operating Systems the build is for. Default is lwm. l for linux, w for windows, m for MacOS
--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       
-u|--url     Specify the URL of the repository (if you want to compile your own fork).


export SIGNER=jackielove4u
# enter the version and/or branch name below.
export VERSION=2.21.0
wget https://raw.githubusercontent.com/Groestlcoin/groestlcoin/$VERSION/contrib/gitian-build.py
chmod +x gitian-build.py
./gitian-build.py --setup -c $SIGNER $VERSION

# Create input folder and enter the directory
mkdir gitian-builder/inputs && cd gitian-builder/inputs
#Fetch MacOSX10.11.sdk if building for old Groestlcoin Core
wget https://bitcoincore.org/depends-sources/sdks/MacOSX10.11.sdk.tar.gz
#Fetch MacOSX10.14.sdk if building for old Groestlcoin Core
wget https://bitcoincore.org/depends-sources/sdks/MacOSX10.14.sdk.tar.gz
#Fetch Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz if building for old Groestlcoin Core
wget https://bitcoincore.org/depends-sources/sdks/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz
#Fetch Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz
wget https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz
#Return to build directory
cd ../..

#This command will build Groestlcoin Core for all platforms. Make sure to close Malwarebytes otherwise it will fail (Malwarebytes blocks bitcoin-core.org URL)
#To speed up the build, use -j 4 -m 10000 as the first arguments, where 4 is the number of CPU cores you allocated to the VM plus one and 10000 is a little bit less than #the MBs of RAM you allocated

# build a branch or commit
./gitian-build.py -j 4 -m 10000 --build -c --no-commit $SIGNER $VERSION

#Watch logs with:
tail -f gitian-builder/gitian-builder/var/build.log

#Delete debug binaries
cd groestlcoin-binaries/$VERSION && rm *-debug*

# Create SHA256SUMS and display it
sha256sum * > SHA256SUMS && cat SHA256SUMS

#Sign SHA256SUMS and display it
gpg --digest-algo sha256 --clearsign SHA256SUMS && rm SHA256SUMS && cat SHA256SUMS.asc

#Verify SHA256SUMS
gpg --verify SHA256SUMS.asc

#Copy the created tarballs (or you can use SFTP client like WINSCP and connect to localhost with portnumber 22222 and copy the created tarballs from /home/gitianuser/gitian-builder/groestlcoin-binaries/$VERSION)
scp -P 22222 -r /home/gitianuser/gitian-builder/groestlcoin-binaries/$VERSION [email protected]:~/Desktop/

commit new created folders on /home/gitianuser/gitian-builder/gitian.sigs to https://github.com/Groestlcoin/gitian.sigs