Skip to content

Instantly share code, notes, and snippets.

@dexX7
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save dexX7/7bca4f21141acaa0ec65 to your computer and use it in GitHub Desktop.

Select an option

Save dexX7/7bca4f21141acaa0ec65 to your computer and use it in GitHub Desktop.
Deterministic building: Omni Core v0.0.9.1-rel

This guide targets Windows user, but it can be followed by other OS as well.

1. Download and install Oracle VirtualBox:

http://download.virtualbox.org/virtualbox/4.3.24/VirtualBox-4.3.24-98716-Win.exe

2. Follow this picture tutorial exactly step for step to setup a Debian VM:

https://github.com/mastercoin-MSC/mastercore/blob/mscore-0.0.9/doc/gitian-building.md#create-a-new-virtualbox-vm

In particular:

  • Create a new VirtualBox VM
  • Install Debian

Note: the link to Debian 7.4.0 is no longer available, so use a newer version:

http://cdimage.debian.org/debian-cd/7.8.0/amd64/iso-cd/debian-7.8.0-amd64-netinst.iso

For convenience you may want to enable a shared clipboard in Settings - Advanced:

Imgur

Don't close the VM once Debian is installed.

3. Download PuTTY for Windows:

http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

4. Connect to the VM:

Start putty.exe and connect:

  • Host Name: localhost
  • Port: 22222

Imgur

Click Open, accept the server's certificate and login as user root.

5. Install dependencies:

Enter the following line:

apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils zip -y

Imgur

When you get a colorful screen with a question about the LXC directory, just go with the default (/var/lib/lxc):

Imgur

6. Go on with:

adduser debian sudo

Imgur

7. Copy or enter each line:

echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc
echo "cgroup  /sys/fs/cgroup  cgroup  defaults  0   0" >> /etc/fstab
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 'exit 0' >> /etc/rc.local
echo 'export USE_LXC=1' >> /home/debian/.profile
echo 'export GITIAN_HOST_IP=10.0.3.2' >> /home/debian/.profile
echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/debian/.profile
reboot

Imgur

The connection will terminate due to the reboot.

8. Reconnect:

Start putty.exe and use:

  • Host Name: localhost
  • Port: 22222

This time login with user debian.

Imgur

9. Install vm-builder, copy or enter:

wget http://archive.ubuntu.com/ubuntu/pool/universe/v/vm-builder/vm-builder_0.12.4+bzr489.orig.tar.gz
echo "ec12e0070a007989561bfee5862c89a32c301992dd2771c4d5078ef1b3014f03  vm-builder_0.12.4+bzr489.orig.tar.gz" | sha256sum -c
tar -zxvf vm-builder_0.12.4+bzr489.orig.tar.gz
cd vm-builder-0.12.4+bzr489
sudo python setup.py install
cd ..

Note: vm-builder_0.12.4+bzr489.orig.tar.gz: OK is expected after entering the second line.

You will be asked for the password for the user debian.

Imgur

10. Clone gitian-builder:

git clone https://github.com/devrandom/gitian-builder.git

Imgur

11. Clone and prepare mastercore:

git clone https://github.com/mastercoin-MSC/mastercore.git bitcoin

Note: We are going to use a workaround to use Bitcoin Core's Gitian descriptors, so be sure you don't forget bitcoin at the end of the line.

Imgur

Because Omni Core's binaries were renamed to mastercored, mastercore-cli and mastercore-qt, but the build descriptors are intended to be used with Bitcoin Core, the file renaming is temporarily reverted.

The commit hash of omnicore-0.0.9.1-rel is 2c46451da12c7ecb57a6edde5675bf121eb1790b, so enter the following lines:

cd bitcoin
git checkout 2c46451da12c7ecb57a6edde5675bf121eb1790b

Note: We are going to use the commit hash 2c46451da12c7ecb57a6edde5675bf121eb1790b later.

Return to the home directory:

cd ..

Imgur

12. Setup gitian images, enter:

cd gitian-builder
bin/make-base-vm --lxc --arch i386 --suite precise
bin/make-base-vm --lxc --arch amd64 --suite precise

These steps may take a while and it could show messages, which one may read as error messages, but this is totally fine and expected. You may be asked to enter the password for the user debian.

Imgur

13. Download dependencies:

Enter each of the following lines:

mkdir -p inputs
cd inputs
wget 'http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.9.20140701.tar.gz' -O miniupnpc-1.9.20140701.tar.gz
wget 'https://www.openssl.org/source/old/1.0.1/openssl-1.0.1i.tar.gz'
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
wget 'http://zlib.net/zlib-1.2.8.tar.gz'
wget 'ftp://ftp.simplesystems.org/pub/png/src/history/libpng16/libpng-1.6.8.tar.gz'
wget 'https://fukuchi.org/works/qrencode/qrencode-3.4.3.tar.bz2'
wget 'https://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.bz2'
wget 'https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/boost-mingw.patch' -O boost-mingw-gas-cross-compile-2013-03-03.patch
wget 'https://download.qt-project.org/official_releases/qt/5.2/5.2.0/single/qt-everywhere-opensource-src-5.2.0.tar.gz'
wget 'https://download.qt-project.org/archive/qt/4.6/qt-everywhere-opensource-src-4.6.4.tar.gz'
wget 'https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2'
wget 'https://github.com/mingwandroid/toolchain4/archive/10cc648683617cca8bcbeae507888099b41b530c.tar.gz'
wget 'http://www.opensource.apple.com/tarballs/cctools/cctools-809.tar.gz'
wget 'http://www.opensource.apple.com/tarballs/dyld/dyld-195.5.tar.gz'
wget 'http://www.opensource.apple.com/tarballs/ld64/ld64-127.2.tar.gz'
wget 'http://pkgs.fedoraproject.org/repo/pkgs/cdrkit/cdrkit-1.1.11.tar.gz/efe08e2f3ca478486037b053acd512e9/cdrkit-1.1.11.tar.gz'
wget 'https://github.com/theuni/libdmg-hfsplus/archive/libdmg-hfsplus-v0.1.tar.gz'
wget 'http://llvm.org/releases/3.2/clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz' -O clang-llvm-3.2-x86-linux-ubuntu-12.04.tar.gz
wget 'https://raw.githubusercontent.com/theuni/osx-cross-depends/master/patches/cdrtools/genisoimage.diff' -O cdrkit-deterministic.patch
cd ..

Imgur

14. Build dependencies for Windows:

If you do not intend to build binaries for Windows, you can skip this section.

Enter line by line:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/boost-win.yml
mv build/out/boost-*.zip inputs/

The following result hashes are expected:

60dc2d3b61e9c7d5dbe2f90d5955772ad748a47918ff2d8b74e8db9b1b91c909  boost-win32-1.55.0-gitian-r6.zip
f65fcaf346bc7b73bc8db3a8614f4f6bee2f61fcbe495e9881133a7c2612a167  boost-win64-1.55.0-gitian-r6.zip
ec17898a32b270af6a7c866b507d964d6060e3188879f6e1ec31a609bc8bb74c  boost-res.yml

Imgur

Go on and enter line by line:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/deps-win.yml
mv build/out/bitcoin-deps-*.zip inputs/

The following result hashes are expected:

9c2572b021b3b50dc9441f2e96d672ac1da4cb6c9f88a1711aa0234882f353cf  bitcoin-deps-win32-gitian-r15.zip
94e9f6d861140d9130a15830eba40eba4c8c830440506ac7cc0d1e3217293c25  bitcoin-deps-win64-gitian-r15.zip
7f70d48f3cc2de50ec77711d5b59482b3cad174d704e258add6b8e83e19fd566  bitcoin-deps-res.yml

Imgur

Then enter:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-win.yml
mv build/out/qt-*.zip inputs/

The following result hashes are expected:

963e3e5e85879010a91143c90a711a5d1d5aba992e38672cdf7b54e42c56b2f1  qt-win32-5.2.0-gitian-r3.zip
751c579830d173ef3e6f194e83d18b92ebef6df03289db13ab77a52b6bc86ef0  qt-win64-5.2.0-gitian-r3.zip
0fc79c8ab775b42a7d101d6862c9e50701970f3494ca4db66ee569217090296b  qt-res.yml

Imgur

And finally enter:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/protobuf-win.yml
mv build/out/protobuf-*.zip inputs/

The following result hashes are expected:

e2e403e1a08869c7eed4d4293bce13d51ec6a63592918b90ae215a0eceb44cb4  protobuf-win32-2.5.0-gitian-r4.zip
a0999037e8b0ef9ade13efd88fee261ba401f5ca910068b7e0cd3262ba667db0  protobuf-win64-2.5.0-gitian-r4.zip
8066120f974958c88a8590d159205f79c8f92da9d0791418a16265502aef881f  protobuf-win32-res.yml

Imgur

15. Build Omni Core for Windows:

If you do not intend to build binaries for Windows, you can skip this section.

Since the commit hash of the release is 2c46451da12c7ecb57a6edde5675bf121eb1790b, enter the following:

URL=https://github.com/mastercoin-MSC/mastercore.git
COMMIT=2c46451da12c7ecb57a6edde5675bf121eb1790b
./bin/gbuild --commit bitcoin=${COMMIT} --url bitcoin=${URL} ../bitcoin/contrib/gitian-descriptors/gitian-win.yml

This step is likely going to take a while.

Imgur

The expected build result hashes are:

10c1c236a21b923e74cdda87a5bee6f6d659512b51e8857fb0baad6cb153434b  32/bitcoin-0.9.3-win32-setup.exe
c97ca65a225c1587ec6b8c196600366ea07cb64359a4cca527c353b6f2b29a1d  32/bitcoin-cli.exe
fa4454a7d383cf7161e8a2009418606c96e2f5e1e195b50ddc21998679824e67  32/bitcoin-qt.exe
daa23e593d58416b95029210511e309474f862b82cfb20a4f41d9090c34efe04  32/bitcoind.exe
e76d16c91a0981ad1b01d7bfd7b25725d8e55578445caa10f63b517d58873d5d  32/test_bitcoin-qt.exe
ba1969bdf02ccf6a386875d5942878d34af8450b31b2d82438772481b42a294c  32/test_bitcoin.exe
e663e8d906bb114f33a5eef1768c17017793724444bd7175e19acaef03f007d4  64/bitcoin-0.9.3-win64-setup.exe
9ae3cbf74e3c6cafa3709a2082457362dd9075c5a21d394ee6ae664b322f2c9a  64/bitcoin-cli.exe
61345ee38b529f69799c5e392d4dba9f329deefd0a04f596731b58d72d0404dd  64/bitcoin-qt.exe
46a5ad5ffbf582738043ff3b9ff6cc7d2e9bda936749a5a99064c774bb0e9ef3  64/bitcoind.exe
9c86d51b86c47f643018db5b80698e7b80365f903933f9be5590e21f18ac0b24  64/test_bitcoin-qt.exe
bfdd3b4fce1823018f2edf811854eab1ebe6ebe8c2a810c0f1e59c6dd75cbf59  64/test_bitcoin.exe
87c9db294441549205abaf59d48a9fc176dfcad4a540ac043300960f5bea7a20  src/bitcoin-0.9.3.tar.gz
ebf18cd774aeb7bdd54c9fb28d29323351735de44e82dd5e1b540691de3ce628  bitcoin-res.yml

Imgur

16. Prepare zipped package of Omni Core:

If you do not intend to publish a zipped package, you can skip this section.

To navigate to the build results, which are stored in /home/debian/gitian-builder/build/out/64, enter the following:

cd build/out/64

The release package is going to include mastercore-cli.exe, mastercored.exe, mastercore-qt.exe and a file with file hashes. Enter:

mv bitcoin-cli.exe mastercore-cli.exe
mv bitcoind.exe mastercored.exe
mv bitcoin-qt.exe mastercore-qt.exe
sha256sum mastercore-cli.exe mastercored.exe mastercore-qt.exe > sha256sum.txt

To deterministically zip the files, the access and modification times need to be updated to a known reference time and the files must be zipped in exactly the same order. Enter the following:

touch -t 201306010000 mastercore-cli.exe mastercored.exe mastercore-qt.exe sha256sum.txt
zip -X omnicore-v0.0.9.1-rel-win.zip mastercore-cli.exe mastercored.exe mastercore-qt.exe sha256sum.txt

To confirm the expected results, enter:

echo "393a187984d7614b58acee2193ec4394  omnicore-v0.0.9.1-rel-win.zip" | md5sum -c
echo "41edc70223dc34ed36fb6d417eed62895577f577  omnicore-v0.0.9.1-rel-win.zip" | sha1sum -c
echo "f012d5511a5be06659fa4a18099424bee9f77a1648c0f1255223f401ba480198  omnicore-v0.0.9.1-rel-win.zip" | sha256sum -c

Imgur

To generate file hashes, which can be used to publish, enter:

md5sum omnicore-v0.0.9.1-rel-win.zip > omnicore-v0.0.9.1-rel-win.zip.md5
sha1sum omnicore-v0.0.9.1-rel-win.zip > omnicore-v0.0.9.1-rel-win.zip.sha1
sha256sum omnicore-v0.0.9.1-rel-win.zip > omnicore-v0.0.9.1-rel-win.zip.sha256

Finally move all results to the home dir:

mv omnicore-v0.0.9.1-rel-win.* /home/debian/

17. Move files from VM:

Get an SFTP client such as FileZilla:

https://filezilla-project.org/download.php?type=client

Connect to:

  • Host: localhost
  • Port: 22222
  • Protocol: SFTP - SSH File Transfer Protocol
  • User: debian
  • Password: somepw

Imgur

Move the files to your local machine. The results are available here:

/home/debian/omnicore-v0.0.9.1-rel-win.zip
/home/debian/omnicore-v0.0.9.1-rel-win.zip.md5
/home/debian/omnicore-v0.0.9.1-rel-win.zip.sha1
/home/debian/omnicore-v0.0.9.1-rel-win.zip.sha256

18. Build dependencies for Linux:

Note: befores starting a new build, make sure the results were moved!

If you do not intend to build binaries for Linux, you can this section, but otherwise enter line by line:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/boost-linux.yml
mv build/out/boost-*.zip inputs/

The following result hashes are expected:

f29b7d9577417333fb56e023c2977f5726a7c297f320b175a4108cf7cd4c2d29  boost-linux32-1.55.0-gitian-r1.zip
88232451c4104f7eb16e469ac6474fd1231bd485687253f7b2bdf46c0781d535  boost-linux64-1.55.0-gitian-r1.zip

Then enter:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/deps-linux.yml
mv build/out/bitcoin-deps-*.zip inputs/

The following result hashes are expected:

b66e8374031adf8d5309c046615fe4f561c3a7e3c1f6885675c13083db0c4d3b  bitcoin-deps-linux32-gitian-r8.zip
ec83deb4e81bea5ac1fb5e3f1b88cd02ca665306f0c2290ef4f19b974525005e  bitcoin-deps-linux64-gitian-r8.zip

And finally:

./bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-linux.yml
mv build/out/qt-*.tar.gz inputs/

The following result hashes are expected:

57e57dbdadc818cd270e7e00500a5e1085b3bcbdef69a885f0fb7573a8d987e1  qt-linux32-4.6.4-gitian-r1.tar.gz
60eb4b9c5779580b7d66529efa5b2836ba1a70edde2a0f3f696d647906a826be  qt-linux64-4.6.4-gitian-r1.tar.gz

19. Build Omni Core for Linux:

If you do not intend to build binaries for Linux, you can skip this section.

The process is similar to building binaries for Windows, but a different build descriptor is used.

Enter the following:

URL=https://github.com/mastercoin-MSC/mastercore.git
COMMIT=2c46451da12c7ecb57a6edde5675bf121eb1790b
./bin/gbuild --commit bitcoin=${COMMIT} --url bitcoin=${URL} ../bitcoin/contrib/gitian-descriptors/gitian-linux.yml

This step is also likely going to take a while.

The expected build result hashes are:

TODO: insert hashes

You may back to step 16 and repeat step 17, but with Linux build results.

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