Skip to content

Commit ae379cf

Browse files
committed
[scripts] build earlier releases
1 parent 98264e2 commit ae379cf

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ qrc_*.cpp
108108
.DS_Store
109109
build
110110

111+
# Previous releases
112+
releases
113+
111114
#lcov
112115
*.gcno
113116
*.gcda

contrib/devtools/previous_release.sh

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018-2019 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# Build previous releases.
8+
9+
export LC_ALL=C
10+
11+
CONFIG_FLAGS=""
12+
FUNCTIONAL_TESTS=0
13+
DELETE_EXISTING=0
14+
USE_DEPENDS=0
15+
DOWNLOAD_BINARY=0
16+
CONFIG_FLAGS=""
17+
TARGET="releases"
18+
19+
while getopts ":hfrdbt:" opt; do
20+
case $opt in
21+
h)
22+
echo "Usage: .previous_release.sh [options] tag1 tag2"
23+
echo " options:"
24+
echo " -h Print this message"
25+
echo " -f Configure for functional tests"
26+
echo " -r Remove existing directory"
27+
echo " -d Use depends"
28+
echo " -b Download release binary"
29+
echo " -t Target directory (default: releases)"
30+
exit 0
31+
;;
32+
f)
33+
FUNCTIONAL_TESTS=1
34+
CONFIG_FLAGS="$CONFIG_FLAGS --without-gui --disable-tests --disable-bench"
35+
;;
36+
r)
37+
DELETE_EXISTING=1
38+
;;
39+
d)
40+
USE_DEPENDS=1
41+
;;
42+
b)
43+
DOWNLOAD_BINARY=1
44+
;;
45+
t)
46+
TARGET=$OPTARG
47+
;;
48+
\?)
49+
echo "Invalid option: -$OPTARG" >&2
50+
exit 1
51+
;;
52+
esac
53+
done
54+
55+
shift $((OPTIND-1))
56+
57+
if [ -z "$1" ]; then
58+
echo "Specify release tag(s), e.g.: .previous_release v0.15.1"
59+
exit 1
60+
fi
61+
62+
if [ ! -d "$TARGET" ]; then
63+
mkdir -p $TARGET
64+
fi
65+
66+
if [ "$DOWNLOAD_BINARY" -eq "1" ]; then
67+
HOST="${HOST:-$(./depends/config.guess)}"
68+
case "$HOST" in
69+
x86_64-*-linux*)
70+
PLATFORM=x86_64-linux-gnu
71+
;;
72+
x86_64-apple-darwin*)
73+
PLATFORM=osx64
74+
;;
75+
*)
76+
echo "Not sure which binary to download for $HOST."
77+
exit 1
78+
;;
79+
esac
80+
fi
81+
82+
echo "Releases directory: $TARGET"
83+
pushd "$TARGET" || exit 1
84+
{
85+
for tag in "$@"
86+
do
87+
if [ "$DELETE_EXISTING" -eq "1" ]; then
88+
if [ -d "$tag" ]; then
89+
rm -r "$tag"
90+
fi
91+
fi
92+
93+
if [ "$DOWNLOAD_BINARY" -eq "0" ]; then
94+
95+
if [ ! -d "$tag" ]; then
96+
if [ -z $(git tag -l "$tag") ]; then
97+
echo "Tag $tag not found"
98+
exit 1
99+
fi
100+
101+
git clone https://github.com/bitcoin/bitcoin "$tag"
102+
pushd "$tag" || exit 1
103+
{
104+
git checkout "$tag"
105+
if [ "$USE_DEPENDS" -eq "1" ]; then
106+
pushd depends || exit 1
107+
{
108+
if [ "$FUNCTIONAL_TESTS" -eq "1" ]; then
109+
make NO_QT=1
110+
else
111+
make
112+
fi
113+
HOST="${HOST:-$(./config.guess)}"
114+
}
115+
popd || exit 1
116+
CONFIG_FLAGS="--prefix=$PWD/depends/$HOST $CONFIG_FLAGS"
117+
fi
118+
./autogen.sh
119+
./configure $CONFIG_FLAGS
120+
make
121+
# Move binaries, so they're in the same place as in the release download:
122+
mkdir bin
123+
mv src/bitcoind src/bitcoin-cli src/bitcoin-tx bin
124+
if [ "$FUNCTIONAL_TESTS" -eq "0" ]; then
125+
mv src/qt/bitcoin-qt bin
126+
fi
127+
}
128+
popd || exit 1
129+
fi
130+
else
131+
if [ -d "$tag" ]; then
132+
echo "Using cached $tag"
133+
else
134+
mkdir "$tag"
135+
URL="https://bitcoin.org/bin/bitcoin-core-${tag:1}/bitcoin-${tag:1}-$PLATFORM.tar.gz"
136+
echo "Fetching: $URL"
137+
curl -O $URL
138+
tar -zxf "bitcoin-${tag:1}-$PLATFORM.tar.gz" -C "$tag" --strip-components=1 "bitcoin-${tag:1}"
139+
rm "bitcoin-${tag:1}-$PLATFORM.tar.gz"
140+
fi
141+
fi
142+
done
143+
}
144+
popd || exit 1

0 commit comments

Comments
 (0)