]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
script/run-make.sh: retry if dpkg was interrupted 42743/head
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 08:29:10 +0000 (16:29 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 10:05:46 +0000 (18:05 +0800)
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 <kchai@redhat.com>
src/script/run-make.sh

index 3437d715aa9a62889b8559083fef309b658865dd..2c07b645fea0b593bbeccb71c602ae03f088e91d 100755 (executable)
@@ -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