diff --git a/devstack-vm-gate.sh b/devstack-vm-gate.sh index 45a3ea60..b8e0819d 100755 --- a/devstack-vm-gate.sh +++ b/devstack-vm-gate.sh @@ -78,10 +78,13 @@ function setup_localrc { else # Install PyYaml for test-matrix.py if uses_debs; then - sudo apt-get update - sudo apt-get --assume-yes install python-yaml + if ! dpkg -s python-yaml > /dev/null; then + apt_get_install python-yaml + fi elif is_fedora; then - sudo yum install -y PyYAML + if ! rpm --quiet -q "PyYAML"; then + sudo yum install -y PyYAML + fi fi MY_ENABLED_SERVICES=`cd $BASE/new/devstack-gate && ./test-matrix.py -b $localrc_branch -f $DEVSTACK_GATE_FEATURE_MATRIX` local original_enabled_services=$MY_ENABLED_SERVICES diff --git a/functions.sh b/functions.sh index d63e34e3..f8f0643b 100644 --- a/functions.sh +++ b/functions.sh @@ -43,6 +43,21 @@ function function_exists { type $1 2>/dev/null | grep -q 'is a function' } +function apt_get_install { + # fetch the updates in a loop to ensure that we're update to + # date. Only do this once per run. Give up to 5 minutes to succeed + # here. + if [[ -z "$APT_UPDATED" ]]; then + if ! timeout 300 sh -c "while ! sudo apt-get update; do sleep 30; done"; then + echo "Failed to update apt repos, we're dead now" + exit 1 + fi + APT_UPDATED=1 + fi + + sudo apt-get --assume-yes install $@ +} + function call_hook_if_defined { local hook_name=$1 local filename=${2-$WORKSPACE/devstack-gate-$hook_name.txt}