64
64
GIT_COMMIT=$( git rev-parse --short=12 HEAD)
65
65
fi
66
66
67
+ # ###############
68
+ # Check 4: Make sure that build directories do no exist
69
+ # ###############
70
+
71
+ # Default to building for all supported HOSTs (overridable by environment)
72
+ export HOSTS=" ${HOSTS:- x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu
73
+ x86_64-w64-mingw32} "
74
+
75
+ DISTSRC_BASE=" ${DISTSRC_BASE:- ${PWD} } "
76
+
77
+ # Usage: distsrc_for_host HOST
78
+ #
79
+ # HOST: The current platform triple we're building for
80
+ #
81
+ distsrc_for_host () {
82
+ echo " ${DISTSRC_BASE} /distsrc-${GIT_COMMIT} -${1} "
83
+ }
84
+
85
+ # Accumulate a list of build directories that already exist...
86
+ hosts_distsrc_exists=" "
87
+ for host in $HOSTS ; do
88
+ if [ -e " $( distsrc_for_host " $host " ) " ]; then
89
+ hosts_distsrc_exists+=" ${host} "
90
+ fi
91
+ done
92
+
93
+ if [ -n " $hosts_distsrc_exists " ]; then
94
+ # ...so that we can print them out nicely in an error message
95
+ cat << EOF
96
+ ERR: Build directories for this commit already exist for the following platform
97
+ triples you're attempting to build, probably because of previous builds.
98
+ Please remove, or otherwise deal with them prior to starting another build.
99
+
100
+ Aborting...
101
+
102
+ EOF
103
+ for host in $hosts_distsrc_exists ; do
104
+ echo " ${host} '$( distsrc_for_host " $host " ) '"
105
+ done
106
+ exit 1
107
+ else
108
+ mkdir -p " $DISTSRC_BASE "
109
+ fi
110
+
67
111
# ########
68
112
# Setup #
69
113
# ########
@@ -116,9 +160,9 @@ and untracked files and directories will be wiped, allowing you to start anew.
116
160
EOF
117
161
}
118
162
119
- # Deterministically build Bitcoin Core for HOSTs (overridable by environment)
163
+ # Deterministically build Bitcoin Core
120
164
# shellcheck disable=SC2153
121
- for host in ${ HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu x86_64-w64-mingw32} ; do
165
+ for host in $HOSTS ; do
122
166
123
167
# Display proper warning when the user interrupts the build
124
168
trap ' int_trap ${host}' INT
@@ -187,12 +231,13 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv
187
231
# Please read the README.md in the same directory as this file for
188
232
# more information.
189
233
#
190
- # shellcheck disable=SC2086
234
+ # shellcheck disable=SC2086,SC2031
191
235
time-machine environment --manifest=" ${PWD} /contrib/guix/manifest.scm" \
192
236
--container \
193
237
--pure \
194
238
--no-cwd \
195
239
--share=" $PWD " =/bitcoin \
240
+ --share=" $DISTSRC_BASE " =/distsrc-base \
196
241
--share=" $OUTDIR " =/outdir \
197
242
--expose=" $( git rev-parse --git-common-dir) " \
198
243
${SOURCES_PATH: +--share=" $SOURCES_PATH " } \
@@ -204,6 +249,7 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv
204
249
SOURCE_DATE_EPOCH=" ${SOURCE_DATE_EPOCH:? unable to determine value} " \
205
250
${V: +V=1} \
206
251
${SOURCES_PATH: +SOURCES_PATH=" $SOURCES_PATH " } \
252
+ DISTSRC=" $( DISTSRC_BASE=/distsrc-base && distsrc_for_host " $HOST " ) " \
207
253
OUTDIR=/outdir \
208
254
bash -c " cd /bitcoin && bash contrib/guix/libexec/build.sh"
209
255
)
0 commit comments