From 829d626f0a9c7f520fede2a18c1c76e31e459fa8 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 24 Sep 2015 13:32:14 +1000 Subject: [PATCH] Move yum-based install into function Move yum-based install into a function, to make way for a second related function where use dnf later Change-Id: Iad09f3753ecdfa0c10cb8a0970a3c8e5a2dccab1 --- elements/yum-minimal/root.d/08-yum-chroot | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/elements/yum-minimal/root.d/08-yum-chroot b/elements/yum-minimal/root.d/08-yum-chroot index 63ee72e5..f20d8ffc 100755 --- a/elements/yum-minimal/root.d/08-yum-chroot +++ b/elements/yum-minimal/root.d/08-yum-chroot @@ -33,13 +33,7 @@ YUMCHROOT_TARBALL=$DIB_IMAGE_CACHE/yumchroot-${DISTRO_NAME}-${DIB_RELEASE}-${ARC # TODO Maybe deal with DIB_DISTRIBUTION_MIRROR http_proxy=${http_proxy:-} -set -x -if [ -n "$DIB_OFFLINE" -o -n "${DIB_YUMCHROOT_USE_CACHE:-}" ] && [ -f $YUMCHROOT_TARBALL ] ; then - echo $YUMCHROOT_TARBALL found in cache. Using. - sudo tar -C $TARGET_ROOT --numeric-owner -xzf $YUMCHROOT_TARBALL -else - sudo mkdir -p $TARGET_ROOT/var/lib/rpm - sudo rpm --root $TARGET_ROOT --initdb +function _do_yum { WORKING=$(mktemp --tmpdir=${TMP_DIR:-/tmp} -d) EACTION="rm -r $WORKING" @@ -103,6 +97,16 @@ else done sudo rm $TARGET_ROOT/etc/resolv.conf sudo umount $TMP_MOUNT_PATH/tmp/yum +} + +if [ -n "$DIB_OFFLINE" -o -n "${DIB_YUMCHROOT_USE_CACHE:-}" ] && [ -f $YUMCHROOT_TARBALL ] ; then + echo $YUMCHROOT_TARBALL found in cache. Using. + sudo tar -C $TARGET_ROOT --numeric-owner -xzf $YUMCHROOT_TARBALL +else + sudo mkdir -p $TARGET_ROOT/var/lib/rpm + sudo rpm --root $TARGET_ROOT --initdb + + _do_yum echo Caching result in $YUMCHROOT_TARBALL sudo tar --numeric-owner -C $TARGET_ROOT -zcf $YUMCHROOT_TARBALL --exclude='./tmp/*' .