From 66fae447879604849beb2108242e33cc0c6fc867 Mon Sep 17 00:00:00 2001 From: "Stefan K. Berg" Date: Thu, 8 Oct 2015 18:06:00 +0200 Subject: 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 --- fuel/build/f_isoroot/f_repobuild/Makefile | 6 +--- .../f_isoroot/f_repobuild/select_ubuntu_repo.sh | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) create mode 100755 fuel/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh 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" + -- cgit 1.2.3-korg