diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2020-08-20 15:56:47 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-08-20 15:56:47 +0200 |
commit | 660c262da8ad677f5a0e42e2980e7b442b8369e5 (patch) | |
tree | c8aad515a6cb31cbdf932d0cabe44c64cf6cb648 | |
parent | 8d1309fbec39ede43aae68fbcea21bfc34f61645 (diff) | |
download | rpm-package-builder-660c262da8ad677f5a0e42e2980e7b442b8369e5.tar.gz |
add configure-mirror
-rw-r--r-- | Dockerfile | 4 | ||||
-rwxr-xr-x | configure-mirror | 49 |
2 files changed, 52 insertions, 1 deletions
@@ -9,7 +9,9 @@ LABEL maintainer="Gerd Hoffmann <kraxel@redhat.com>" \ USER root -RUN dnf update -y && \ +COPY configure-mirror /usr/local/bin +RUN /usr/local/bin/configure-mirror && \ + dnf update -y && \ dnf install -y \ 'dnf-command(builddep)' \ 'dnf-command(config-manager)' \ diff --git a/configure-mirror b/configure-mirror new file mode 100755 index 0000000..a66ec01 --- /dev/null +++ b/configure-mirror @@ -0,0 +1,49 @@ +#!/bin/sh + +function set_baseurl() { + local furl="$1" + local turl="$2" + local name="$3" + local file + + if test "$turl" = ""; then + echo "# no mirror: $furl (env \$$name)" + return + fi + + for file in /etc/yum.repos.d/*.repo; do + if test ! -f "${file}.dist"; then + cp "${file}" "${file}.dist" + fi + grep -q -e "baseurl=$furl" "${file}.dist" || continue + echo "# mirror: $furl -> $turl ($file)" + sed -e 's/^mirrorlist/#mirrorlist/' \ + -e 's/^metalink/#metalink/' \ + -e 's/^#baseurl/baseurl/' \ + -e "s|baseurl=${furl}|baseurl=${turl}|" \ + < "${file}.dist" > "$file" + done +} + +# +# use fixed (configurable) mirror. +# be cache proxy friendly. +# +set_baseurl http://mirror.centos.org/centos/ "${CENTOS_MIRROR}" CENTOS_MIRROR +set_baseurl http://download.fedoraproject.org/pub/epel/ "${EPEL_MIRROR}" EPEL_MIRROR +set_baseurl http://download.fedoraproject.org/pub/fedora/linux/ "${FEDORA_MIRROR}" FEDORA_MIRROR +set_baseurl http://download.example/pub/fedora/linux/ "${FEDORA_MIRROR}" FEDORA_MIRROR + +# +# no parallel downloads please. +# +if test -f /etc/dnf/dnf.conf; then + grep -q max_parallel_downloads /etc/dnf/dnf.conf ||\ + echo max_parallel_downloads=1 >> /etc/dnf/dnf.conf +fi +if test -f /etc/yum.conf; then + grep -q max_connections /etc/yum.conf ||\ + echo max_connections=1 >> /etc/yum.conf +fi + +exit 0 |