From f8a0715c560eefb270b7f4bdc2c222e1590aa537 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 10 Dec 2013 17:11:52 +0100 Subject: [PATCH] Add zypper element This provides some customizations for zypper based distributions (e.g. openSUSE and SLES). It is heavily inspired by the yum element and sets up zypper to cache downloaded package outside of the chroot so that they can be reused to speed up subsequent builds. Change-Id: I775c921ee19cf7d1180fb68c1b7857ea6245a77d --- elements/opensuse/element-deps | 1 + elements/zypper/README.md | 10 ++++++++++ .../zypper/post-install.d/99-zypper-no-keep-packages | 6 ++++++ elements/zypper/pre-install.d/01-zypper-keep-packages | 6 ++++++ elements/zypper/root.d/50-zypper-cache | 10 ++++++++++ 5 files changed, 33 insertions(+) create mode 100644 elements/zypper/README.md create mode 100755 elements/zypper/post-install.d/99-zypper-no-keep-packages create mode 100755 elements/zypper/pre-install.d/01-zypper-keep-packages create mode 100755 elements/zypper/root.d/50-zypper-cache diff --git a/elements/opensuse/element-deps b/elements/opensuse/element-deps index 5c6d5779..4c2b56c3 100644 --- a/elements/opensuse/element-deps +++ b/elements/opensuse/element-deps @@ -1,2 +1,3 @@ cache-url dib-run-parts +zypper diff --git a/elements/zypper/README.md b/elements/zypper/README.md new file mode 100644 index 00000000..aec7e616 --- /dev/null +++ b/elements/zypper/README.md @@ -0,0 +1,10 @@ +This element provides some customizations for zypper based distributions like +SLES and openSUSE. It works in a very similar way as the yum element does for +yum based distributions. + +Zypper is reconfigured so that it keeps downloaded packages cached 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 for +caching packages since the download servers will often redirect clients to +different mirrors. diff --git a/elements/zypper/post-install.d/99-zypper-no-keep-packages b/elements/zypper/post-install.d/99-zypper-no-keep-packages new file mode 100755 index 00000000..a68a05e1 --- /dev/null +++ b/elements/zypper/post-install.d/99-zypper-no-keep-packages @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +# Disable caching packages for all repositories +sudo zypper modifyrepo --all --no-keep-packages diff --git a/elements/zypper/pre-install.d/01-zypper-keep-packages b/elements/zypper/pre-install.d/01-zypper-keep-packages new file mode 100755 index 00000000..43c01882 --- /dev/null +++ b/elements/zypper/pre-install.d/01-zypper-keep-packages @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +# Enable caching packages for all repositories +sudo zypper modifyrepo --all --keep-packages diff --git a/elements/zypper/root.d/50-zypper-cache b/elements/zypper/root.d/50-zypper-cache new file mode 100755 index 00000000..9504bf3a --- /dev/null +++ b/elements/zypper/root.d/50-zypper-cache @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +[ -n "$TARGET_ROOT" ] + +ZYPPER_CACHE_DIR=~/.cache/image-create/zypper +mkdir -p $ZYPPER_CACHE_DIR + +sudo mount --bind $ZYPPER_CACHE_DIR $TMP_MOUNT_PATH/var/cache/zypp