Browse code

Merge "Update again and retry a failed package install"

Jenkins authored on 2014/06/11 00:15:57
Showing 1 changed files
... ...
@@ -881,29 +881,43 @@ function get_packages {
881 881
 
882 882
 # Distro-agnostic package installer
883 883
 # install_package package [package ...]
884
-function install_package {
885
-    local xtrace=$(set +o | grep xtrace)
886
-    set +o xtrace
887
-    if is_ubuntu; then
888
-        # if there are transient errors pulling the updates, that's fine. It may
889
-        # be secondary repositories that we don't really care about.
890
-        [[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update || /bin/true
891
-        NO_UPDATE_REPOS=True
884
+function update_package_repo {
885
+    if [[ "NO_UPDATE_REPOS" = "True" ]]; then
886
+        return 0
887
+    fi
892 888
 
889
+    if is_ubuntu; then
890
+        local xtrace=$(set +o | grep xtrace)
891
+        set +o xtrace
892
+        if [[ "$REPOS_UPDATED" != "True" || "$RETRY_UPDATE" = "True" ]]; then
893
+            # if there are transient errors pulling the updates, that's fine.
894
+            # It may be secondary repositories that we don't really care about.
895
+            apt_get update  || /bin/true
896
+            REPOS_UPDATED=True
897
+        fi
893 898
         $xtrace
899
+    fi
900
+}
901
+
902
+function real_install_package {
903
+    if is_ubuntu; then
894 904
         apt_get install "$@"
895 905
     elif is_fedora; then
896
-        $xtrace
897 906
         yum_install "$@"
898 907
     elif is_suse; then
899
-        $xtrace
900 908
         zypper_install "$@"
901 909
     else
902
-        $xtrace
903 910
         exit_distro_not_supported "installing packages"
904 911
     fi
905 912
 }
906 913
 
914
+# Distro-agnostic package installer
915
+# install_package package [package ...]
916
+function install_package {
917
+    update_package_repo
918
+    real_install_package $@ || RETRY_UPDATE=True update_package_repo && real_install_package $@
919
+}
920
+
907 921
 # Distro-agnostic function to tell if a package is installed
908 922
 # is_package_installed package [package ...]
909 923
 function is_package_installed {