From 06171f9f81a9df3fc296acd615a995da15b82330 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Mon, 15 Apr 2019 16:54:33 -0400 Subject: [PATCH] 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 --- centos-mirror-tools/make_stx_mirror_yum_conf.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/centos-mirror-tools/make_stx_mirror_yum_conf.sh b/centos-mirror-tools/make_stx_mirror_yum_conf.sh index 01f30005..fc4403b3 100755 --- a/centos-mirror-tools/make_stx_mirror_yum_conf.sh +++ b/centos-mirror-tools/make_stx_mirror_yum_conf.sh @@ -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 #