nyanrainbowcoinnyancoin

Gitian Build (Temporary / In Progress / May be Incorrect)

Currently based on Litecoin, will be updated to Nyancoin when that software is updated.

This guide is for actual hardware running Ubuntu. Other options are probably possible.

This was written in August 2015 and has not been updated since. Information below may be out of date or incorrect. Use at your own risk.

Definitions

Ubuntu - Linux type operating system which will be used for this example.
Gitian Builder - Software to build/compile other software in a predefined and controlled envirnoment.
Github - Website where multiple versions of software can be stored and worked on by many people simultaneously.
Git - Software used to control different versions of software, the basis of Github

Required items

An actual hardware computer (NOT a virtual machine, online hosting account or similar as they most likely will NOT work.)
At least 3GB of RAM is required.

For signing the results, a GPG key (if you do not have one, instructions to create one can be found in this separate guide (TO DO - LINK NOT YET DONE)

Purpose

This creates the Nyancoin software, but using a specific defined and controlled environment. Multiple people can (and should) do this, and their results should all be identical.
These results are then signed (to confirm they have not been altered) and publicly shared.
Once a certain number of identical results have been obtained, it is then reasonably certain that all of them were built from the same (i.e. correct) source.

Without this, it would be next to impossible to confirm exactly what had been built from where - leaving the possibility that the software could have been tampered with.

 

 

INITIAL SETUP AND INSTALLATION OF SOFTWARE

This section should only need to be done once.

1. Check BIOS settings

These are usually accessed immediately after powering on by pressing ESC / F1 or some similar key. Varies by manufacturer.
In the settings, look for for Virtulisation / VT-x / AMD-v. This must be ENABLED. Most machines have this disabled by default.
If changing, be sure to SAVE settings on exit.

2. Install Ubuntu 14.04 LTS 64 Bit, default options for eveything

An internet connection is required for this and everything else described later.
Be sure to make a note of the username and password - it will be required later.
If you already installed Ubuntu and then changed the BIOS settings, you must shut down and power off, then restart the machine.
DO NOT just select the 'restart' option from within Ubuntu.

Make sure it's the 64 bit version, as the 32 bit version will not work.

3. With Ubuntu loaded, open a terminal window

You will be in the default user's home directory, which should be /home/USERNAME/ (USERNAME is whatever user name you chose when installing Ubuntu)
All the commands below are typed in the terminal window.
Some of them will ask for a password - it's the one you chose when installing Ubuntu.

For those that have not used Linux/Unix type operating systems before, note that:
a. All commands are case sensitive. ls Ls lS LS are NOT the same, and only the correct one will work. This is not the sloppy world of Windows where anything goes!
b. Read the commands carefully, spelling and spacing matters, don't assume what they say.

4. Install tools etc

Installation of development tools and other items. Some of these need to be confirmed - Enter / Continue / Yes etc.
May take a while to download and install.

These are: add location of db4.8 packages, update list of packages, install developer tools, install gitian/VM related bits, update everything else to latest versions.

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install build-essential libboost-all-dev libdb4.8-dev libdb4.8++-dev libminiupnpc-dev libssl-dev
sudo apt-get install git ruby apache2 apt-cacher-ng python-vm-builder qemu-kvm
sudo apt-get dist-upgrade

5. After that has installed, check that essential items are working properly

sudo service apt-cacher-ng status

result should be: apt-cacher-ng is running.
If not, installation has failed or not done yet. Either install it, or remove and reinstall.

apt-cacher is used to avoid downloading packages multiple times - after downloading it caches (stores) the download for use again. Without it, the build process would download the required packages again and again, taking much longer and wasting your bandwith allowance if you have one.

sudo /usr/sbin/kvm-ok

result should be: /dev/kvm exists, KVM acceleration can be used
If not, it's either not installed, or more likely vt-x is not enabled in the BIOS.
The output from the command will give further useful information if there is a problem.
If the processor in your machine doesn't support VT-x at all, then it's game over - get a system that does support it.
(This is why it will NOT work in a virtual machine such as VirtualBox - VT-x is not supported in Virtualbox clients)

6. Download the Gitian software from Github

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

This will create a directory called gitian-builder which contains many other directories and files
May take a while depending on your internet connection.

7. Change to the newly created Gitian Builder directory

cd gitian-builder

You are now in the correct directory, to check

pwd

result should be /home/USERNAME/gitian-builder/

8. Create the virtual machine base

bin/make-base-vm --arch amd64 --suite precise

Output should be items such as .. Generating key pair...keys randomart image ... calling hook ... ETC
This will take a while and generate a massive long list of messages.

The keypair generated is used by later commands to log in to the virtual machine. This is unrelated to signing the builds, you do not need to do anything with the keypair that is created.

9. Check that it was actually created

ls

In the listing of items there should be a newly created file called base-precise-amd64.qcow2
You are still in the /home/USERNAME/gitian-builder directory at this point

 

 

CREATE AND TEST THE VIRTUAL MACHINE

Proves that all of the installing above was done properly and it actually works.

Still in the /home/USERNAME/gitian-builder directory as before.

10. Add the /libexec directory to the $PATH environment variable

PATH=$PATH:$(pwd)/libexec

This is required so the next commands can find what they are looking for.

11. Create a clean virtual machine (target) from the base file that was created before

make-clean-vm --arch amd64 --suite precise

Result should be Formatting.....
and it creates a file called target-precise-amd64.qcow2

12. Start the virtual machine

start-target 64 precise-amd64 &

& at the end is required, plenty of other documents have this missing due to obvious copy and paste without actually checking their work.

13. Check that the virtual machine is working by listing a few files

on-target ls -la

Result should be a directory listing of the virtual machine.

on-target is a command which logs into the virtual machine and then executes whatever command follows it.

If this does not work, check the file build.log located at /home/USERNAME/gitian-builder/var/build.log for any errors.
'Cannot set up guest memory 'pc.ram': Cannot allocate memory' means that the machine you are using does not have enough RAM installed. 3GB+ is required.

14. Stop the virtual machine

stop-target

This stops the virtual machine.
Shows an error: KILLING TARGET since did not shut down in 10 seconds - however does stop, unclear whether this is the correct behavior or not?

 

 

DOWNLOAD / BUILD THE COIN OF CHOICE

15. Change to the home directory

cd

Check this with

pwd

Result should be /home/USERNAME

16. Download Litecoin from github

git clone https://github.com/litecoin-project/litecoin.git

This creates a directory called litecoin which contains many other files and directories.

17. Set VERSION environment variable to required version

export VERSION=(0.10.2.2)

Versions as listed at https://github.com/litecoin-project/litecoin/releases
The numeric part only, as the 'v' is added in the commands later.
The latest one was used for this example which was 0.10.2.2

18. Change to the litecoin directory

pushd ./litecoin

This adds the existing directory to a list (stack) so we can return to it later using popd.

19. Select the version of litecoin to use for this build

git checkout v${VERSION}

This selects version v0.10.2.2 or whatever version was selected at 17.
Result should be a block of text stating the location/changes have been made.
checking out v0.10.2.2 ... detatched HEAD state ...HEAD is now at ...

20. Return to original directory and change to gitian-builder directory

popd
pushd ./gitian-builder

21. Create the inputs directory

mkdir -p inputs

This directory wiil contain the source code for litecoin and anything else needed to create this build.

22. Do the linux build

./bin/gbuild --commit litecoin=v${VERSION} ../litecoin/contrib/gitian-descriptors/gitian-linux.yml

The output from this is similar to
Initilised empty git repo in ... (THE INPUTS DIR)
Downloading etc..
Stopping / starting target
Peparing build environment
Upgrading system
Creating package manifest
~~massive list of files
Running build script (log in var/build.log)

Other documentation indicates this may take a long time. 95 minutes in this case - yes, hour and a half.
However it is not necessary to wait around while this is done - once started you can leave and return later.

If using a laptop, mains power will be required. It will get hot. Do not place laptop on lap.

It may well take less time on subsequent attempts, this has not yet been tested.

It says DONE when done. Eventually.

INCOMPLETE FROM HERE

--. Do the windows build

./bin/gbuild --commit litecoin=v${VERSION} ../litecoin/contrib/gitian-descriptors/gitian-win.yml

Output is similar to the linux build above, and gets to Running Build Script after a couple of minutes.

Completed after 101 minutes.

 

TO DO / IN PROGRESS

Signing the resulting builds which uses gpg by default. The 'gitian key' referred to in other documentation is actually just a normal GPG key.
The ./bin/gsign script uses gpg --detatch-sign -u NAME by default, as in:
system!("#{program} -u "#{signer}" "#{assert_path}"")

Mac build which requires files I do not have, see https://www.reddit.com/r/nyancoins/comments/3fh6im/crossplatform_gitian_builds/

Adding signatures to gitian.sigs

Updated 05 November 2017.