[BTC-dev] UPDATED v0.0.5: Patching The Reference Implementation: A Guide

Shane Kinney modsix at gmail.com
Thu Mar 19 02:13:44 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

   ..::[  The Bitcoin Foundation: Building with Patch Files  ]::..

       [                    Date: 2015.03.14                 ]
       [                 Version: 0.0.5                      ]
       [                  Author: mod6 [R.01]                ]

[ Introduction ]:

        For testing of all of the recently submitted patches and subsequent
        changes to the Bitcoin reference implementation; a Guide on how to
        properly verify patches, apply and build with them is necessary for
        individuals who wish to assist in the arduous testing process.

0x00] A Guide to Building the Bitcoin Reference Implementation with Patches

  0x01] Download Bitcoin source v0.5.3 [R.02] and verify sha256 hash [R.03]:
        curl [R.02] -s -o bitcoin-v0.5.3.tar.gz
        sha256sum bitcoin-v0.5.3.tar.gz

  0x02] Unpack the Bitcoin v0.5.3 code:
        tar -xf bitcoin-v0.5.3.tar.gz

  0x03] Download Patch Tarballs:
        curl [R.04] -s -o chicken.tar.gz
        curl [R.06] -s -o rm_rf_upnp.tar.gz
        curl [R.08] -s -o https-snipsnip.tar.gz
        curl [R.0A] -s -o turdmeister-alert-snip.tar.gz
        curl [R.0C] -s -o goodbye-win32.tar.gz
        curl [R.0E] -s -o db_config.tar.gz
        curl [R.10] -s -o rev_bump.tar.gz
        curl [R.12] -s -o static-makefile.tar.gz

  0x04] Check SHA256 Hashes of Patch Tarballs:
        sha256sum *.tar.gz
        [R.05]  chicken.tar.gz
        [R.07]  rm_rf_upnp.tar.gz
        [R.09]  https-snipsnip.tar.gz
        [R.0B]  turdmeister-alert-snip.tar.gz
        [R.0D]  goodbye-win32.tar.gz
        [R.0F]  db_config.tar.gz
        [R.11]  rev_bump.tar.gz
        [R.13]  static-makefile.tar.gz

  0x05] Unpack Patches:
        mkdir -p chicken && tar -xf chicken.tar.gz -C chicken
        tar -xf rm_rf_upnp.tar.gz
        mkdir -p https-snipsnip \
        && tar -xf https-snipsnip.tar.gz -C https-snipsnip
        mkdir -p alert-snip \
        && tar -xf turdmeister-alert-snip.tar.gz -C alert-snip
        mkdir -p goodbye-win32 \
        && tar -xf goodbye-win32.tar.gz -C goodbye-win32
        tar -xf db_config.tar.gz
        tar -xf rev_bump.tar.gz
        tar -xf static-makefile.tar.gz

  0x06] Verify Patch Signatures:
        gpg --verify chicken/bitcoin-asciilifeform.1.patch.sig
        gpg --verify rm_rf_upnp/rm_rf_upnp.patch.sig
        gpg --verify \
        https-snipsnip/bitcoin-asciilifeform.2-https_snipsnip.patch.sig
        gpg --verify \
        alert-snip/bitcoin-asciilifeform.3-turdmeister-alert-snip.patch.sig
        gpg --verify \
        goodbye-win32/bitcoin-asciilifeform.4-goodbye-win32.patch.sig
        gpg --verify db_config/bitcoin-v0_5_3-db_config.6.patch.sig
        gpg --verify rev_bump/bitcoin-v0_5_3_1-rev_bump.7.patch.sig
        gpg --verify \
        static-makefile/bitcoin-v0_5_3_1-static_makefile_v002.8.patch.sig

  0x07] Clean Source Base:

        mkdir bitcoin
        cd bitcoin-bitcoin-a8def6b
        for i in `cut -d ' ' -f 3- \
        ../chicken/bitcoin-0.5.3-no-crud.sha256.manifest`;
        do cp --parents $i ../bitcoin;
        done
        cd ..

        The following commands are optional, their output should be equal:

        find bitcoin -xtype f -print0 | xargs -0 sha256sum | wc -l
        cat chicken/bitcoin-0.5.3-no-crud.sha256.manifest | wc -l

  0x08] Patch Bitcoin v0.5.3 Source Base & Clean Up:

        [ NOTE ]: The Bitcoin v0.5.3 codebase must be patched with the
                  following patches in this exact order or it will not
                  patch cleanly.

        cd bitcoin

        cp ../chicken/bitcoin-asciilifeform.1.patch .
        patch -p1 < bitcoin-asciilifeform.1.patch
        cp ../rm_rf_upnp/rm_rf_upnp.patch .
        patch -p1 < rm_rf_upnp.patch
        cp ../https-snipsnip/bitcoin-asciilifeform.2-https_snipsnip.patch .
        patch -p1 < bitcoin-asciilifeform.2-https_snipsnip.patch
        cp ../alert-snip/bitcoin-asciilifeform.3-turdmeister-alert-snip.patch .
        patch -p1 < bitcoin-asciilifeform.3-turdmeister-alert-snip.patch
        cp ../goodbye-win32/bitcoin-asciilifeform.4-goodbye-win32.patch .
        patch -p1 < bitcoin-asciilifeform.4-goodbye-win32.patch
        cp ../db_config/bitcoin-v0_5_3-db_config.6.patch .
        patch -p1 < bitcoin-v0_5_3-db_config.6.patch
        cp ../rev_bump/bitcoin-v0_5_3_1-rev_bump.7.patch .
        patch -p1 < bitcoin-v0_5_3_1-rev_bump.7.patch
        cp ../static-makefile/bitcoin-v0_5_3_1-static_makefile_v002.8.patch .
        patch -p1 < bitcoin-v0_5_3_1-static_makefile_v002.8.patch

        [ CLEAN-UP ]:
        rm bitcoin-asciilifeform.1.patch
        rm rm_rf_upnp.patch
        rm bitcoin-asciilifeform.2-https_snipsnip.patch
        rm bitcoin-asciilifeform.3-turdmeister-alert-snip.patch
        rm bitcoin-asciilifeform.4-goodbye-win32.patch
        rm bitcoin-v0_5_3-db_config.6.patch
        rm bitcoin-v0_5_3_1-rev_bump.7.patch
        rm bitcoin-v0_5_3_1-static_makefile_v002.8.patch

        cd ..

  0x09] Compile Static Binary with Patched Source:
        From the below section: `auth.sh', cut the code from
        "#!/bin/bash" to "###### EOF ######" into `auth.sh'.
        The `auth.sh' script should be placed in the same
        directory as the `bitcoin' directory.

        chmod +x auth.sh
        ./auth.sh

[ References ]:
  [R.01]: 027A 8D7C 0FB8 A166 4372 0F40 7217 05A8 B71E ADAF
  [R.02]: https://codeload.github.com/bitcoin/bitcoin/legacy.tar.gz/v0.5.3
  [R.03]: aab1f8ea8c7f131ff69dfa3b9437ba35531018be760132dd6373f41a591f6382
  [R.04]: http://thebitcoin.foundation/chicken.tar.gz
  [R.05]: 63164ea54f042226a6aa8768b98b0f323d66f08693c6fd271a850c00308517ad
  [R.06]: http://thebitcoin.foundation/rm_rf_upnp.tar.gz
  [R.07]: f5f27b806b90b0ffd3d2d73e240eba02f13c5dec3d693b37e08686d04164861a
  [R.08]: http://thebitcoin.foundation/https-snipsnip.tar.gz
  [R.09]: 047844a601bc575d7660826b02f0d640f02ae84cd641f45552c825b72bc116f4
  [R.0A]: http://thebitcoin.foundation/turdmeister-alert-snip.tar.gz
  [R.0B]: 39b5aac2b6de016eda23a96fe6f9a565dbbe4f4aa46e8584c102ee71fa4fe7f4
  [R.0C]: http://thebitcoin.foundation/goodbye-win32.tar.gz
  [R.0D]: 5149a481629e0f10b659d38fee0736e0b6e631ab3bbeb6cde449aa61226cdbb3
  [R.0E]: http://thebitcoin.foundation/db_config.tar.gz
  [R.0F]: b315dc1494334d24606622b7bd3a2569b53e5ad970971ee666ae7adc28fc7d65
  [R.10]: http://thebitcoin.foundation/rev_bump.tar.gz
  [R.11]: 5efe5de69b6fdb97ff445a1a37a5cc227dd77b59a8553b3ee235a378f352903a
  [R.12]: http://thebitcoin.foundation/static-makefile.tar.gz
  [R.13]: ae1498e577281f591a9bb9e4b6153af7f5eab8ff628b75b71b06be0dc7f564ab

[ Public Key Fingerprints ]:

  [ asciilifeform ]:
    1721 5D11 8B72 3950 7FAF ED98 B982 28A0 01AB FFC7
    http://bitcoin-otc.com/viewgpg.php?nick=asciilifeform

  [ ben_vulpes ]:
    4F79 0794 2CA8 B89B 01E2 5A76 2AFA 1A9F D2D0 31DA
    http://bitcoin-otc.com/viewgpg.php?nick=ben_vulpes

  [ mod6 ]:
    027A 8D7C 0FB8 A166 4372 0F40 7217 05A8 B71E ADAF
    http://bitcoin-otc.com/viewgpg.php?nick=mod6

[ auto.sh ]:

#!/bin/sh

# v0.0.5

# Set the BOOST_ADDRESS_MODEL of the Build Environment for BOOST
BOOST_ADDRESS_MODEL=64
# Set the BOOST_ARCH_TYPE of the Build Environment for BOOST
BOOST_ARCH_TYPE=x86_64
# Set the target os & arch type for OpenSSL
SSL_ARCH_TYPE=linux-x86_64

if [ "$#" -gt 0 ]; then
  if [ "$1" = "clean" ]; then
    cd bitcoin/src
    make -f makefile.unix clean
    exit 0;
  fi
fi

REALPATH=`which realpath`
if [ -f $REALPATH ] && [ "$REALPATH" != "" ]; then
  echo "Found realpath."
else
  echo "Didn't find realpath, please install 'realpath'"
  exit 1;
fi

CURL=`which curl`
if [ -f $CURL ] && [ "$CURL" != "" ]; then
  echo "Found curl."
else
  echo "Didn't find curl, please install 'curl'"
  exit 1;
fi

if [ ! -d distfiles ]; then
  mkdir distfiles;
fi

if [ ! -d ourlibs ]; then
  mkdir ourlibs;
fi

OPENSSL=openssl-1.0.1g
BDB=db-4.8.30
BOOST=boost_1_52_0

DIST=./distfiles
OURLIBS=$(realpath ./ourlibs)

export CC=gcc
export CXX=g++
export LD=ld
export CFLAGS=-I/usr/include
export LDFLAGS=-L/usr/lib
export PATH=$PATH:/usr/bin

if [ ! -d "$OPENSSL" ]; then
  curl "http://openssl.org/source/old/1.0.1/openssl-1.0.1g.tar.gz" \
   -s -o distfiles/openssl-1.0.1g.tar.gz
  SSL_SHA256=`sha256sum distfiles/openssl-1.0.1g.tar.gz |
   sed -n 's/^\(.*\) .*$/\1/p' | tr -d ' '`;
  SSL_HASH="53cb818c3b90e507a8348f4f5eaedb05d8bfe5358aabb508b7263cc670c3e028";
  if [ "$SSL_SHA256" != "$SSL_HASH" ]; then
    echo "OpenSSL Hash did not match!  Expected: $SSL_HASH Found:
$SSL_SHA256";
    exit 1;
  fi
  tar xfz $DIST/$OPENSSL.tar.gz;
  cd $OPENSSL;
  ./Configure --prefix=$OURLIBS $SSL_ARCH_TYPE \
  no-dso no-shared && make && make install;
  cd ..;
else
  echo "Found 'openssl-1.0.1g', skipping..."
fi

if [ ! -d "$BDB" ]; then
  curl "http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz" \
   -s -o distfiles/db-4.8.30.tar.gz
  BDB_SHA256=`sha256sum distfiles/db-4.8.30.tar.gz |
   sed -n 's/^\(.*\) .*$/\1/p' | tr -d ' '`;
  BDB_HASH="e0491a07cdb21fb9aa82773bbbedaeb7639cbd0e7f96147ab46141e0045db72a";
  if [ "$BDB_SHA256" != "$BDB_HASH" ]; then
    echo "BDB Hash mis-match!  Expected: $BDB_HASH Found: $BDB_SHA256";
    exit 1;
  fi
  tar xfz $DIST/$BDB.tar.gz;
  cd $BDB/build_unix;
  ../dist/configure --enable-cxx --prefix=$OURLIBS &&
  make &&
  make install &&
  cd ../..;
else
  echo "Found 'db-4.8.30', skipping..."
fi

if [ ! -d "$BOOST" ]; then
  boost="http://sourceforge.net/projects/boost/files/boost"
  curl -L "$boost/1.52.0/boost_1_52_0.tar.gz" \
   -s -o distfiles/boost_1_52_0.tar.gz
  BOOST_SHA256=`sha256sum distfiles/boost_1_52_0.tar.gz |
   sed -n 's/^\(.*\) .*$/\1/p' | tr -d ' '`;
  BOOST_HASH="eea637a4ce9f9b45a0d5e00bb9462c9f084086264d85d63133dd6d240398b28f";
  if [ "$BOOST_SHA256" != "$BOOST_HASH" ]; then
   echo "Boost Hash mis-match!  Expected: $BOOST_HASH Found: $BOOST_SHA256";
   exit 1;
  fi
  tar xfz $DIST/$BOOST.tar.gz;
  cd $BOOST;
  echo "using gcc : $BOOST_ARCH_TYPE : $CXX ;" >
tools/build/v2/user-config.jam;
  ./bootstrap.sh;
  ./bjam toolset=gcc address-model=$BOOST_ADDRESS_MODEL \
  link=static -sNO_BZIP2=1 -sNO_ZLIB=1 -sNO_COMPRESSION=1;
  ./bjam toolset=gcc address-model=$BOOST_ADDRESS_MODEL \
  link=static --prefix=$OURLIBS install;
  cd ..;
else
  echo "Found 'boost_1_52_0', skipping..."
fi

export BOOST_INCLUDE_PATH=$OURLIBS/include
export BDB_INCLUDE_PATH=$OURLIBS/include
export OPENSSL_INCLUDE_PATH=$OURLIBS/include
export BOOST_LIB_PATH=$OURLIBS/lib
export BDB_LIB_PATH=$OURLIBS/lib
export OPENSSL_LIB_PATH=$OURLIBS/lib
export LDFLAGS=

cd bitcoin/src;
make LMODE=static LMODE2=static -f makefile.unix bitcoind
strip bitcoind
echo "Done!"
###### EOF ######
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (FreeBSD)

iQIcBAEBCgAGBQJVCiC4AAoJEHIXBai3Hq2vhWwP/j0Vq0qaxHgU3r1mE+d38Z+n
oDNzJd4NATaW2wDzPzjw2JjtNNqOBJtbebiQoDrXQHa/ZZ54pWqgln7SplrU9O+p
7d8PL0nvtmgOHBv9hJvz9c56Qe3tJqwJYPJE/eWsnjILErPgSWyOZrmkVwrlb7xc
EwsVBbODbgZzm5gd1UiZJIGRGg1swQq3fkGTlKZnrUQm+rBv0UQbLAENsmjXrKPf
6oZRBGsg28s4PJAL5XdWtkUdSRwRjJ+EhqTIw2esJLkv2hWiSB9yPCyXMvSVAjnt
te+yhQYagusYobdFFKNCxfVBaN+Y2dqtimNorwF+XJsguJG1VjGEdKEeMjDfScAT
TKbZAxefNmkIVXKtS70/y/1amlenINo4rgcqRCYqRF+A/H0CzpaN90PfEAufTGt/
Np68mXFZ5D5HvWxwo1zb6EbDwzs1sI2TYHXird59P9ifY5YNTh8dddqnNqO2mPWn
PK9M9g5h/i9GmfMXEQTDV05TLOohgBEVZodpbYJD4knTUVLazwmNJYNc2SuoP7l5
fxstnd5cxQ+rLeJxOT0NFTOi1Y43LSKOjlcGMKP6znMvTZO091g5iZPWCELOmiJC
2eOzgvdkoluUQx+uAHU7Z4I5WdxTXKZYerJ0r9yd4hS3hLuvN5aVHX6H1M1ckf8Z
uF+pLJYyKuEoTjSXXLoB
=J+yI
-----END PGP SIGNATURE-----


More information about the BTC-dev mailing list