From 1f4b40268bbc682e0390e8d96fcdf4e88b618613 Mon Sep 17 00:00:00 2001 From: Paride Legovini Date: Mon, 15 Jun 2020 16:14:08 +0200 Subject: [PATCH 1/3] RPM build: disable the dynamic mirror URLs when using a proxy When using an http proxy make sure to disable all the dynamic mirror URLs. In particular: - Uncomment the baseurl in /etc/yum.repos.d/*.repo. - Comment out the mirrorlist and metalink URLs in *.repo. - Replace the dynamic download.fedoraproject.org host with dl.fedoraproject.org, which is static. - Run the above as part of the MAYBE_RELIABLE_YUM_INSTALL command, as installing packages may add new repos (e.g. EPEL). - Stop disabling fastestmirror, not needed when doing the above. --- tools/read-dependencies | 5 +++++ tools/run-container | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/read-dependencies b/tools/read-dependencies index 666e24f541e..62cfd581450 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -48,6 +48,11 @@ MAYBE_RELIABLE_YUM_INSTALL = [ done error ":: running yum install --cacheonly --assumeyes $*" yum install --cacheonly --assumeyes "$@" + if grep -q "^proxy=" /etc/yum.conf; then + error ":: http proxy in use => forcing the use of fixed URLs in /etc/yum.repos.d/*.repo" + sed -Ei '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo + sed -i 's/download\.fedoraproject\.org/dl.fedoraproject.org/g' /etc/yum.repos.d/*.repo + fi """, 'reliable-yum-install'] diff --git a/tools/run-container b/tools/run-container index 7212550eb61..d1873e69f16 100755 --- a/tools/run-container +++ b/tools/run-container @@ -351,9 +351,8 @@ wait_for_boot() { if [ "$OS_NAME" = "centos" ]; then debug 1 "configuring proxy ${http_proxy}" inside "$name" sh -c "echo proxy=$http_proxy >> /etc/yum.conf" - inside "$name" sed -i s/enabled=1/enabled=0/ \ - /etc/yum/pluginconf.d/fastestmirror.conf - inside "$name" sh -c "sed -i '/^#baseurl=/s/#// ; s/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo" + inside "$name" sh -c "sed -Ei '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo" + inside "$name" sh -c "sed -i 's/download\.fedoraproject\.org/dl.fedoraproject.org/g' /etc/yum.repos.d/*.repo" else debug 1 "do not know how to configure proxy on $OS_NAME" fi From b8b696ea7605bfb72d1d6b964a6d40dfa0264f64 Mon Sep 17 00:00:00 2001 From: Paride Legovini Date: Mon, 15 Jun 2020 19:01:59 +0200 Subject: [PATCH 2/3] Replace 'sed -Ei' with 'sed -i --regexp-extended' Favour long options in scripts. --- tools/read-dependencies | 2 +- tools/run-container | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/read-dependencies b/tools/read-dependencies index 62cfd581450..7aa826af36e 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -50,7 +50,7 @@ MAYBE_RELIABLE_YUM_INSTALL = [ yum install --cacheonly --assumeyes "$@" if grep -q "^proxy=" /etc/yum.conf; then error ":: http proxy in use => forcing the use of fixed URLs in /etc/yum.repos.d/*.repo" - sed -Ei '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo + sed -i --regexp-extended '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo sed -i 's/download\.fedoraproject\.org/dl.fedoraproject.org/g' /etc/yum.repos.d/*.repo fi """, diff --git a/tools/run-container b/tools/run-container index d1873e69f16..15948e7723c 100755 --- a/tools/run-container +++ b/tools/run-container @@ -351,7 +351,7 @@ wait_for_boot() { if [ "$OS_NAME" = "centos" ]; then debug 1 "configuring proxy ${http_proxy}" inside "$name" sh -c "echo proxy=$http_proxy >> /etc/yum.conf" - inside "$name" sh -c "sed -Ei '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo" + inside "$name" sh -c "sed -i --regexp-extended '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo" inside "$name" sh -c "sed -i 's/download\.fedoraproject\.org/dl.fedoraproject.org/g' /etc/yum.repos.d/*.repo" else debug 1 "do not know how to configure proxy on $OS_NAME" From f57b3b1943304e10165702965c0e7b393747374f Mon Sep 17 00:00:00 2001 From: Paride Legovini Date: Tue, 16 Jun 2020 11:52:57 +0200 Subject: [PATCH 3/3] yum install: apply the proxy config before and after installing packages --- tools/read-dependencies | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/read-dependencies b/tools/read-dependencies index 7aa826af36e..fd1946a571d 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -34,6 +34,13 @@ MAYBE_RELIABLE_YUM_INSTALL = [ 'sh', '-c', """ error() { echo "$@" 1>&2; } + configure_repos_for_proxy_use() { + grep -q "^proxy=" /etc/yum.conf || return 0 + error ":: http proxy in use => forcing the use of fixed URLs in /etc/yum.repos.d/*.repo" + sed -i --regexp-extended '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo + sed -i 's/download\.fedoraproject\.org/dl.fedoraproject.org/g' /etc/yum.repos.d/*.repo + } + configure_repos_for_proxy_use n=0; max=10; bcmd="yum install --downloadonly --assumeyes --setopt=keepcache=1" while n=$(($n+1)); do @@ -48,11 +55,7 @@ MAYBE_RELIABLE_YUM_INSTALL = [ done error ":: running yum install --cacheonly --assumeyes $*" yum install --cacheonly --assumeyes "$@" - if grep -q "^proxy=" /etc/yum.conf; then - error ":: http proxy in use => forcing the use of fixed URLs in /etc/yum.repos.d/*.repo" - sed -i --regexp-extended '/^#baseurl=/s/#// ; /^(mirrorlist|metalink)=/s/^/#/' /etc/yum.repos.d/*.repo - sed -i 's/download\.fedoraproject\.org/dl.fedoraproject.org/g' /etc/yum.repos.d/*.repo - fi + configure_repos_for_proxy_use """, 'reliable-yum-install']