Update again and retry a failed package install

On ubuntu, if we run into an error installing the package, it can be
because of transient upstream errors with repo sync state. Although
retrying the update won't fix it all of the time, it's low cost enough
to be worth a try before we totally give up.

Related-bug: 1286818
Change-Id: I522ac0d0bd8f82dc98f386c89f66c2b743efa525
This commit is contained in:
Monty Taylor 2014-06-06 08:45:16 -04:00 committed by Jeremy Stanley
parent 7b63c5ec9e
commit 5cc6d2cd0c

View File

@ -881,29 +881,43 @@ function get_packages {
# Distro-agnostic package installer # Distro-agnostic package installer
# install_package package [package ...] # install_package package [package ...]
function install_package { function update_package_repo {
if [[ "NO_UPDATE_REPOS" = "True" ]]; then
return 0
fi
if is_ubuntu; then
local xtrace=$(set +o | grep xtrace) local xtrace=$(set +o | grep xtrace)
set +o xtrace set +o xtrace
if is_ubuntu; then if [[ "$REPOS_UPDATED" != "True" || "$RETRY_UPDATE" = "True" ]]; then
# if there are transient errors pulling the updates, that's fine. It may # if there are transient errors pulling the updates, that's fine.
# be secondary repositories that we don't really care about. # It may be secondary repositories that we don't really care about.
[[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update || /bin/true apt_get update || /bin/true
NO_UPDATE_REPOS=True REPOS_UPDATED=True
fi
$xtrace $xtrace
fi
}
function real_install_package {
if is_ubuntu; then
apt_get install "$@" apt_get install "$@"
elif is_fedora; then elif is_fedora; then
$xtrace
yum_install "$@" yum_install "$@"
elif is_suse; then elif is_suse; then
$xtrace
zypper_install "$@" zypper_install "$@"
else else
$xtrace
exit_distro_not_supported "installing packages" exit_distro_not_supported "installing packages"
fi fi
} }
# Distro-agnostic package installer
# install_package package [package ...]
function install_package {
update_package_repo
real_install_package $@ || RETRY_UPDATE=True update_package_repo && real_install_package $@
}
# Distro-agnostic function to tell if a package is installed # Distro-agnostic function to tell if a package is installed
# is_package_installed package [package ...] # is_package_installed package [package ...]
function is_package_installed { function is_package_installed {