|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This script will do code related release preparation stuff for Bitcoin Core as specified in |
| 4 | +# the release-process.md file. |
| 5 | +# This should be run from the folder containing the Source tree |
| 6 | +# The following actions will be done: |
| 7 | +# 1. Set the version numbers as specified in the arguments |
| 8 | +# 2. Update src/chainparams.cpp nMinimumChainWork and defaultAssumeValid with information from the getblockchaininfo rpc. |
| 9 | +# 3. Update Hard coded seeds |
| 10 | +# 4. Set BLOCK_CHAIN_SIZE |
| 11 | +# 5. Update translations |
| 12 | +# 6. Generate updated manpages |
| 13 | +# Note: Step 2 assumes that an up-to-date Bitcoin Core is running and has been built in the |
| 14 | +# directory which this script is being run. |
| 15 | + |
| 16 | +# Variables |
| 17 | +VERSION= |
| 18 | +BLOCK_CHAIN_SIZE= |
| 19 | +DATADIR="" |
| 20 | +verBump=true |
| 21 | +chainparamsUpdate=true |
| 22 | +seedUpdate=true |
| 23 | +blockchainsizeBump=true |
| 24 | +translationsUpdate=true |
| 25 | +genManpages=true |
| 26 | + |
| 27 | +# Help Message |
| 28 | +read -d '' usage <<- EOF |
| 29 | +Usage: $scriptName version block_chain_size |
| 30 | +
|
| 31 | +Run this script from the Bitcoin Core Source root directory. This requires a current version of Bitcoin Core |
| 32 | +to be running at the time that this script is run. |
| 33 | +
|
| 34 | +Arguments: |
| 35 | +version Version number to set following the MAJOR.MINOR.REVISION format. Only required if |
| 36 | + a version bump will be done. e.g. 0.14.0 |
| 37 | +block_chain_size The size of the blockchain for the intro display. Should contain a little bit of |
| 38 | + overhead. Only required if BLOCK_CHAIN_SIZE will be updated. e.g. 120 |
| 39 | +
|
| 40 | +Options: |
| 41 | +--datadir <path> The path to the data directory of the running Bitcoin Core node. Note that this is |
| 42 | + different from Bitcoin Core's -datadir option syntax. There is no equals, simply a space |
| 43 | + followed by the path |
| 44 | +
|
| 45 | +--skip [v|c|s|b|t|m] Skip the specified steps. v=version bump; c=update nMinimumChainwork and defaultAssumeValid |
| 46 | + s=hard coded seed update; b=blockchain size bump; t=translations update; m=generate manpages. |
| 47 | + The steps will be done in the order listed above. |
| 48 | +
|
| 49 | +EOF |
| 50 | + |
| 51 | +# Get options and arguments |
| 52 | +while :; do |
| 53 | + case $1 in |
| 54 | + # datadir |
| 55 | + --datadir) |
| 56 | + if [ -n "$2" ] |
| 57 | + then |
| 58 | + DATADIR="-datadir=$2" |
| 59 | + shift |
| 60 | + else |
| 61 | + echo 'Error: "--datadir" requires an argument' |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + ;; |
| 65 | + # skips |
| 66 | + --skip) |
| 67 | + if [ -n "$2" ] |
| 68 | + then |
| 69 | + if [[ "$2" = *"v"* ]] |
| 70 | + then |
| 71 | + verBump=false |
| 72 | + fi |
| 73 | + if [[ "$2" = *"c"* ]] |
| 74 | + then |
| 75 | + chainparamsUpdate=false |
| 76 | + fi |
| 77 | + if [[ "$2" = *"s"* ]] |
| 78 | + then |
| 79 | + seedUpdate=false |
| 80 | + fi |
| 81 | + if [[ "$2" = *"b"* ]] |
| 82 | + then |
| 83 | + blockchainsizeBump=false |
| 84 | + fi |
| 85 | + if [[ "$2" = *"t"* ]] |
| 86 | + then |
| 87 | + translationsUpdate=false |
| 88 | + fi |
| 89 | + if [[ "$2" = *"m"* ]] |
| 90 | + then |
| 91 | + genManpages=false |
| 92 | + fi |
| 93 | + shift |
| 94 | + else |
| 95 | + echo 'Error: "--skip" requires an argument' |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | + ;; |
| 99 | + *) # Default case: If no more options then break out of the loop. |
| 100 | + break |
| 101 | + esac |
| 102 | + shift |
| 103 | +done |
| 104 | + |
| 105 | +if [[ $verBump = true ]] |
| 106 | +then |
| 107 | + # Bump Version numbers |
| 108 | + # Get version |
| 109 | + if [[ -n "$1" ]] |
| 110 | + then |
| 111 | + VERSION=$1 |
| 112 | + shift |
| 113 | + fi |
| 114 | + |
| 115 | + # Check that a version is specified |
| 116 | + if [[ $VERSION == "" ]] |
| 117 | + then |
| 118 | + echo "$scriptName: Missing version." |
| 119 | + echo "Try $scriptName --help for more information" |
| 120 | + exit 1 |
| 121 | + fi |
| 122 | + |
| 123 | + echo "Setting Version number" |
| 124 | + major=$(echo $VERSION | cut -d. -f1) |
| 125 | + minor=$(echo $VERSION | cut -d. -f2) |
| 126 | + rev=$(echo $VERSION | cut -d. -f3) |
| 127 | + |
| 128 | + # configure.ac |
| 129 | + sed -i "/define(_CLIENT_VERSION_MAJOR, /c\define(_CLIENT_VERSION_MAJOR, $major)" ./configure.ac |
| 130 | + sed -i "/define(_CLIENT_VERSION_MINOR, /c\define(_CLIENT_VERSION_MINOR, $minor)" ./configure.ac |
| 131 | + sed -i "/define(_CLIENT_VERSION_REVISION, /c\define(_CLIENT_VERSION_REVISION, $rev)" ./configure.ac |
| 132 | + sed -i "/define(_CLIENT_VERSION_IS_RELEASE, /c\define(_CLIENT_VERSION_IS_RELEASE, true)" ./configure.ac |
| 133 | + |
| 134 | + # src/clientversion.h |
| 135 | + sed -i "/#define CLIENT_VERSION_MAJOR /c\#define CLIENT_VERSION_MAJOR $major" ./src/clientversion.h |
| 136 | + sed -i "/#define CLIENT_VERSION_MINOR /c\#define CLIENT_VERSION_MINOR $minor" ./src/clientversion.h |
| 137 | + sed -i "/#define CLIENT_VERSION_REVISION /c\#define CLIENT_VERSION_REVISION $rev" ./src/clientversion.h |
| 138 | + sed -i "/#define CLIENT_VERSION_IS_RELEASE /c\#define CLIENT_VERSION_IS_RELEASE true" ./src/clientversion.h |
| 139 | + |
| 140 | + # docs |
| 141 | + sed -i "/PROJECT_NUMBER = /c\PROJECT_NUMBER = $VERSION" ./doc/Doxyfile |
| 142 | + sed -i "1s/.*/Bitcoin Core $VERSION/" ./doc/README.md |
| 143 | + sed -i "1s/.*/Bitcoin Core $VERSION/" ./doc/README_windows.txt |
| 144 | + |
| 145 | + # gitian descriptors |
| 146 | + sed -i "2s/.*/name: \"bitcoin-win-$major.$minor\"/" ./contrib/gitian-descriptors/gitian-win.yml |
| 147 | + sed -i "2s/.*/name: \"bitcoin-linux-$major.$minor\"/" ./contrib/gitian-descriptors/gitian-linux.yml |
| 148 | + sed -i "2s/.*/name: \"bitcoin-osx-$major.$minor\"/" ./contrib/gitian-descriptors/gitian-osx.yml |
| 149 | +fi |
| 150 | + |
| 151 | +if [[ $chainparamsUpdate = true ]] |
| 152 | +then |
| 153 | + # Update nMinimumChainWork and defaultAssumeValid |
| 154 | + echo "Updating nMinimumChainWork and defaultAssumeValid" |
| 155 | + blockchaininfo=`src/bitcoin-cli ${DATADIR} getblockchaininfo` |
| 156 | + chainwork=`echo "$blockchaininfo" | jq -r '.chainwork'` |
| 157 | + bestblockhash=`echo "$blockchaininfo" | jq -r '.bestblockhash'` |
| 158 | + sed -i "0,/ consensus.nMinimumChainWork = uint256S(.*/s// consensus.nMinimumChainWork = uint256S(\"0x$chainwork\");/" ./src/chainparams.cpp |
| 159 | + sed -i "0,/ consensus.defaultAssumeValid = uint256S(.*/s// consensus.defaultAssumeValid = uint256S(\"0x$bestblockhash\");/" ./src/chainparams.cpp |
| 160 | +fi |
| 161 | + |
| 162 | +if [[ $seedUpdate = true ]] |
| 163 | +then |
| 164 | + # Update Seeds |
| 165 | + echo "Updating hard coded seeds" |
| 166 | + pushd ./contrib/seeds |
| 167 | + curl -s http://bitcoin.sipa.be/seeds.txt > seeds_main.txt |
| 168 | + python makeseeds.py < seeds_main.txt > nodes_main.txt |
| 169 | + python generate-seeds.py . > ../../src/chainparamsseeds.h |
| 170 | +popd |
| 171 | +fi |
| 172 | + |
| 173 | +if [[ $blockchainsizeBump = true ]] |
| 174 | +then |
| 175 | + # Set blockchain size |
| 176 | + # Get block_chain_size |
| 177 | + if [[ -n "$1" ]] |
| 178 | + then |
| 179 | + BLOCK_CHAIN_SIZE=$1 |
| 180 | + shift |
| 181 | + fi |
| 182 | + |
| 183 | + # Check that a block_chain_size is specified |
| 184 | + if [[ $BLOCK_CHAIN_SIZE == "" ]] |
| 185 | + then |
| 186 | + echo "$scriptName: Missing block_chain_size." |
| 187 | + echo "Try $scriptName --help for more information" |
| 188 | + exit 1 |
| 189 | + fi |
| 190 | + echo "Setting BLOCK_CHAIN_SIZE" |
| 191 | + sed -i "/static const uint64_t BLOCK_CHAIN_SIZE = /c\static const uint64_t BLOCK_CHAIN_SIZE = $BLOCK_CHAIN_SIZE;" ./src/qt/intro.cpp |
| 192 | +fi |
| 193 | + |
| 194 | +if [[ $translationsUpdate = true ]] |
| 195 | +then |
| 196 | + # Update translations |
| 197 | + echo "Updating translations" |
| 198 | + python contrib/devtools/update-translations.py |
| 199 | + ls src/qt/locale/*ts|xargs -n1 basename|sed 's/\(bitcoin_\(.*\)\).ts/<file alias="\2">locale\/\1.qm<\/file>/' |
| 200 | + ls src/qt/locale/*ts|xargs -n1 basename|sed 's/\(bitcoin_\(.*\)\).ts/ qt\/locale\/\1.ts \\/' |
| 201 | +fi |
| 202 | + |
| 203 | +if [[ $genManpages = true ]] |
| 204 | +then |
| 205 | + # Generate manpages |
| 206 | + echo "Generating manpages" |
| 207 | + bash ./contrib/devtools/gen-manpages.sh |
| 208 | +fi |
| 209 | + |
| 210 | +# Complete |
| 211 | +echo "Release preparation complete. Please use git to commit these changes" |
0 commit comments