|
|
2b0a338 |
From b4897d1c279de97cb777b5aa2b08d7365b320dd5 Mon Sep 17 00:00:00 2001
|
|
|
2b0a338 |
From: James Slagle <jslagle@redhat.com>
|
|
|
2b0a338 |
Date: Thu, 4 Dec 2014 15:03:08 -0500
|
|
|
2b0a338 |
Subject: [PATCH] Allow injecting arbitrary yum repo configuration
|
|
|
2b0a338 |
|
|
|
2b0a338 |
Allows specifying the path to a yum repo configuration file to be used
|
|
|
2b0a338 |
during the image build process. The repo configuration file is removed
|
|
|
2b0a338 |
at the end of the build. This is useful in that it allows using any
|
|
|
2b0a338 |
arbitrary repo configuration during an image build.
|
|
|
2b0a338 |
|
|
|
2b0a338 |
Change-Id: I7d5c67d74a0bb4722ffc60aacfd9fa7e80fb59d5
|
|
|
2b0a338 |
---
|
|
|
2b0a338 |
elements/yum/README.md | 5 +++++
|
|
|
2b0a338 |
elements/yum/cleanup.d/99-remove-yum-repo-conf | 6 ++++++
|
|
|
2b0a338 |
elements/yum/extra-data.d/99-yum-repo-conf | 18 ++++++++++++++++++
|
|
|
2b0a338 |
3 files changed, 29 insertions(+)
|
|
|
2b0a338 |
create mode 100755 elements/yum/cleanup.d/99-remove-yum-repo-conf
|
|
|
2b0a338 |
create mode 100755 elements/yum/extra-data.d/99-yum-repo-conf
|
|
|
2b0a338 |
|
|
|
2b0a338 |
diff --git a/elements/yum/README.md b/elements/yum/README.md
|
|
|
2b0a338 |
index b38a94f..2425a7f 100644
|
|
|
2b0a338 |
--- a/elements/yum/README.md
|
|
|
2b0a338 |
+++ b/elements/yum/README.md
|
|
|
2b0a338 |
@@ -8,3 +8,8 @@ chroot so that they can be reused by subsequent image builds. The cache
|
|
|
2b0a338 |
increases image building speed when building multiple images, especially on
|
|
|
2b0a338 |
slow connections. This is more effective than using an HTTP proxy as a yum
|
|
|
2b0a338 |
cache since the same rpm from different mirrors is often requested.
|
|
|
2b0a338 |
+
|
|
|
2b0a338 |
+A custom yum repository configuration can also be applied by defining
|
|
|
2b0a338 |
+`DIB_YUM_REPO_CONF` to the path to a repo configuration file. The file will
|
|
|
2b0a338 |
+be copied to /etc/yum.repos.d/dib-yum-repo-conf.repo during the image build,
|
|
|
2b0a338 |
+and then removed at the end of the build.
|
|
|
2b0a338 |
diff --git a/elements/yum/cleanup.d/99-remove-yum-repo-conf b/elements/yum/cleanup.d/99-remove-yum-repo-conf
|
|
|
2b0a338 |
new file mode 100755
|
|
|
2b0a338 |
index 0000000..887aa4f
|
|
|
2b0a338 |
--- /dev/null
|
|
|
2b0a338 |
+++ b/elements/yum/cleanup.d/99-remove-yum-repo-conf
|
|
|
2b0a338 |
@@ -0,0 +1,6 @@
|
|
|
2b0a338 |
+#!/bin/bash
|
|
|
2b0a338 |
+
|
|
|
2b0a338 |
+set -eux
|
|
|
2b0a338 |
+set -o pipefail
|
|
|
2b0a338 |
+
|
|
|
2b0a338 |
+sudo rm -f $TMP_MOUNT_PATH/etc/yum.repos.d/dib-yum-repo-conf.repo
|
|
|
2b0a338 |
diff --git a/elements/yum/extra-data.d/99-yum-repo-conf b/elements/yum/extra-data.d/99-yum-repo-conf
|
|
|
2b0a338 |
new file mode 100755
|
|
|
2b0a338 |
index 0000000..f0dde92
|
|
|
2b0a338 |
--- /dev/null
|
|
|
2b0a338 |
+++ b/elements/yum/extra-data.d/99-yum-repo-conf
|
|
|
2b0a338 |
@@ -0,0 +1,18 @@
|
|
|
2b0a338 |
+#!/bin/bash
|
|
|
2b0a338 |
+# Add an additional yum repo configuration with $DIB_YUM_REPO_CONF
|
|
|
2b0a338 |
+
|
|
|
2b0a338 |
+set -eux
|
|
|
2b0a338 |
+set -o pipefail
|
|
|
2b0a338 |
+
|
|
|
2b0a338 |
+# exit directly if DIB_YUM_REPO_CONF is not defined properly
|
|
|
2b0a338 |
+if [ -z "${DIB_YUM_REPO_CONF:-}" ] ; then
|
|
|
2b0a338 |
+ echo "DIB_YUM_REPO_CONF is not set - no repo configuration will be copied in"
|
|
|
2b0a338 |
+ exit 0
|
|
|
2b0a338 |
+elif [ ! -f "$DIB_YUM_REPO_CONF" ] ; then
|
|
|
2b0a338 |
+ echo "DIB_YUM_REPO_CONF is not a valid yum repo configuration file."
|
|
|
2b0a338 |
+ echo "You should assign a proper yum repo configuration file in DIB_YUM_REPO_CONF"
|
|
|
2b0a338 |
+ exit 1
|
|
|
2b0a338 |
+fi
|
|
|
2b0a338 |
+
|
|
|
2b0a338 |
+# copy the yum repo configuration
|
|
|
2b0a338 |
+sudo cp -L -f $DIB_YUM_REPO_CONF $TMP_MOUNT_PATH/etc/yum.repos.d/dib-yum-repo-conf.repo
|