Browse code

Preserve result returned by apt-get and pip

Change I855ffe9c7a75e9943106af0f70cf715c34ae25c5 and
I368fec44858bd97fc6a314fb20eed2b10932cbb1 added timing
infrastructure which hides the return value of
the main commands. Restore the prior behaviour.

Change-Id: I4a536abefa7824ac6d42e7bbbf1079d9cc055984
Closes-Bug: #1518545

Federico Ressi authored on 2015/11/21 20:15:39
Showing 2 changed files
... ...
@@ -1045,7 +1045,7 @@ function apt_get_update {
1045 1045
 # Uses globals ``OFFLINE``, ``*_proxy``
1046 1046
 # apt_get operation package [package ...]
1047 1047
 function apt_get {
1048
-    local xtrace
1048
+    local xtrace result
1049 1049
     xtrace=$(set +o | grep xtrace)
1050 1050
     set +o xtrace
1051 1051
 
... ...
@@ -1062,9 +1062,11 @@ function apt_get {
1062 1062
         http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \
1063 1063
         no_proxy=${no_proxy:-} \
1064 1064
         apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
1065
+    result=$?
1065 1066
 
1066 1067
     # stop the clock
1067 1068
     time_stop "apt-get"
1069
+    return $result
1068 1070
 }
1069 1071
 
1070 1072
 function _parse_package_files {
... ...
@@ -81,7 +81,7 @@ function get_python_versions_for_package {
81 81
 # ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``,
82 82
 # pip_install package [package ...]
83 83
 function pip_install {
84
-    local xtrace
84
+    local xtrace result
85 85
     xtrace=$(set +o | grep xtrace)
86 86
     set +o xtrace
87 87
     local upgrade=""
... ...
@@ -155,10 +155,11 @@ function pip_install {
155 155
         PIP_FIND_LINKS=$PIP_FIND_LINKS \
156 156
         $cmd_pip $upgrade \
157 157
         $@
158
+    result=$?
158 159
 
159 160
     # Also install test requirements
160 161
     local test_req="${!#}/test-requirements.txt"
161
-    if [[ -e "$test_req" ]]; then
162
+    if [[ $result == 0 ]] && [[ -e "$test_req" ]]; then
162 163
         echo "Installing test-requirements for $test_req"
163 164
         $sudo_pip \
164 165
             http_proxy=${http_proxy:-} \
... ...
@@ -167,9 +168,11 @@ function pip_install {
167 167
             PIP_FIND_LINKS=$PIP_FIND_LINKS \
168 168
             $cmd_pip $upgrade \
169 169
             -r $test_req
170
+        result=$?
170 171
     fi
171 172
 
172 173
     time_stop "pip_install"
174
+    return $result
173 175
 }
174 176
 
175 177
 # get version of a package from global requirements file