4
4
# Should be in Travis' cache
5
5
BREW_LOCAL_BOTTLE_METADATA=" $HOME /local_bottle_metadata"
6
6
7
+ # FIXME: temporary fix to enable the build, should be replaced with the proper path to the cache dir
8
+ mkdir -p $BREW_LOCAL_BOTTLE_METADATA
9
+
7
10
# Starting reference point for elapsed build time; seconds since the epoch.
8
11
# TRAVIS_TIMER_START_TIME is set at the start of a log fold, in nanoseconds since the epoch
9
12
BREW_TIME_START=$(( $TRAVIS_TIMER_START_TIME / 10 ** 9 ))
@@ -48,33 +51,33 @@ function brew_add_local_bottles {
48
51
# so that `brew` commands can find them.
49
52
# If the package was updated, removes the corresponding files
50
53
# and the bottle's entry in the formula, if any.
51
-
52
- # Bottle entry in formula:
54
+
55
+ # Bottle entry in formula:
53
56
# bottle do
54
57
# <...>
55
58
# sha256 "<sha256>" => :<os_codename>
56
59
# <...>
57
- # end
58
-
60
+ # end
61
+
59
62
echo " Cached bottles:"
60
63
ls " $( brew --cache) /downloads" || true # may not exist initially since it's "$(brew --cache)" that is in Travis cache
61
64
echo " Saved .json's and links:"
62
65
ls " $BREW_LOCAL_BOTTLE_METADATA "
63
-
66
+
64
67
for JSON in " $BREW_LOCAL_BOTTLE_METADATA " /* .json; do
65
68
[ -e " $JSON " ] || break # OSX 10.11 bash has no nullglob
66
69
local PACKAGE JSON_VERSION JSON_REBUILD OS_CODENAME BOTTLE_HASH
67
-
70
+
68
71
_brew_parse_bottle_json " $JSON " PACKAGE JSON_VERSION JSON_REBUILD OS_CODENAME BOTTLE_HASH
69
72
70
73
echo " Adding local bottle: $PACKAGE ${JSON_VERSION} _${JSON_REBUILD} "
71
-
74
+
72
75
local FORMULA_VERSION FORMULA_REBUILD FORMULA_BOTTLE_HASH
73
-
76
+
74
77
_brew_parse_package_info " $PACKAGE " " $OS_CODENAME " FORMULA_VERSION FORMULA_REBUILD FORMULA_BOTTLE_HASH
75
78
76
79
local FORMULA_HAS_BOTTLE; [ -n " $FORMULA_BOTTLE_HASH " ] && FORMULA_HAS_BOTTLE=1 || true
77
-
80
+
78
81
79
82
local BOTTLE_LINK BOTTLE=" " ; BOTTLE_LINK=" ${JSON} .bottle.lnk" ;
80
83
local BOTTLE_EXISTS= BOTTLE_MISMATCH= VERSION_MISMATCH=
@@ -88,10 +91,10 @@ function brew_add_local_bottles {
88
91
if [ -f " $BOTTLE_LINK " ]; then
89
92
BOTTLE=$( cat " $BOTTLE_LINK " ) ;
90
93
BOTTLE=$( cd " $( dirname " $BOTTLE " ) " ; pwd) /$( basename " $BOTTLE " )
91
-
94
+
92
95
if [ -e " $BOTTLE " ]; then
93
96
BOTTLE_EXISTS=1;
94
-
97
+
95
98
# The hash in `brew --cache $PACKAGE` entry is generated from download URL,
96
99
# which itself is generated from base URL and version
97
100
# (see Homebrew/Library/Homebrew/download_strategy.rb:cached_location).
@@ -110,7 +113,7 @@ function brew_add_local_bottles {
110
113
else
111
114
echo " Link file is missing or of invalid type!" >&2
112
115
fi
113
-
116
+
114
117
# Delete cached bottle and all metadata if invalid
115
118
if [[ -z " $BOTTLE_EXISTS " || -n " $VERSION_MISMATCH " || -n " $BOTTLE_MISMATCH " ]]; then
116
119
echo " Deleting the cached bottle and all metadata"
@@ -133,11 +136,11 @@ function brew_add_local_bottles {
133
136
git commit -m " Removed obsolete local bottle ${JSON_VERSION} _${JSON_REBUILD} :${OS_CODENAME} " " $FORMULA "
134
137
)
135
138
fi
136
-
139
+
137
140
if [ -n " $BOTTLE " -a -n " $BOTTLE_EXISTS " ]; then rm " $BOTTLE " ; fi
138
141
rm -f " $BOTTLE_LINK "
139
142
rm " $JSON "
140
-
143
+
141
144
# (Re)add metadata to the formula otherwise
142
145
else
143
146
if [ " $FORMULA_BOTTLE_HASH " == " $BOTTLE_HASH " ]; then
@@ -156,7 +159,7 @@ function brew_cache_cleanup {
156
159
157
160
# Lefovers from some failure probably
158
161
rm -f " $BREW_LOCAL_BOTTLE_METADATA " /* .tar.gz
159
-
162
+
160
163
# `brew cleanup` may delete locally-built bottles that weren't needed this time
161
164
# so we're saving and restoring them
162
165
local BOTTLE_LINK BOTTLE
@@ -187,16 +190,16 @@ function brew_go_bootstrap_mode {
187
190
local EXIT_CODE=${1:- 1}
188
191
189
192
echo " Going into cache bootstrap mode"
190
-
193
+
191
194
BREW_BOOTSTRAP_MODE=1
192
-
195
+
193
196
# Can't just `exit` because that would terminate the build without saving the cache
194
197
# Have to replace further actions with no-ops
195
-
198
+
196
199
local MESSAGE=" " ; if [ " $EXIT_CODE " -ne 0 ]; then
197
200
MESSAGE=' Building dependencies took too long. Restart the build in Travis UI to continue from cache.' ;
198
201
fi
199
-
202
+
200
203
eval '
201
204
function ' " $cmd " ' { return 0; }
202
205
function repair_wheelhouse { return 0; }
@@ -205,11 +208,11 @@ function brew_go_bootstrap_mode {
205
208
echo \
206
209
' echo -e "\n' " $MESSAGE " ' \n"'
207
210
fi) " \
208
- '
211
+ '
209
212
# Travis runs user scripts via `eval` i.e. in the same shell process.
210
213
# So have to unset errexit in order to get to cache save stage
211
214
set +e; return ' " $EXIT_CODE " '
212
- }'
215
+ }'
213
216
}
214
217
215
218
@@ -228,15 +231,15 @@ function _brew_install_and_cache_within_time_limit {
228
231
if grep -qxFf <( cat <<< " $_BREW_ALREADY_INSTALLED" ) <<< " $PACKAGE" ; then
229
232
MARKED_INSTALLED=1
230
233
fi
231
-
234
+
232
235
if [ -n " $MARKED_INSTALLED " ] || (brew list --versions " $PACKAGE " > /dev/null && ! (brew outdated | grep -qxF " $PACKAGE " )); then
233
236
echo " Already installed and the latest version: $PACKAGE "
234
237
if [ -z " $MARKED_INSTALLED " ]; then _brew_mark_installed " $PACKAGE " ; fi
235
238
return 0
236
239
fi
237
-
240
+
238
241
local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
239
-
242
+
240
243
_brew_is_bottle_available " $PACKAGE " KEG_ONLY || BUILD_FROM_SOURCE=1
241
244
[ -n " $BUILD_FROM_SOURCE " ] && INCLUDE_BUILD=" --include-build" || true
242
245
@@ -254,7 +257,7 @@ function _brew_install_and_cache_within_time_limit {
254
257
_brew_install_and_cache " $PACKAGE " " $( [[ -z " $BUILD_FROM_SOURCE " ]] && echo 1 || echo 0) " " $KEG_ONLY " || return 2
255
258
_brew_check_elapsed_build_time " $TIME_START " " $TIME_LIMIT " || return $?
256
259
}
257
-
260
+
258
261
259
262
function _brew_parse_bottle_json {
260
263
# Parse JSON file resulting from `brew bottle --json`
@@ -271,9 +274,9 @@ function _brew_parse_bottle_json {
271
274
print tag_name
272
275
print tag_dict["sha256"]
273
276
' " $JSON " )
274
-
277
+
275
278
unset JSON
276
-
279
+
277
280
{ local i v; for i in {1..5}; do
278
281
read -r v
279
282
eval " ${1:? } =\" $v \" "
@@ -284,7 +287,7 @@ function _brew_parse_bottle_json {
284
287
function _brew_parse_package_info {
285
288
# Get and parse `brew info --json` about a package
286
289
# and save data into specified variables
287
-
290
+
288
291
local PACKAGE OS_CODENAME
289
292
PACKAGE=" ${1:? } " ; shift
290
293
OS_CODENAME=" ${1:? } " ; shift
@@ -300,9 +303,9 @@ function _brew_parse_package_info {
300
303
print bottle_data["files"].get(sys.argv[2],{"sha256":"!?"})["sha256"] #prevent losing trailing blank line to command substitution
301
304
' \
302
305
" $PACKAGE " " $OS_CODENAME " ) ; JSON_DATA=" ${JSON_DATA% \!\? } " #! ? can't occur in a hash
303
-
306
+
304
307
unset PACKAGE OS_CODENAME
305
-
308
+
306
309
{ local i v; for i in {1..3}; do
307
310
read -r v
308
311
eval " ${1:? } =\" $v \" "
@@ -346,13 +349,13 @@ function _brew_install_and_cache {
346
349
# Install bottle or make and cache bottle.
347
350
# assumes that deps were already installed
348
351
# and not already the latest version
349
-
352
+
350
353
local PACKAGE USE_BOTTLE KEG_ONLY
351
354
PACKAGE="${1:? } "
352
355
USE_BOTTLE="${2:? } "
353
356
KEG_ONLY="${3:? } "
354
357
local VERB
355
-
358
+
356
359
if brew list --versions "$PACKAGE "; then
357
360
# Install alongside the old version to avoid to have to update "runtime dependents"
358
361
# https://discourse.brew.sh/t/can-i-install-a-new-version-without-having-to-upgrade-runtime-dependents/4443
@@ -363,7 +366,7 @@ function _brew_install_and_cache {
363
366
else
364
367
VERB=install
365
368
fi
366
-
369
+
367
370
if [[ "$USE_BOTTLE " -gt 0 ]]; then
368
371
echo "Installing bottle for: $PACKAGE "
369
372
brew $VERB "$PACKAGE "
@@ -380,12 +383,12 @@ function _brew_install_and_cache {
380
383
#proper procedure as per https://discourse.brew.sh/t/how-are-bottle-and-postinstall-related-is-it-safe-to-run-bottle-after-postinstall/3410 /4
381
384
brew uninstall --ignore-dependencies "$PACKAGE "
382
385
brew $VERB "$BOTTLE "
383
-
386
+
384
387
local JSON; JSON=$(sed -E 's/bottle(.[[:digit:]]+)?\.tar\.gz$/bottle.json/' <<<"$BOTTLE ")
385
-
388
+
386
389
#`brew bottle --merge` doesn't return nonzero on nonexisting json file
387
390
test -f "$JSON " -a -f "$BOTTLE "
388
-
391
+
389
392
brew bottle --merge --write "$JSON "
390
393
local CACHED_BOTTLE; CACHED_BOTTLE="$(brew --cache "$PACKAGE ")"
391
394
mv "$BOTTLE " "$CACHED_BOTTLE ";
@@ -394,9 +397,9 @@ function _brew_install_and_cache {
394
397
#Symlinks aren't cached by Travis. Will just save paths in files then.
395
398
local BOTTLE_LINK; BOTTLE_LINK="${CACHED_JSON} .bottle.lnk"
396
399
echo "$CACHED_BOTTLE " >"$BOTTLE_LINK "
397
-
400
+
398
401
fi
399
-
402
+
400
403
_brew_mark_installed "$PACKAGE "
401
404
}
402
405
@@ -411,11 +414,11 @@ function _brew_check_elapsed_build_time {
411
414
local TIME_START TIME_LIMIT ELAPSED_TIME
412
415
TIME_START="${1:? } "
413
416
TIME_LIMIT="${2:? } "
414
-
417
+
415
418
ELAPSED_TIME=$(($(date +%s) - $TIME_START ))
416
419
echo " Elapsed time: " $(( $ELAPSED_TIME / 60 )) " m (${ELAPSED_TIME} s)"
417
-
418
- if [[ " $ELAPSED_TIME " -gt $TIME_LIMIT ]]; then
420
+
421
+ if [[ " $ELAPSED_TIME " -gt $TIME_LIMIT ]]; then
419
422
brew_go_bootstrap_mode
420
423
return 1
421
424
fi
@@ -426,19 +429,19 @@ function _brew_check_slow_building_ahead {
426
429
427
430
#If the package's projected build completion is higher than hard limit,
428
431
# skip it and arrange for further build to be skipped and return 1
429
-
432
+
430
433
local PACKAGE TIME_START TIME_HARD_LIMIT
431
434
PACKAGE=" ${1:? } "
432
435
TIME_START=" ${2:? } "
433
436
TIME_HARD_LIMIT=" ${3:? } "
434
-
435
- local PROJECTED_BUILD_TIME
437
+
438
+ local PROJECTED_BUILD_TIME
436
439
PROJECTED_BUILD_TIME=$( echo " $BREW_SLOW_BUILIDING_PACKAGES " | awk ' $1=="' " $PACKAGE " ' "{print $2}' )
437
440
[ -z " $PROJECTED_BUILD_TIME " ] && return 0 || true
438
-
441
+
439
442
local PROJECTED_BUILD_END_ELAPSED_TIME
440
443
PROJECTED_BUILD_END_ELAPSED_TIME=$(( $(date +% s) - TIME_START + PROJECTED_BUILD_TIME * 60 ))
441
-
444
+
442
445
if [[ " $PROJECTED_BUILD_END_ELAPSED_TIME " -ge " $TIME_HARD_LIMIT " ]]; then
443
446
echo -e " \n Projected build end elapsed time for $PACKAGE : $(( PROJECTED_BUILD_END_ELAPSED_TIME/ 60 )) m ($PROJECTED_BUILD_END_ELAPSED_TIMEs )"
444
447
brew_go_bootstrap_mode
0 commit comments