File tree Expand file tree Collapse file tree 1 file changed +24
-12
lines changed
Expand file tree Collapse file tree 1 file changed +24
-12
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- set -e
3+ set -E
4+ exec 3< & 2 # preserve original stderr at fd 3
45
56abs_dirname () {
67 local cwd=" $( pwd) "
@@ -16,12 +17,15 @@ abs_dirname() {
1617 cd " $cwd "
1718}
1819
19- log () {
20- if [ -z " $VERBOSE " ]; then
21- cat >> " $LOG_PATH "
22- else
23- tee -a " $LOG_PATH "
24- fi
20+ build_failed () {
21+ { echo
22+ echo " BUILD FAILED"
23+ echo
24+ echo " Inspect or clean up the working tree at ${TEMP_PATH} "
25+ echo " Results logged to ${LOG_PATH} "
26+ echo
27+ } >&3
28+ exit 1
2529}
2630
2731install_package () {
@@ -47,14 +51,14 @@ download_package() {
4751
4852 echo " Downloading ${package_url} ..." >&2
4953 { curl " $package_url " > " ${package_name} .tar.gz"
50- } 2>&1 | log
54+ } >&4 2>&1
5155}
5256
5357extract_package () {
5458 local package_name=" $1 "
5559
5660 { tar xzvf " ${package_name} .tar.gz"
57- } 2>&1 | log
61+ } >&4 2>&1
5862}
5963
6064build_package () {
@@ -80,22 +84,22 @@ build_package_standard() {
8084 { ./configure --prefix=" $PREFIX_PATH "
8185 make -j 2
8286 make install
83- } 2>&1 | log
87+ } >&4 2>&1
8488}
8589
8690build_package_ruby () {
8791 local package_name=" $1 "
8892
8993 { " $RUBY_BIN " setup.rb
90- } 2>&1 | log
94+ } >&4 2>&1
9195}
9296
9397build_package_rbx () {
9498 local package_name=" $1 "
9599
96100 { ./configure --prefix=" $PREFIX_PATH "
97101 rake install
98- } 2>&1 | log
102+ } >&4 2>&1
99103}
100104
101105build_package_copy () {
@@ -181,12 +185,20 @@ TEMP_PATH="/tmp/ruby-build.${SEED}"
181185RUBY_BIN=" ${PREFIX_PATH} /bin/ruby"
182186CWD=" $( pwd) "
183187
188+ exec 4<> " $LOG_PATH " # open the log file at fd 4
189+ if [ -n " $VERBOSE " ]; then
190+ tail -f " $LOG_PATH " &
191+ trap " kill 0" SIGINT SIGTERM EXIT
192+ fi
193+
184194export LDFLAGS=" -L'${PREFIX_PATH} /lib' ${LDFLAGS} "
185195export CPPFLAGS=" -I'${PREFIX_PATH} /include' ${CPPFLAGS} "
186196
187197unset RUBYOPT
188198unset RUBYLIB
189199
200+ trap build_failed ERR
190201mkdir -p " $TEMP_PATH "
191202source " $DEFINITION_PATH "
192203rm -fr " $TEMP_PATH "
204+ trap - ERR
You can’t perform that action at this time.
0 commit comments