Author Topic: How to build Groestlcoin Core with Gitian  (Read 436 times)

Offline jackielove4u

  • Administrator
  • Sr. Member
  • *****
  • Posts: 458
  • Groestlcoin
    • View Profile
How to build Groestlcoin Core with Gitian
« on: January 23, 2020, 09:26:49 pm »
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/bitcoin-core/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 broadcast 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=' >> /home/gitianuser/.profile
echo 'export LXC_GUEST_IP=' >> /home/gitianuser/.profile

(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
./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 ..

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

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 branch name below for example 2.19.1 or 2.20.1
export VERSION=2.20.1
cd gitian-builder
wget https://raw.githubusercontent.com/Groestlcoin/groestlcoin/$VERSION/contrib/gitian-build.py
chmod +x gitian-build.py
./gitian-build.py --setup -c $SIGNER $VERSION

#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
#Enter existing passphrase then press enter twice and consider the warnings from the tool and its implications before proceeding.

#Fetch MacOSX10.11.sdk
wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.11.sdk.tar.xz
#Fetch MacOSX10.14.sdk
wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.14.sdk.tar.xz
# Create input folder
mkdir gitian-builder/inputs/
# Move SDK to the right folder
mv MacOSX10.11.sdk.tar.xz gitian-builder/inputs/MacOSX10.11.sdk.tar.gz
mv MacOSX10.14.sdk.tar.xz gitian-builder/inputs/MacOSX10.14.sdk.tar.gz

#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
./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

You will find the binaries in tarball files stored in /home/gitianuser/gitian-builder/groestlcoin-binaries/$VERSION
To copy the created tarball(s) you can use SFTP client on portnumber 22222
commit new created folders on /home/gitianuser/gitian-builder/gitian.sigs to https://github.com/Groestlcoin/gitian.sigs
« Last Edit: August 20, 2020, 09:26:59 pm by jackielove4u »