aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-08-19 10:52:08 +0200
committerGerd Hoffmann <kraxel@redhat.com>2020-08-19 10:52:08 +0200
commita960502adc61619d96c2ef44216d53b211565718 (patch)
tree03327902a9fe0bd058281f20343bc3ee270620eb
parent370418cb984a792eece9df6ecbd52cb567bebddd (diff)
downloadrpm-package-builder-a960502adc61619d96c2ef44216d53b211565718.tar.gz
add configure-mirror
-rw-r--r--Dockerfile5
-rwxr-xr-xconfigure-mirror41
2 files changed, 45 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile
index c125f0a..2b627e6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,11 +9,14 @@ LABEL maintainer="Gerd Hoffmann <kraxel@redhat.com>" \
USER root
-RUN yum update -y && \
+COPY configure-mirror /usr/local/bin
+RUN /usr/local/bin/configure-mirror && \
+ yum update -y && \
yum install -y \
yum-utils \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& \
+ /usr/local/bin/configure-mirror && \
yum install -y \
fedora-packager tito \
autoconf automake libtool \
diff --git a/configure-mirror b/configure-mirror
new file mode 100755
index 0000000..f895e78
--- /dev/null
+++ b/configure-mirror
@@ -0,0 +1,41 @@
+#!/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 -v "${file}" "${file}.dist"
+ fi
+ grep -q -e "baseurl=$furl" "${file}.dist" || continue
+ echo "# mirror: $furl -> $turl ($file)"
+ sed -e 's/^mirrorlist/#mirrorlist/' \
+ -e 's/^#baseurl/baseurl/' \
+ -e "s|baseurl=${furl}|baseurl=${turl}|" \
+ < "${file}.dist" > "$file"
+ diff -u "${file}.dist" "$file"
+ done
+}
+
+#
+# use fixed (configurable) mirror.
+# be cache proxy friendly.
+#
+set_baseurl http://mirror.centos.org/ "${CENTOS_MIRROR}" CENTOS_MIRROR
+set_baseurl http://download.fedoraproject.org/ "${FEDORA_MIRROR}" FEDORA_MIRROR
+
+#
+# no parallel downloads please.
+#
+grep -q max_parallel_downloads /etc/dnf/dnf.conf ||\
+echo max_parallel_downloads=1 >> /etc/dnf/dnf.conf
+
+exit 0