mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
kokoro: fix handling of apt-get errors
When a command is called as if expression, its error code can be get only in this if block. For example, the next script prints 0: if ( false ); then true fi echo $? PiperOrigin-RevId: 305638629
This commit is contained in:
+15
-7
@@ -89,12 +89,20 @@ function install_runsc() {
|
||||
# be correct, otherwise this may result in a loop that spins until time out.
|
||||
function apt_install() {
|
||||
while true; do
|
||||
if (sudo apt-get update && sudo apt-get install -y "$@"); then
|
||||
break
|
||||
fi
|
||||
result=$?
|
||||
if [[ $result -ne 100 ]]; then
|
||||
return $result
|
||||
fi
|
||||
sudo apt-get update &&
|
||||
sudo apt-get install -y "$@" &&
|
||||
true
|
||||
result="${?}"
|
||||
case $result in
|
||||
0)
|
||||
break
|
||||
;;
|
||||
100)
|
||||
# 100 is the error code that apt-get returns.
|
||||
;;
|
||||
*)
|
||||
exit $result
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user