From 7e60540c0d8d02c976f7890831e103584501c27c Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 10 Nov 2016 14:22:17 +1100 Subject: [PATCH] Cleanup yumdownloader repos yumdownloader has to have all the repo XML files, etc, which adds up to a not totally insignificant 150MiB or so. Currently we're leaking this directory for every build, which adds up on regualar builders like nodepool. Isolate the call with a separate TMPDIR so we can clean it up after the initial download. Change-Id: Ic65e8ca837cc76b7a1bb9f83027b4a5bdd270f75 --- elements/yum-minimal/root.d/08-yum-chroot | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/elements/yum-minimal/root.d/08-yum-chroot b/elements/yum-minimal/root.d/08-yum-chroot index 50c0a6b2..10fe1d25 100755 --- a/elements/yum-minimal/root.d/08-yum-chroot +++ b/elements/yum-minimal/root.d/08-yum-chroot @@ -56,6 +56,7 @@ _RPM="rpm --dbpath=/var/lib/rpm" # has yum/yumdownloader function _install_repos { local packages + local rc # pre-install the base system packages via rpm. We previously # just left it up to yum to drag these in when we "yum install @@ -79,11 +80,21 @@ function _install_repos { packages+="${DISTRO_NAME}-repos " fi - yumdownloader \ + # yumdownloader puts repo xml files and such into a directory + # ${TMPDIR}/yum-$USER-random. Since we don't need this once the + # initial download happens, redirect TMPDIR for this call so we + # can clean it up nicely + local temp_tmp + temp_tmp=$(mktemp -d) + TMPDIR=${temp_tmp} yumdownloader \ --releasever=$DIB_RELEASE \ --setopt=reposdir=$TMP_HOOKS_PATH/yum.repos.d \ --destdir=$WORKING \ - ${packages} + ${packages} && rc=$? || rc=$? + rm -rf ${temp_tmp} + if [[ ${rc} != 0 ]]; then + die "Failed to download initial packages: ${packages}" + fi # --nodeps works around these wanting /bin/sh in some fedora # releases, see rhbz#1265873