@@ -178,12 +178,6 @@ host_to_commonname() {
178
178
esac
179
179
}
180
180
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
181
# Determine the reference time used for determinism (overridable by environment)
188
182
SOURCE_DATE_EPOCH=" ${SOURCE_DATE_EPOCH:- $(git log --format=% at -1)} "
189
183
@@ -201,10 +195,70 @@ time-machine() {
201
195
-- " $@ "
202
196
}
203
197
198
+
199
+ # Precious directories are those which should not be cleaned between successive
200
+ # guix builds
201
+ depends_precious_dir_names=' SOURCES_PATH BASE_CACHE SDK_PATH'
202
+ precious_dir_names=" ${depends_precious_dir_names} OUTDIR_BASE"
203
+
204
+ # Usage: contains IFS-SEPARATED-LIST ITEM
205
+ contains () {
206
+ for i in ${1} ; do
207
+ if [ " $i " = " ${2} " ]; then
208
+ return 0 # Found!
209
+ fi
210
+ done
211
+ return 1
212
+ }
213
+
214
+ # If the user explicitly specified a precious directory, create it so we
215
+ # can map it into the container
216
+ for precious_dir_name in $precious_dir_names ; do
217
+ precious_dir_path=" ${! precious_dir_name} "
218
+ if [ -n " $precious_dir_path " ]; then
219
+ if [ ! -e " $precious_dir_path " ]; then
220
+ mkdir -p " $precious_dir_path "
221
+ elif [ -L " $precious_dir_path " ]; then
222
+ echo " ERR: ${precious_dir_name} cannot be a symbolic link"
223
+ exit 1
224
+ elif [ ! -d " $precious_dir_path " ]; then
225
+ echo " ERR: ${precious_dir_name} must be a directory"
226
+ exit 1
227
+ fi
228
+ fi
229
+ done
230
+
231
+ mkdir -p " $VAR_BASE "
232
+
233
+ # Record the _effective_ values of precious directories such that guix-clean can
234
+ # avoid clobbering them if appropriate.
235
+ #
236
+ # shellcheck disable=SC2046,SC2086
237
+ {
238
+ # Get depends precious dir definitions from depends
239
+ make -C " ${PWD} /depends" \
240
+ --no-print-directory \
241
+ -- $( printf " print-%s\n" $depends_precious_dir_names )
242
+
243
+ # Get remaining precious dir definitions from the environment
244
+ for precious_dir_name in $precious_dir_names ; do
245
+ precious_dir_path=" ${! precious_dir_name} "
246
+ if ! contains " $depends_precious_dir_names " " $precious_dir_name " ; then
247
+ echo " ${precious_dir_name} =${precious_dir_path} "
248
+ fi
249
+ done
250
+ } > " ${VAR_BASE} /precious_dirs"
251
+
204
252
# Make sure an output directory exists for our builds
205
253
OUTDIR_BASE=" ${OUTDIR_BASE:- ${VERSION_BASE} / output} "
206
254
mkdir -p " $OUTDIR_BASE "
207
255
256
+ # Download the depends sources now as we won't have internet access in the build
257
+ # container
258
+ for host in $HOSTS ; do
259
+ make -C " ${PWD} /depends" -j" $JOBS " download-" $( host_to_commonname " $host " ) " ${V: +V=1} ${SOURCES_PATH: +SOURCES_PATH=" $SOURCES_PATH " }
260
+ done
261
+
208
262
# Usage: outdir_for_host HOST
209
263
#
210
264
# HOST: The current platform triple we're building for
@@ -235,12 +289,6 @@ and untracked files and directories will be wiped, allowing you to start anew.
235
289
EOF
236
290
}
237
291
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
292
# Deterministically build Bitcoin Core
245
293
# shellcheck disable=SC2153
246
294
for host in $HOSTS ; do
0 commit comments