From c9a6aef9f4360759b2f52611be0b3c56ae8ce40a Mon Sep 17 00:00:00 2001 From: James Slagle Date: Wed, 31 Jul 2013 09:37:57 -0400 Subject: [PATCH] Add yum element. The yum element provides for specific customizations for yum based distros. The included customization is a yum cache mounted outside of the chroot so that yum downloaded packages are reused on subsequent image builds. Change-Id: I6833c9fdbc83cb09debec6a789082e105c917800 --- elements/fedora/element-deps | 1 + elements/yum/README.md | 10 ++++++++++ elements/yum/pre-install.d/01-yum-keepcache | 8 ++++++++ elements/yum/root.d/50-yum-cache | 11 +++++++++++ 4 files changed, 30 insertions(+) create mode 100644 elements/yum/README.md create mode 100755 elements/yum/pre-install.d/01-yum-keepcache create mode 100755 elements/yum/root.d/50-yum-cache diff --git a/elements/fedora/element-deps b/elements/fedora/element-deps index 386e17306..d04ce43de 100644 --- a/elements/fedora/element-deps +++ b/elements/fedora/element-deps @@ -2,3 +2,4 @@ dib-run-parts dracut-network cache-url dkms +yum diff --git a/elements/yum/README.md b/elements/yum/README.md new file mode 100644 index 000000000..b38a94fef --- /dev/null +++ b/elements/yum/README.md @@ -0,0 +1,10 @@ +Provide yum specific image building glue. + +RHEL/Fedora/CentOS and other yum based distributions need specific yum +customizations. + +Customizations include caching of downloaded yum packages outside of the build +chroot so that they can be reused by subsequent image builds. The cache +increases image building speed when building multiple images, especially on +slow connections. This is more effective than using an HTTP proxy as a yum +cache since the same rpm from different mirrors is often requested. diff --git a/elements/yum/pre-install.d/01-yum-keepcache b/elements/yum/pre-install.d/01-yum-keepcache new file mode 100755 index 000000000..2ada3e0b1 --- /dev/null +++ b/elements/yum/pre-install.d/01-yum-keepcache @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +[ -n "TARGET_ROOT" ] + +sudo sed -i 's/keepcache=0/keepcache=1/' $TARGET_ROOT/etc/yum.conf +sudo sed -i 's/cachedir=\/var\/cache\/yum/cachedir=\/tmp\/yum/' $TARGET_ROOT/etc/yum.conf diff --git a/elements/yum/root.d/50-yum-cache b/elements/yum/root.d/50-yum-cache new file mode 100755 index 000000000..f7dd92472 --- /dev/null +++ b/elements/yum/root.d/50-yum-cache @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +[ -n "TARGET_ROOT" ] + +YUM_CACHE_DIR=~/.cache/image-create/yum +mkdir -p $YUM_CACHE_DIR + +sudo mkdir -p $TMP_MOUNT_PATH/tmp/yum +sudo mount --bind $YUM_CACHE_DIR $TMP_MOUNT_PATH/tmp/yum