@@ -103,6 +103,14 @@ ERR: Build directories for this commit already exist for the following platform
103
103
104
104
Aborting...
105
105
106
+ Hint: To blow everything away, you may want to use:
107
+
108
+ $ ./contrib/guix/guix-clean
109
+
110
+ Specifically, this will remove all files without an entry in the index,
111
+ excluding the SDK directory, the depends download cache, the depends built
112
+ packages cache, the garbage collector roots for Guix environments, and the
113
+ output directory.
106
114
EOF
107
115
for host in $hosts_distsrc_exists ; do
108
116
echo " ${host} '$( distsrc_for_host " $host " ) '"
119
127
for host in $HOSTS ; do
120
128
case " $host " in
121
129
* darwin* )
122
- OSX_SDK=" $( make -C " ${PWD} /depends" --no-print-directory HOST=" $host " print-OSX_SDK | sed ' s@^[^=]\+=[[:space:]]\+ @@g' ) "
130
+ OSX_SDK=" $( make -C " ${PWD} /depends" --no-print-directory HOST=" $host " print-OSX_SDK | sed ' s@^[^=]\+=@@g' ) "
123
131
if [ -e " $OSX_SDK " ]; then
124
132
echo " Found macOS SDK at '${OSX_SDK} ', using..."
125
133
else
@@ -178,12 +186,6 @@ host_to_commonname() {
178
186
esac
179
187
}
180
188
181
- # Download the depends sources now as we won't have internet access in the build
182
- # container
183
- for host in $HOSTS ; do
184
- make -C " ${PWD} /depends" -j" $JOBS " download-" $( host_to_commonname " $host " ) " ${V: +V=1} ${SOURCES_PATH: +SOURCES_PATH=" $SOURCES_PATH " }
185
- done
186
-
187
189
# Determine the reference time used for determinism (overridable by environment)
188
190
SOURCE_DATE_EPOCH=" ${SOURCE_DATE_EPOCH:- $(git log --format=% at -1)} "
189
191
@@ -201,10 +203,70 @@ time-machine() {
201
203
-- " $@ "
202
204
}
203
205
206
+
207
+ # Precious directories are those which should not be cleaned between successive
208
+ # guix builds
209
+ depends_precious_dir_names=' SOURCES_PATH BASE_CACHE SDK_PATH'
210
+ precious_dir_names=" ${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE"
211
+
212
+ # Usage: contains IFS-SEPARATED-LIST ITEM
213
+ contains () {
214
+ for i in ${1} ; do
215
+ if [ " $i " = " ${2} " ]; then
216
+ return 0 # Found!
217
+ fi
218
+ done
219
+ return 1
220
+ }
221
+
222
+ # If the user explicitly specified a precious directory, create it so we
223
+ # can map it into the container
224
+ for precious_dir_name in $precious_dir_names ; do
225
+ precious_dir_path=" ${! precious_dir_name} "
226
+ if [ -n " $precious_dir_path " ]; then
227
+ if [ ! -e " $precious_dir_path " ]; then
228
+ mkdir -p " $precious_dir_path "
229
+ elif [ -L " $precious_dir_path " ]; then
230
+ echo " ERR: ${precious_dir_name} cannot be a symbolic link"
231
+ exit 1
232
+ elif [ ! -d " $precious_dir_path " ]; then
233
+ echo " ERR: ${precious_dir_name} must be a directory"
234
+ exit 1
235
+ fi
236
+ fi
237
+ done
238
+
239
+ mkdir -p " $VAR_BASE "
240
+
241
+ # Record the _effective_ values of precious directories such that guix-clean can
242
+ # avoid clobbering them if appropriate.
243
+ #
244
+ # shellcheck disable=SC2046,SC2086
245
+ {
246
+ # Get depends precious dir definitions from depends
247
+ make -C " ${PWD} /depends" \
248
+ --no-print-directory \
249
+ -- $( printf " print-%s\n" $depends_precious_dir_names )
250
+
251
+ # Get remaining precious dir definitions from the environment
252
+ for precious_dir_name in $precious_dir_names ; do
253
+ precious_dir_path=" ${! precious_dir_name} "
254
+ if ! contains " $depends_precious_dir_names " " $precious_dir_name " ; then
255
+ echo " ${precious_dir_name} =${precious_dir_path} "
256
+ fi
257
+ done
258
+ } > " ${VAR_BASE} /precious_dirs"
259
+
204
260
# Make sure an output directory exists for our builds
205
261
OUTDIR_BASE=" ${OUTDIR_BASE:- ${VERSION_BASE} / output} "
206
262
mkdir -p " $OUTDIR_BASE "
207
263
264
+ # Download the depends sources now as we won't have internet access in the build
265
+ # container
266
+ for host in $HOSTS ; do
267
+ make -C " ${PWD} /depends" -j" $JOBS " download-" $( host_to_commonname " $host " ) " ${V: +V=1} ${SOURCES_PATH: +SOURCES_PATH=" $SOURCES_PATH " }
268
+ done
269
+
208
270
# Usage: outdir_for_host HOST
209
271
#
210
272
# HOST: The current platform triple we're building for
@@ -213,6 +275,14 @@ outdir_for_host() {
213
275
echo " ${OUTDIR_BASE} /${1} "
214
276
}
215
277
278
+ # Usage: profiledir_for_host HOST COMMAND
279
+ #
280
+ # HOST: The current platform triple we're building for
281
+ #
282
+ profiledir_for_host () {
283
+ echo " ${PROFILES_BASE} /${2} -${1} "
284
+ }
285
+
216
286
217
287
# ########
218
288
# BUILD #
@@ -223,24 +293,19 @@ outdir_for_host() {
223
293
int_trap () {
224
294
cat << EOF
225
295
** INT received while building ${1} , you may want to clean up the relevant
226
- output, deploy, and distsrc-* directories before rebuilding
296
+ work directories (e.g. distsrc-*) before rebuilding
227
297
228
298
Hint: To blow everything away, you may want to use:
229
299
230
- $ git clean -xdff --exclude='/depends/SDKs/*'
300
+ $ ./contrib/guix/guix-clean
231
301
232
302
Specifically, this will remove all files without an entry in the index,
233
- excluding the SDK directory. Practically speaking, this means that all ignored
234
- and untracked files and directories will be wiped, allowing you to start anew.
303
+ excluding the SDK directory, the depends download cache, the depends built
304
+ packages cache, the garbage collector roots for Guix environments, and the
305
+ output directory.
235
306
EOF
236
307
}
237
308
238
- # Create SOURCES_PATH, BASE_CACHE, and SDK_PATH if they are non-empty so that we
239
- # can map them into the container
240
- [ -z " $SOURCES_PATH " ] || mkdir -p " $SOURCES_PATH "
241
- [ -z " $BASE_CACHE " ] || mkdir -p " $BASE_CACHE "
242
- [ -z " $SDK_PATH " ] || mkdir -p " $SDK_PATH "
243
-
244
309
# Deterministically build Bitcoin Core
245
310
# shellcheck disable=SC2153
246
311
for host in $HOSTS ; do
347
412
--keep-failed \
348
413
--fallback \
349
414
--link-profile \
415
+ --root=" $( profiledir_for_host " ${HOST} " build) " \
350
416
${SUBSTITUTE_URLS: +--substitute-urls=" $SUBSTITUTE_URLS " } \
351
417
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
352
418
-- env HOST=" $host " \
0 commit comments