From 131fb6e4dbdb7a9c373dc2f00a892c053fc13576 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 5 May 2014 15:33:26 -0400 Subject: [PATCH] Fedora: Add support for configuring Yum mirrors Updates the fedora element so that DIB_DISTRIBUTION_MIRROR can be used to configure a custom Yum mirror on Fedora. This implementation replaces the baseurl in each of the default Fedora Yum .repo files so that a custom mirror URL/path can be supplied. The URL should point to the directory where the updates and release directories exist. Example: http://download.fedoraproject.org/pub/fedora/linux As part of this change we also remove any existing metalink settings in the .repo files to cover the case where an end user runs their own createrepo command to create the mirror... which means your metadata won't match that of the normal Fedora mirrors and your baseurl won't get used. Change-Id: I1a49a2941b1cc489e91a72b87430393cd32e865d --- elements/fedora/README.md | 8 ++++++++ elements/fedora/pre-install.d/01-set-fedora-mirror | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100755 elements/fedora/pre-install.d/01-set-fedora-mirror diff --git a/elements/fedora/README.md b/elements/fedora/README.md index c31621ff..97003091 100644 --- a/elements/fedora/README.md +++ b/elements/fedora/README.md @@ -1,3 +1,11 @@ Use Fedora cloud images as the baseline for built disk images. +If you wish to use a Fedora Yum mirror you can set DIB\_DISTRIBUTION\_MIRROR +before running bin/disk-image-create. Example: + + DIB\_DISTRIBUTION\_MIRROR=http://download.fedoraproject.org/pub/fedora/linux + +This URL should point to the directory containing the releases/updates/ +development/and extras directories. + For further details see the redhat-common README. diff --git a/elements/fedora/pre-install.d/01-set-fedora-mirror b/elements/fedora/pre-install.d/01-set-fedora-mirror new file mode 100755 index 00000000..a80236a9 --- /dev/null +++ b/elements/fedora/pre-install.d/01-set-fedora-mirror @@ -0,0 +1,11 @@ +#!/bin/bash + +set -eu + +DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} + +[ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0 + +for FILE in /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo /etc/yum.repos.d/fedora-updates-testing.repo; do + sudo sed -e "s|^#baseurl=http://download.fedoraproject.org/pub/fedora/linux|baseurl=$DIB_DISTRIBUTION_MIRROR|;/^metalink/d" -i $FILE +done