diff options
author | Paride Legovini <paride.legovini@canonical.com> | 2020-06-18 17:45:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 11:45:16 -0400 |
commit | d4639837ff623f199afd3e44aa836bf4b845456e (patch) | |
tree | 94a510048e09fce804ca313c37432f2c23518397 | |
parent | 3d13a9dd469f354d0ddc1e36be37d743b5a57c73 (diff) | |
download | vyos-cloud-init-d4639837ff623f199afd3e44aa836bf4b845456e.tar.gz vyos-cloud-init-d4639837ff623f199afd3e44aa836bf4b845456e.zip |
RPM build: disable the dynamic mirror URLs when using a proxy (#437)
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.
-rwxr-xr-x | tools/read-dependencies | 8 | ||||
-rwxr-xr-x | tools/run-container | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/tools/read-dependencies b/tools/read-dependencies index 666e24f5..fd1946a5 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,6 +55,7 @@ MAYBE_RELIABLE_YUM_INSTALL = [ done error ":: running yum install --cacheonly --assumeyes $*" yum install --cacheonly --assumeyes "$@" + configure_repos_for_proxy_use """, 'reliable-yum-install'] diff --git a/tools/run-container b/tools/run-container index 7212550e..15948e77 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 -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" fi |