X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=build%2Ff_isoroot%2Ff_repobuild%2Fselect_ubuntu_repo.sh;h=c3bb5cf363f07646c671b8145fb1d2fe61e9cc4b;hb=e12aec84ef1767d4ba9469dfb12d65d928bf0ed4;hp=992359afda454182ba7c6a6db7e3e6e97bf25c97;hpb=0cc989a2376c6f9c8171a556c7fa7869f4635dc6;p=fuel.git diff --git a/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh b/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh index 992359afd..c3bb5cf36 100755 --- a/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh +++ b/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh @@ -1,55 +1,38 @@ #!/bin/bash - -RSYNC="rsync -4 --contimeout 5 --no-motd --list-only" - -# try to choose close ubuntu mirror which support rsync protocol -# https://bugs.launchpad.net/fuel/+bug/1459252 - -# A minor modificiation of Michal Skalski's original Makefile version -# to only consider repos where no repo updates are in progress (as -# that may have us hanging quite a while otherwise). If no suitable -# local mirror can be found after four attempts, the default archive -# is returned instead. - -return_url=0 - -while [ "$1" != "" ]; do - case $1 in - -u | --url ) shift - return_url=1 - ;; - # Shift all the parameters down by one - esac - shift -done - - -cnt=0 -while [ $cnt -lt 4 ] +############################################################################## +# Copyright (c) 2015,2016 Ericsson AB and others. +# mskalski@mirantis.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Try to choose close ubuntu mirror from mirrors.txt, but "whitewash" this +# against the full repo list to removed mirrors not up-to-date. + +# Some Ubuntu mirrors seem less reliable for this type of mirroring - +# as they are discoved they can be added to the blacklist below in order +# for them not to be considered. +BLACKLIST="mirror.clibre.uqam.ca" + +for url in $((curl -s https://launchpad.net/ubuntu/+archivemirrors | \ + grep -P -B8 "statusUP|statusSIX" | \ + grep -o -P "(f|ht)tp.*\"" | \ + sed 's/"$//' | sort | uniq; \ + curl -s http://mirrors.ubuntu.com/mirrors.txt | sort | uniq) | \ + sort | uniq -d) do - for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt) - do - host=$(echo $url | cut -d'/' -f3) - if $RSYNC "${host}::ubuntu/." &> /dev/null - then - if ! $RSYNC "${host}::ubuntu/Archive-Update-in-Progress*" &> /dev/null - then - if [ "$return_url" = "1" ]; then - echo "$url" - exit 0 - else - echo "$host" - exit 0 - fi - fi - fi - done - cnt=$[cnt + 1] - sleep 15 + host=$(echo $url | cut -d'/' -f3) + echo ${BLACKLIST} | grep -q ${host} && continue + if curl -s -o /dev/null --head --fail "$url"; then + echo $url + exit 0 + else + continue + fi done -if [ "$return_url" = "1" ]; then - echo "http://archive.ubuntu.com/ubuntu/" -else - echo "archive.ubuntu.com" -fi +# If no suitable local mirror can be found, +# the default archive is returned instead. +echo "http://archive.ubuntu.com/ubuntu/"