diff options
author | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-10-08 18:06:00 +0200 |
---|---|---|
committer | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-10-09 07:15:06 +0200 |
commit | 66fae447879604849beb2108242e33cc0c6fc867 (patch) | |
tree | e1bcd4ddb11831146569d54b7ab6a396bcf68617 | |
parent | 006cb3a13764cb95f49fa43eb7a8b55972b5c462 (diff) |
Updated logic for selecting Ubuntu repo for mirroring
A slight improvement to Michal Skalski's original concept just
to filter out repos where updates are in progress (which would
leave us hanging).
Change-Id: Id641b3aa82b991c23b5742d1f64ff79cfbbd708c
Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
-rw-r--r-- | fuel/build/f_isoroot/f_repobuild/Makefile | 6 | ||||
-rwxr-xr-x | fuel/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh | 33 |
2 files changed, 34 insertions, 5 deletions
diff --git a/fuel/build/f_isoroot/f_repobuild/Makefile b/fuel/build/f_isoroot/f_repobuild/Makefile index 6bfbd35c1..03e4caecb 100644 --- a/fuel/build/f_isoroot/f_repobuild/Makefile +++ b/fuel/build/f_isoroot/f_repobuild/Makefile @@ -13,11 +13,7 @@ TOP := $(shell pwd) DOCKNAME = fuelrepo DOCKVERSION = 1.0 -# try to choose close ubuntu mirror which support rsync protocol -# https://bugs.launchpad.net/fuel/+bug/1459252 -MIRROR_URLS := $(shell curl -s http://mirrors.ubuntu.com/mirrors.txt) -MIRROR_HOSTS := $(shell for url in ${MIRROR_URLS}; do echo $$url | cut -d'/' -f3; done) -RSYNC_HOST := $(shell for host in ${MIRROR_HOSTS}; do rsync -4 --contimeout 5 --no-motd --list-only "$${host}::ubuntu/." &> /dev/null && echo $$host && break; done) +RSYNC_HOST := $(shell ./select_ubuntu_repo.sh) .PHONY: all all: .nailgun diff --git a/fuel/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh b/fuel/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh new file mode 100755 index 000000000..cb05fe136 --- /dev/null +++ b/fuel/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh @@ -0,0 +1,33 @@ +#!/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. + +cnt=0 +while [ $cnt -lt 4 ] +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 + echo "$host" + exit 0 + fi + fi + done + cnt=$[cnt + 1] + sleep 15 +done +echo "archive.ubuntu.com" + |