Build cryptocoin wallet/client on Linux

The following script can be used to automatically build most cryptocoin wallets/clients on Linux. You may also want to check out my post on compiling the memecoin client.
Git repositories should be defined in a file named ‘gits’ and it should be placed in the same folder as the script. Each line can contain only 1 repository and commented out repositories have their source folder deleted (so be aware of this !).

Sources are checked out in a subfolder ‘autobuild’ and all executables are compiled in the source folder:

./autobuild.sh
./gits
./autobuild
./autbuild/primecoin/primecoin-qt
./autobuild/bitcoin/bitcoin-qt
./autobuild/litecoin/litecoin-qt

Clients will be build without UPNP, IPv6 or QR-Code support. If you plan on moving your wallets between different devices than it is strongly encourage to verify that the installed Berkley DB (libdb) has version 4.8 . If you run a recent version of Ubuntu then you certainly won’t have version 4.8 in your repositories.

You need at least 786MB of RAM; insufficient resources will result in gcc being killed.

The script:

#!/bin/bash
# P_W999 - 2013 - This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
# http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US
# This script comes as-is, with no guarantees or waranties and it is used at own risk.
# v0.1 - 2013-10-05
# * Initial release
# v0.2 - 2013-11-02
# * Removed auto-installation of dependencies because they usually have different names on different distributions
# * Added warning about Berkley 4.8 <-> 5.x
# v0.3 - 2013-11-02
# * Fix for AnonCoin client (i2psam dependency)
# v0.4 - 2013-11-02
# * Added dependencies for openSuse
DEPENDENCIES=(build-essential libssl-dev libdb-dev libdb++-dev libboost-all-dev libqrencode-dev qt4-qmake libqtgui4 libqt4-dev libprotobuf-dev libprotoc-dev protobuf-compiler git autoconf automake)
DEPENDENCIES_OPENSUSE=(gcc-c++ make glibc-devel libopenssl-devel libdb-4_8-devel boost-devel qrencode-devel devel_qt4 libqt4-x11 libqt4-devel protobuf-devel protobuf-c libprotoc7 git autoconf automake)
echo "You need the following dependencies to compile the cryptocoin clients: "
echo "(X/K)Ubuntu/Devian: ${DEPENDENCIES[*]}"
echo "openSuse: ${DEPENDENCIES_OPENSUSE[*]}"
echo "WARNING: Please add following PPA to ensure you have libdb-4.8: https://launchpad.net/~bitcoin/+archive/bitcoin"
echo "         Using newer versions of libdb can break binary compatibility"
 
#Set default line separator
IFS=$'\n'
 
#Create directory where source code will be checked out and executable will be compiled
if [ ! -d "autobuild" ]
then
    mkdir autobuild
fi
cd autobuild
 
#Read every line in the input file
for line in `cat ../gits` ; do
    #Get the /xxx.git part of the URL
    gitAdres=`expr "$line" : '.*\(/[a-zA-Z0-9]*\.git\)'`
        #Drop the '/' and the '.git' part
    gitPath=${gitAdres:1:-4}
        #If line commented out, delete the source folder (TODO: make this an option ? )
    if [[ $line =~ ^#.* ]]
        then
                echo Checkout: skipping and deleting $gitPath
        if [ -d "$gitPath" ]
        then
            rm $gitPath --recursive -f
        fi
    else
        #Output folder already exists: make a pull request to update source code
        if [ -d "$gitPath" ]
        then
            echo Checkout: pulling $gitPath
            cd "$gitPath"
            git pull &>>pull.out
            cd ..
        #Output folder does not exist: make a clone request to get source code
        else
            echo Checkout: cloning $gitPath
            git clone $line &>>clone.out
        fi
    fi
done
 
#All source code is checked out in different folder
#Go into each folder and build the source code
for dir in `find . -maxdepth 1 -type d | grep [^\.]` ; do
    cd $dir
    echo Pre-build: in `pwd`
    #Some clients come with a build_detect_platform script. After check out, this file is not executable.
    if [ -f src/leveldb/build_detect_platform ]
    then
        echo Pre-build: chmod +x on build_detect_platform
        chmod +x src/leveldb/build_detect_platform
    fi
    if [ -f i2psam/makefile.unix ]
    then
        echo First making i2psam
        cd i2psam
        make -f makefile.unix &>> i2psam.out
        cd ..
    fi
    #Delete old build log (XXX: not realy needed)
    if [ -f "build.out" ]
    then
        rm build.out
    fi
    #Some libraries have hardcoded lib-boost suffixes. Remove these from the qmake.pro file since not needed on (X)Ubuntu (TODO: not sure about others)
    echo Pre-build: Ensuring no lib-boost version is hardcoded
    for pro in `find -maxdepth 1 -iname *.pro` ; do
        sed -i 's/-mgw46-mt-sd-1_53//g' $pro
    done
    #Bitcoin client uses autoconf instead of qmake
    if [ -f "autogen.sh" ]
    then
        echo Building with autoconf
        ./autogen.sh &>>build.out
        ./configure USE_UPNP=- USE_QRCODE=0 USE_IPV6=0 --with-incompatible-bdb &>>build.out
        make &>>build.out
    #Most clients use qmake + make
    else
        echo Building with qmake
        qmake USE_UPNP=- USE_QRCODE=0 USE_IPV6=0 &>>build.out
        make &>>build.out
    fi
    status=$?
    if test $status -eq 0
    then
        echo Exit code was normal
    fi
    cd ..
done

This script was tested on Xubuntu 13.04, openSuse 12.3, Linux Mint 16 with the following repositories:

The following clients currently don’t build correctly

Depending on the cryptocoin-client, the compilation may take a while and it might look like nothing happens. The compilation output is redirected to ./autobuild//build.out .

//Update 2013-11-02: tested with more clients, added some more info, changed script to v0.4
//Update 2013-12-20: added DogeCoin to the list after testing it
//Update 2014-01-05: tested on Linux Mint 16 (Petra) XFCE edition + fix WordPress messing up the script

Advertisements

One thought on “Build cryptocoin wallet/client on Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s