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

Shane Kinney modsix at gmail.com
Tue Jan 27 03:37:17 UTC 2015


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

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

       [                    Date: 2015.01.25                 ]
       [                 Version: 0.0.4                      ]
       [                  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 db_config.tar.gz
        curl [R.11] -s -o rev_bump.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]  db_config.tar.gz
        [R.12]  rev_bump.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

  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

  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 ../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

        [ 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

  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/db_config.tar.gz
  [R.10]: b315dc1494334d24606622b7bd3a2569b53e5ad970971ee666ae7adc28fc7d65
  [R.11]: http://thebitcoin.foundation/rev_bump.tar.gz
  [R.12]: 5efe5de69b6fdb97ff445a1a37a5cc227dd77b59a8553b3ee235a378f352903a

[ 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

  [ 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)

iQIcBAEBCgAGBQJUxwIBAAoJEHIXBai3Hq2vsycP/2sfCaz4rv6TyD8L1C2FJ5PF
v4Vn/A8t/M27VhM8zEPQwFuvyv3+IbLfQPTJIhkpGKpx4IpIbJuH2c644x6aglJe
HD5j8VRCatjMnH/Bu4GfPaWlL4rDR+Kegf4aylLxzjaNjSvyNuEDxvj5YmZgr+JO
hsuB3Tb44kJheB5Oi4f171tc09OljZMfHT81YBlqaT56vHt9JArfcR6EKz2gcTBq
1aUWNKhjIJ1RH1+6UsZ8zP5PYoZIGwY6f+dt7GeeSwXvN7rPiKKU4sj3fmUVabHV
lhai9JjJ85GrBTbOdnNJavDIUPmyM0siGPQtJ/Ylr8J2rIaQu+gjauMcRUqaH9AN
fVn0q6fbPpwI54tFIkhGzh/tmbnDRMBvJG9yKTBH/fjFkdZUm5A0hXWA6C8JjWMS
p9/FnP5DEeRNjIukoAPhJGyUHtWmbs+AK9kW80d3RFjYI1gCTEsGQ4W5+ZNRjIr1
1HK8F50BYC4Tz4GLquMZDwZ2oRSslORK5wdVapaectsFxyiXbH/HFTUIkB+LhggX
HAfW/RRrCIIPg9jGQJqFPmrgk+roqKGxu1+X4JfL4QQav5BXdNbiZLN6Sc5yp/+Q
GnSJZP8pktV99z5bOxN4D2E9yO1pSN4c2kPylhufX93oxXtVgvYWWKTbFOu7v8w3
Sw8+j1myZL9owzOwRqkv
=qp3C
-----END PGP SIGNATURE-----


More information about the BTC-dev mailing list