download_mirrors.sh: cengn urls are not validated before substitution

Problem
=======
download_mirrors.sh by default substitutes urls with their cengn
equivalent. If the user is trying to introduce a new repo, a CENGN
mirror of the repo will not yet exist. The substituted url will be added
to the yum configuration despite being invalid. All subsequent
yumdownload attempts will fail with a 404 on the repodata of the
non-existent cengn repo.

Solution
========
   Only substitute yum repo urls with the cengn equivalent if
cengn actually has the repo.

Closes-bug: 1824877
Change-Id: Ifa262212d67e096cc29131e5738aec0365ed9893
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
Scott Little 2019-04-15 16:54:33 -04:00
parent 85e5ca84dd
commit 06171f9f81
1 changed files with 7 additions and 1 deletions

View File

@ -213,7 +213,13 @@ for REPO in $(find "$CENGN_REPOS_DIR" -type f -name '*repo'); do
#
for URL in $(grep '^baseurl=' "$REPO" | sed 's#^baseurl=##'); do
CENGN_URL="$(url_to_stx_mirror_url "$URL" "$DISTRO")"
sed "s#^baseurl=$URL\$#baseurl=$CENGN_URL#" -i "$REPO"
# Test CENGN url
wget -q --spider $CENGN_URL
if [ $? -eq 0 ]; then
# OK, make substitution
sed "s#^baseurl=$URL\$#baseurl=$CENGN_URL#" -i "$REPO"
fi
done
#