FIXME: Temporary: Use archive.ubuntu.com only
[armband.git] / patches / opnfv-fuel / 0008-Revert-Improving-robustness-of-repo-mirror-selection.patch
1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Sun, 9 Oct 2016 22:02:14 +0200
3 Subject: [PATCH] Revert "Improving robustness of repo mirror selection"
4
5 We recently removed blacklists for a few mirrors, on account
6 of upstream Fuel@OPNFV fixing mirror selection in [1].
7
8 Although the mechanism will be polished a little, it works very
9 nicely; pointing us to [2], where we seem to trigger some flood
10 protection at sync, leading to dropped connections and failed builds.
11
12 Keep using the official Ubuntu Archive mirror [3] until we sort this out.
13
14 Fixes: ARMBAND-136
15
16 [1] https://gerrit.opnfv.org/gerrit/#/c/22195
17 [2] http://mirrors.se.eu.kernel.org/ubuntu/
18 [3] http://archive.ubuntu.com/ubuntu/
19
20 This reverts commit 4d4faf44dc1380b1ca731c49be9705635b840738.
21
22 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
23 ---
24  build/f_isoroot/f_repobuild/select_ubuntu_repo.sh | 120 +++++++---------------
25  1 file changed, 39 insertions(+), 81 deletions(-)
26
27 diff --git a/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh b/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh
28 index 10a8411..20b3485 100755
29 --- a/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh
30 +++ b/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh
31 @@ -1,82 +1,40 @@
32  #!/bin/bash
33 -cleanup() {
34 -    rm -f $TMPFILE
35 -}
36 -
37 -debugmsg() {
38 -    test -n "$DEBUG" && echo "$@" >&2
39 -}
40 -
41 -# Check mirror's integrity
42 -check_mirror () {
43 -    mirror=$1
44 -    status=0
45 -    for packdir in dists/trusty-updates/main/binary-amd64 \
46 -        dists/trusty-updates/restricted/binary-amd64 \
47 -        dists/trusty-updates/universe/binary-amd64 \
48 -        dists/trusty-updates/multiverse/binary-amd64 \
49 -        dists/trusty-security/main/binary-amd64 \
50 -        dists/trusty-security/restricted/binary-amd64 \
51 -        dists/trusty-security/universe/binary-amd64 \
52 -        dists/trusty-security/multiverse/binary-amd64 \
53 -        dists/trusty-proposed/main/binary-amd64 \
54 -        dists/trusty-proposed/restricted/binary-amd64 \
55 -        dists/trusty-proposed/universe/binary-amd64 \
56 -        dists/trusty-proposed/multiverse/binary-amd64 \
57 -        dists/trusty/main/binary-amd64 \
58 -        dists/trusty/restricted/binary-amd64 \
59 -        dists/trusty/universe/binary-amd64 \
60 -        dists/trusty/multiverse/binary-amd64 \
61 -        dists/trusty-backports/main/binary-amd64 \
62 -        dists/trusty-backports/restricted/binary-amd64 \
63 -        dists/trusty-backports/universe/binary-amd64 \
64 -        dists/trusty-backports/multiverse/binary-amd64
65 -    do
66 -        for packfile in Release Packages.gz
67 -        do
68 -            if [ $status -ne 1 ]; then
69 -                curl --output /dev/null --silent --head --fail \
70 -                    $mirror/$packdir/$packfile
71 -                if [ $? -ne 0 ]; then
72 -                    debugmsg "$mirror: Faulty (at least missing $packdir/$packfile)"
73 -                    status=1
74 -                fi
75 -            fi
76 -        done
77 -    done
78 -    return $status
79 -}
80 -
81 -if [ "$1" == "-d" ]; then
82 -    DEBUG=1
83 -fi
84 -
85 -# Hardcode for testing purposes
86 -DEBUG=1
87 -
88 -TMPFILE=$(mktemp /tmp/mirrorsXXXXX)A
89 -trap cleanup exit
90 -
91 -# Generated a list of mirrors considered as "up"
92 -curl -s  https://launchpad.net/ubuntu/+archivemirrors | \
93 -    grep -P -B8 "statusUP|statusSIX" | \
94 -    grep -o -P "(f|ht)tp.*\""  | \
95 -    sed 's/"$//' | sort | uniq > $TMPFILE
96 -
97 -# Iterate over "close" mirror, check that they are considered up
98 -# and sane.
99 -for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt)
100 -do
101 -    grep -q $url $TMPFILE || debugmsg "$url Faulty (detected by Ubuntu)"
102 -    if [ -z $BESTURL ]; then
103 -        if grep -q $url $TMPFILE && check_mirror $url; then
104 -            debugmsg "$url: OK (setting as primary URL)"
105 -            BESTURL=$url
106 -            test -z "$DEBUG" && break
107 -        fi
108 -    else
109 -        grep -q $url $TMPFILE && check_mirror $url && debugmsg "$url: OK"
110 -    fi
111 -done
112 -
113 -echo "$BESTURL"
114 +##############################################################################
115 +# Copyright (c) 2015,2016 Ericsson AB and others.
116 +# mskalski@mirantis.com
117 +# All rights reserved. This program and the accompanying materials
118 +# are made available under the terms of the Apache License, Version 2.0
119 +# which accompanies this distribution, and is available at
120 +# http://www.apache.org/licenses/LICENSE-2.0
121 +##############################################################################
122 +
123 +# Try to choose close ubuntu mirror from mirrors.txt, but "whitewash" this
124 +# against the full repo list to removed mirrors not up-to-date.
125 +
126 +# Some Ubuntu mirrors seem less reliable for this type of mirroring -
127 +# as they are discoved they can be added to the blacklist below in order
128 +# for them not to be considered.
129 +BLACKLIST="mirror.clibre.uqam.ca"
130 +
131 +#NOTE: For now the mirror selection is disabled due to issues not yet
132 +#      understood/resolved.
133 +#for url in $((curl -s  https://launchpad.net/ubuntu/+archivemirrors | \
134 +#              grep -P -B8 "statusUP|statusSIX" | \
135 +#              grep -o -P "(f|ht)tp.*\""  | \
136 +#              sed 's/"$//' | sort | uniq; \
137 +#              curl -s http://mirrors.ubuntu.com/mirrors.txt | sort | uniq) | \
138 +#              sort | uniq -d)
139 +#do
140 +#    host=$(echo $url | cut -d'/' -f3)
141 +#    echo ${BLACKLIST} | grep -q ${host} && continue
142 +#    if curl -s -o /dev/null --head --fail "$url"; then
143 +#      echo $url
144 +#      exit 0
145 +#    else
146 +#      continue
147 +#    fi
148 +#done
149 +
150 +# If no suitable local mirror can be found,
151 +# the default archive is returned instead.
152 +echo "http://archive.ubuntu.com/ubuntu/"