From 70084bd48d09295141d2240cff4a3f5005d7edff Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 29 Mar 2018 00:43:22 +1300 Subject: rrs/tools: ensure recipe parsing code deletes temporary dir load_recipes() was leaving files around in /tmp; on my Fedora system this eventually resulted in /tmp running out of space which we do not want. Signed-off-by: Paul Eggleton --- rrs/tools/common.py | 2 +- rrs/tools/rrs_distros.py | 4 +++- rrs/tools/rrs_upstream_history.py | 4 +++- rrs/tools/upgrade_history_internal.py | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rrs/tools/common.py b/rrs/tools/common.py index d4ceb7156b..df7ecf941c 100644 --- a/rrs/tools/common.py +++ b/rrs/tools/common.py @@ -121,7 +121,7 @@ def load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger, % (layerbranch, fn, str(e))) continue - return (tinfoil, d, recipes) + return (tinfoil, d, recipes, tempdir) # XXX: Copied from oe-core recipeutils to avoid import errors. def get_recipe_pv_without_srcpv(pv, uri_type): diff --git a/rrs/tools/rrs_distros.py b/rrs/tools/rrs_distros.py index 5fc83b8c57..d4400dec6b 100755 --- a/rrs/tools/rrs_distros.py +++ b/rrs/tools/rrs_distros.py @@ -12,6 +12,7 @@ import os.path import optparse import logging from datetime import datetime +import shutil sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) from common import common_setup, load_recipes, \ @@ -108,7 +109,7 @@ if __name__=="__main__": for item in maintplan.maintenanceplanlayerbranch_set.all(): layerbranch = item.layerbranch sys.path = origsyspath - (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, + (tinfoil, d, recipes, tempdir) = load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger) try: if not recipes: @@ -144,6 +145,7 @@ if __name__=="__main__": str(layerbranch), distro, alias)) finally: tinfoil.shutdown() + shutil.rmtree(tempdir) if options.dry_run: raise DryRunRollbackException except DryRunRollbackException: diff --git a/rrs/tools/rrs_upstream_history.py b/rrs/tools/rrs_upstream_history.py index a3bf7984d0..a20fae3fe5 100755 --- a/rrs/tools/rrs_upstream_history.py +++ b/rrs/tools/rrs_upstream_history.py @@ -12,6 +12,7 @@ import os.path import optparse import logging from datetime import datetime +import shutil sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) from common import common_setup, load_recipes, \ @@ -176,7 +177,7 @@ if __name__=="__main__": file = str(os.path.join(layerdir, recipe.full_path())) recipe_files.append(file) - (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, + (tinfoil, d, recipes, tempdir) = load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger, recipe_files=recipe_files) try: @@ -208,6 +209,7 @@ if __name__=="__main__": finally: tinfoil.shutdown() + shutil.rmtree(tempdir) if options.dry_run: raise DryRunRollbackException except DryRunRollbackException: diff --git a/rrs/tools/upgrade_history_internal.py b/rrs/tools/upgrade_history_internal.py index dcfd1af4ed..e8c3c91533 100644 --- a/rrs/tools/upgrade_history_internal.py +++ b/rrs/tools/upgrade_history_internal.py @@ -16,6 +16,7 @@ import optparse import logging import re from distutils.version import LooseVersion +import shutil sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) from common import common_setup, get_pv_type, load_recipes, \ @@ -182,7 +183,7 @@ def generate_history(options, layerbranch_id, commit, logger): utils.runcmd("git clean -dfx", bitbakepath, logger=logger) sys.path.insert(0, os.path.join(bitbakepath, 'lib')) - (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, + (tinfoil, d, recipes, tempdir) = load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger, recipe_files=fns, nocheckout=True) try: @@ -212,6 +213,7 @@ def generate_history(options, layerbranch_id, commit, logger): finally: if tinfoil and hasattr(tinfoil, 'shutdown') and (LooseVersion(bb.__version__) > LooseVersion("1.27")): tinfoil.shutdown() + shutil.rmtree(tempdir) if __name__=="__main__": -- cgit 1.2.3-korg