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

Shane Kinney modsix at gmail.com
Wed Dec 31 20:14:25 UTC 2014


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


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

       [                    Date: 2014.12.30                 ]
       [                 Version: 0.0.2                      ]
       [                  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.0F] -s -o rm_checkpoints.tar.gz
        curl [R.11] -s -o db_config.tar.gz

  0x04] Check SHA256 Hashes of Patch Tarballs:
        sha256sum *.tar.gz
        [R.05]  chicken.tar.gz
        [R.0D]  goodbye-win32.tar.gz
        [R.09]  https-snipsnip.tar.gz
        [R.07]  rm_rf_upnp.tar.gz
        [R.0C]  turdmeister-alert-snip.tar.gz
        [R.10]  rm_checkpoints.tar.gz
        [R.12]  db_config.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
        mkdir -p rm_checkpoints \
        && tar -xf rm_checkpoints.tar.gz -C rm_checkpoints
        mkdir -p db_config && tar -xf db_config.tar.gz -C db_config

  0x06] Verify Patch Signatures:
        gpg --verify 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 rm_checkpoints/bitcoin-v0_5_3-rm_checkpoints.5.patch.sig
        gpg --verfiy db_config/bitcoin-v0_5_3-db_config.6.patch.sig

  0x07] Clean Source Base with PinkPosixPXE's [R.0E] prune-manifest.sh script:

        From the below section: ``prune-manifest.sh'', cut the code from
        "#!/bin/bash" to "###### EOF ######" into ``prune-manifest.sh''

        [ NOTE ]: Be sure to edit the following two lines of the script to
                  correspond with the appropriate locations of the ``chicken''
                  directory and the unpacked bitcoin-bitcoin-a8def6b directory:

                  bitcoin="${HOME}/bitcoin-2014-11-23/bitcoin-bitcoin-a8def6b"
                  chicken="${HOME}/bitcoin-2014-11-23/chicken"

        chmod +x prune-manifest.sh
        ./prune-manifest.sh

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

        find bitcoin-bitcoin-a8def6b \
        -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-bitcoin-a8def6b

        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 ../rm_checkpoints/bitcoin-v0_5_3-rm_checkpoints.5.patch .
        patch -p1 < bitcoin-v0_5_3-rm_checkpoints.5.patch
        cp ../db_config/bitcoin-v0_5_3-db_config.6.patch .
        patch -p1 < bitcoin-v0_5_3-db_config.6.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-rm_checkpoints.5.patch
        rm bitcoin-v0_5_3-db_config.6.patch

  0x09] Compile Patched Source:

        cd src
        make -f makefile.unix

[ 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]: 3DAE 5385 2AF4 7432 CE3C 9318 FF23 EAA3 D815 427F
  [R.0F]: http://thebitcoin.foundation/rm_checkpoints.tar.gz
  [R.10]: 979c1bac78f189783a1a6748980a327a197c2cb14521c8aeb153c20ddc706224
  [R.11]: http://thebitcoin.foundation/db_config.tar.gz
  [R.12]: b315dc1494334d24606622b7bd3a2569b53e5ad970971ee666ae7adc28fc7d65

[ 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/viewratingdetail.php?nick=mod6

  [ PinkPosixPXE ]:
    3DAE 5385 2AF4 7432 CE3C 9318 FF23 EAA3 D815 427F
    http://bitcoin-otc.com/viewratingdetail.php?nick=pinkposixpxe

[ prune-manifest.sh ]:

#!/bin/bash
## prune_manifest.sh ##
## Prune Bitcoin Manifests ##
## Author: PinkPosixPXE - 11/2014 ##

### Put path to bitcoin dir and chicken dir within these variables ###
bitcoin="${HOME}/bitcoin-2014-11-23/bitcoin-bitcoin-a8def6b"
chicken="${HOME}/bitcoin-2014-11-23/chicken"

#### MANIFESTS AND FILE LISTS ####
chickenManifest="${chicken}/bitcoin-0.5.3-no-crud.sha256.manifest"
### tmp files created for filelists, comparisons, and pruning ###
newManifest=/tmp/new-bitcoin.manifest
btcManifest=/tmp/bitcoin-a8def6b.manifest
btcFiles=/tmp/bitcoin-a8def6b.files
newFiles=/tmp/new-bitcoin.files
pruneFiles=/tmp/prune-bitcoin.files

### Array to track file varname, for checking before pruning ###
fileArr=(newManifest btcManifest chickenManifest btcFiles newFiles pruneFiles)
####  INIT ####
### Create required manifests, filelists, and prunelists ###
init() {
  cd ${bitcoin}
  ### Ensure our src dirs exist ###
  if [[ ! -d "${bitcoin}" ]]; then
    echo "Error: Can't find bitcoin src path: ${bitcoin}"
    exit 1
  elif [[ ! -d "${chicken}" ]];then
    echo "Error: Can't find chicken src path: ${chicken}"
    exit 1
  fi
  ### clean old tmp files ###
  rm -v ${newManifest} ${btcFiles} ${newFiles} ${pruneFiles} 2>/dev/null
  ### Create manifest of current bitcoin src ###
  find . -xtype f -exec sha256sum {} \; | sort > ${btcManifest}
  while read line;
  do
    mFile=$(echo "${line}" | awk '{print $2}')
    grep "${mFile}" ${chickenManifest} >> ${newManifest}
  done < ${btcManifest}
  ### Manifest parsing ###
  awk '{print $2}' ${btcManifest} | sort >> ${btcFiles}
  awk '{print $2}' ${chickenManifest} | sort >> ${newFiles}
  comm -23 ${btcFiles} ${newFiles} >> ${pruneFiles}
}

checkFiles() {
  ## Test files exist, and aren't empty ##
  for filevar in ${fileArr[*]}
  do
    file="${!filevar}"
    ## Check if file exists, or is mising ##
    test ! -e "${file}" || test ! -s "${file}" &&{
      echo "Error: Required File Missing, or empty: ${file}"
      exit 1
    }
  done
  ### Check files marked for pruning ###
  while read file
  do
    egrep '^'${file}'$' ${newFiles} && {
      echo "Check Failed: required file marked for deletion: ${file}"
      exit 1
    }
  done< ${pruneFiles}
  return 0
}

pruneFiles() {
  echo "Checks Passed -> Pruning unneeded files from manifest"
  ## Prune manifest, dirs, and tmp files ##
  ## If you want it to remove the files quietly, remove the -v ##
  rm -fv $( < ${pruneFiles} ) 2>/dev/null
  rm -fv ${newManifest} ${btcFiles} ${btcManifest} \
  ${newFiles} ${pruneFiles} 2>/dev/null
  rm -rfv ./contrib ./doc ./scripts ./share
}

init
checkFiles
pruneFiles
###### EOF ######
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (FreeBSD)

iQIcBAEBCgAGBQJUpFa9AAoJEHIXBai3Hq2vHgsQAK/9bSRNHXaAxkLHK2cDPxv5
jWD7wfV7pBMEMw89wvjgQxXNZXc2H0q2VNfPvYU9nAsjtd9NvHSeBzpdCSIEa0ju
Boq/2m9CREj7PN6eWQ3x0mQ2Movo6dlB1B+DHktBcjn63r834X2C/epe/pAGG/2r
YacwpEgj7Co6U39pL+YjKncZWcCll7u6irt3qyBtmXJrRw6+OoXwfF1YpKO7zOLX
6CqdffaUbezNxQiKeTAA0GAwuyY072nvvQehqFgwEul7q3q9VV41o6X+QLAfB+sT
Z0BqNSMBKcpmnkwejuLy1aLAxKO6s9ywKoZQfSnKJCvjQfyo1Q68vg6B44gQRac2
vAPctTj6LzBvxJoBP0zyr7PxMtbUc262FncbqFLDJLq32JBzOjh1AXU7ikHlWTet
em5aGszN34AfHbPozenI7dOZaPjXPItnFOtDFS4ViNsdzpeyhpGpPNGJE7T+17EK
0b/wrIJg5DYldqHOqgcXn0gkdpH1B6vUzv+Bqy6gP/Gd02Bi9T/ajAESP+3Damnq
bIU7BCNLsj4Lau5Rc99YA7dDQZbiYAijlSwwEP3B2JKG4H71oj7CrJgycpYCc0Rf
O5whcOS46iO0Ltq1O12xYRBVd2NaGCEdkLrMZtzI8OJYO7HgDtlxov/VCNDeXz/B
yIA0fNJTiHsV0ONorcGy
=kEux
-----END PGP SIGNATURE-----


More information about the BTC-dev mailing list