Skip to content

Instantly share code, notes, and snippets.

@cryptozeny
Last active October 8, 2020 23:15
Show Gist options
  • Save cryptozeny/0d31e89e6be5631dd0379aa424affcf3 to your computer and use it in GitHub Desktop.
Save cryptozeny/0d31e89e6be5631dd0379aa424affcf3 to your computer and use it in GitHub Desktop.
gitian cross compilation for BTC v0.16.3

GITIAN BUILD for BTC v0.16.3

Prepare VM


Setup VM

Install DEP

sudo apt-get install -y \
git ruby apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils make ubuntu-archive-keyring curl firewalld

LXC && UTF-8 && Timezone

$ sudo -s
  • LXC
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
  • UTF-8 en_US.UTF-8
export LANGUAGE="en_US.UTF-8" && \
echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale && \
echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale
  • Set Timezone Asia/Seoul
timedatectl set-timezone Asia/Seoul
  • Reboot

  • Check (after reboot)

cat /etc/default/locale && \
locale && \
cat /etc/timezone
  • Check Output
#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
Asia/Seoul

Installing Gitian

  • build from source : python-vm-builder (since no python-vm-builder package in Debian)
cd && \
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 ..

BTC clone (BTC tags/v0.16.3)

cd && \
git clone https://github.com/devrandom/gitian-builder.git && \
git clone https://github.com/bitcoin-core/gitian.sigs.git && \
git clone https://github.com/bitcoin-core/bitcoin-detached-sigs.git && \
git clone https://github.com/bitcoin/bitcoin && \
cd bitcoin && \
git checkout tags/v0.16.3 && \
cd

Make Your Own PGP Key

gpg --import ~/cryptozeny-secret.pgp

Gitain Build

Initial Gitian Setup (BTC tags/v0.16.3)

  • download osslsigncode-1.7.1 and Patch (check sha256sum OK)
cd && \
git clone [email protected]:cryptozeny/osslsigncode-1.7.1.tar.gz.git && \
cd osslsigncode-1.7.1.tar.gz/ && \
echo 'a8c4e9cafba922f89de0df1f2152e7be286aba73f78505169bc351a7938dd911 osslsigncode-Backports-to-1.7.1.patch' | sha256sum -c && \
echo 'f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 osslsigncode-1.7.1.tar.gz' | sha256sum -c && \
mkdir -p ~/gitian-builder/inputs && \
cp osslsigncode-Backports-to-1.7.1.patch ~/gitian-builder/inputs/ && \
cp osslsigncode-1.7.1.tar.gz ~/gitian-builder/inputs/
  • download Xcode SDK for macOS build (check sha256sum OK)
cd && \
git clone https://github.com/cryptozeny/MacOSX10.11.sdk.tar.gz.git && \
cd MacOSX10.11.sdk.tar.gz/ && \
echo "fc65dd34a3665a549cf2dc005c1d13fcead9ba17cadac6dfd0ebc46435729898" MacOSX10.11.sdk.tar.gz | sha256sum -c && \
mkdir -p ~/gitian-builder/inputs && \
cp MacOSX10.11.sdk.tar.gz ~/gitian-builder/inputs/MacOSX10.11.sdk.tar.gz
cd && \
cd gitian-builder && \
bin/make-base-vm --lxc --arch amd64 --suite trusty && \
cd
  • Init Gitian cryptozeny
cd && \
cp ./bitcoin/contrib/gitian-build.sh . && \
./gitian-build.sh --setup cryptozeny 0.16.3

Build Binaries (BTC tags/v0.16.3)

  • OS Selection
    --os lwx : Linux + Windows + OSX
    --os l : Linux
    --os w : Windows
    --os x : OSX (macOS)

  • Options : Build Speed (Cores +1)
    2 CPU Cores : -j 3(2+1) or --num-make 3(2+1) (Default 2)
    3 GB Ram : -m 3000 or --memory 3000 (Default 2000)

  • Signer (Github ID) cryptozeny

  • All of them --os lwx

cd && \
./gitian-build.sh -j 3 -m 3000 --os lwx --detach-sign --no-commit -b cryptozeny 0.16.3
  • Linux --os l
cd && \
./gitian-build.sh -j 3 -m 3000 --os l --detach-sign --no-commit -b cryptozeny 0.16.3
  • Windows --os w
cd && \
./gitian-build.sh -j 3 -m 3000 --os w --detach-sign --no-commit -b cryptozeny 0.16.3
  • OSX (macOS) --os x
cd && \
./gitian-build.sh -j 3 -m 3000 --os x --detach-sign --no-commit -b cryptozeny 0.16.3
  • Check Building Process
tail -f ~/gitian-builder/var/build.log
  • Binary Location
ls ~/bitcoin-binaries/0.16.3/
  • Signing PGP to Binaries (Windows and OSX: --os wx)
cd && \
./gitian-build.sh -j 3 -m 3000 --os wx --detach-sign --no-commit -s cryptozeny 0.16.3
  • Remove *-debug* && *-unsigned*
cd ~/bitcoin-binaries/0.16.3/ && \
rm *-debug* ;
rm *-unsigned*
  • Create SHA256SUMS.asc and PGP-sign
cd ~/bitcoin-binaries/0.16.3/ && \
sha256sum * > SHA256SUMS && \
gpg --digest-algo sha256 --clearsign SHA256SUMS # outputs SHA256SUMS.asc # input password
rm SHA256SUMS && \
cat SHA256SUMS.asc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

0768c6c15caffbaca6524824c9563b42c24f70633c681c2744649158aa3fd484  bitcoin-0.16.3-aarch64-linux-gnu.tar.gz
fb2818069854a6ad20ea03b28b55dbd35d8b1f7d453e90b83eace5d0098a2a87  bitcoin-0.16.3-arm-linux-gnueabihf.tar.gz
75a537844313b0a84bdb61ffcdc5c4ce19a738f7ddf71007cd2edf664efd7c37  bitcoin-0.16.3-i686-pc-linux-gnu.tar.gz
78c3bff3b619a19aed575961ea43cc9e142959218835cf51aede7f0b764fc25d  bitcoin-0.16.3-osx64.tar.gz
c67e382b05c26640d95d8dddd9f5203f7c5344f1e1bb1b0ce629e93882dbb416  bitcoin-0.16.3-osx.dmg
836eed97dfc79cff09f356e8fbd6a6ef2de840fb9ff20ebffb51ccffdb100218  bitcoin-0.16.3.tar.gz
1fe280a78b8796ca02824c6e49d7873ec71886722021871bdd489cbddc37b1f3  bitcoin-0.16.3-win32-setup.exe
e3d6a962a4c2cbbd4798f7257a0f85d54cec095e80d9b0f543f4c707b06c8839  bitcoin-0.16.3-win32.zip
bd48ec4b7e701b19f993098db70d69f2bdc03473d403db2438aca5e67a86e446  bitcoin-0.16.3-win64-setup.exe
52469c56222c1b5344065ef2d3ce6fc58ae42939a7b80643a7e3ee75ec237da9  bitcoin-0.16.3-win64.zip
5d422a9d544742bc0df12427383f9c2517433ce7b58cf672b9a9b17c2ef51e4f  bitcoin-0.16.3-x86_64-linux-gnu.tar.gz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJceqlgAAoJELndveKqrcQhjB0P/2NuenliD7xVYB+q409YwTgI
coSDgwo8uMbWr991pg5609siPk/NtQGrJGEylCUscUNzyWWebyS/G1S8zuqjc3IN
HaxY+S5/tcDWGB8IxugFHyXZUE8t5n1uFdvc/tVAGD0aAjrPKwIdcsfdMKSk+NQA
GSiS+RW+FfC70wpc9zAJPM2Kkg4MNVUYHH05ug7ztJIeBp8gksaZvMpoKwiEQcuL
Y7NYQlJm2QpCprUfbTL3b34Zn2Wk1ZdcE3quE3Beo/z+YQqMlKV5EgqnqEr3xtLx
DYZtGOYvp/4Ef6alv/Vj5PxBY6VJZRALXHFh9JW/pVbGXTQEPXN0fP7jOcvJE2kO
Cd6uQkENUzU4JInxxZLKtyk5W8Q5APj2fcITjUAR2vyUX6Br4b+KlxKyKqAGa92u
fd8nKbD3KRUgt5b0uK+34lvuTB+cDfizd+q2VyvbIgsFxozAIELwjBM6bZwUgKeU
O5kVtiSwgSvcMuhr+rjW1ItQfbo6WOfvhT8DyHt6zcTa3I0HALe5Qz5Mii+KyuIS
A+ape9l+s0t2MYJ/OAgQFfJbzZk6jlzFSjxWpoWPOpEnib0vlDgRv0RIv+XaAPk5
pDYdI0tNVwWwP8403Ab6YCDfqIQnh98TIc6oFZ6QY8XtAIWTDcIEhouYmD36k15e
Fm6pBhr+wE0gkMtXharv
=m8i0
-----END PGP SIGNATURE-----
gpg --verify SHA256SUMS.asc

gpg: Signature made Sun 03 Mar 2019 01:03:44 AM KST using RSA key ID AAADC421
gpg: Good signature from "cryptozeny (sugarchain developer) <[email protected]>"
Primary key fingerprint: BB27 9FE1 59A0 E40E D02B  3365 B9DD BDE2 AAAD C421
  • FINAL RELEASE - Copy Binaries to Host (192.168.1.111 is Host's IP)
scp -r /home/gitianuser/bitcoin-binaries/0.16.3/ [email protected]:~/Desktop/

Have a nice build!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment