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