From e2782954088dadb9bfe9cd3760129f06c602e7dd Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Aug 2021 16:29:10 +0800 Subject: [PATCH] script/run-make.sh: retry if dpkg was interrupted there is chance that apt-get is interrupted in the middle when a new PR cancels the running jenkins job, the next job running apt-get or dpkg would run into issues like: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. Build step 'Execute shell' marked build as failure Signed-off-by: Kefu Chai --- src/script/run-make.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/script/run-make.sh b/src/script/run-make.sh index 3437d715aa9a..2c07b645fea0 100755 --- a/src/script/run-make.sh +++ b/src/script/run-make.sh @@ -54,6 +54,30 @@ function detect_ceph_dev_pkgs() { echo "$cmake_opts" } +function do_install() { + local install_cmd + local pkgs + local ret + install_cmd=$1 + shift + pkgs=$@ + shift + ret=0 + $DRY_RUN sudo $install_cmd $pkgs || ret=$? + if test $ret -eq 0 ; then + return + fi + # try harder if apt-get, and it was interrutped + if [[ $install_cmd == *"apt-get"* ]]; then + if test $ret -eq 100 ; then + # dpkg was interrupted + $DRY_RUN sudo dpkg --configure -a + $DRY_RUN sudo $install_cmd $pkgs + else + return $ret + fi + fi +} function prepare() { local install_cmd local which_pkg="which" @@ -81,7 +105,7 @@ function prepare() { exit 1 fi if [ -n "$install_cmd" ]; then - $DRY_RUN sudo $install_cmd ccache $which_pkg + do_install "$install_cmd" ccache $which_pkg else echo "WARNING: Don't know how to install packages" >&2 echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2 -- 2.47.3