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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-03-29 00:43:22 +13:00
parent 404e86a5a3
commit 70084bd48d
4 changed files with 10 additions and 4 deletions

View File

@ -121,7 +121,7 @@ def load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger,
% (layerbranch, fn, str(e))) % (layerbranch, fn, str(e)))
continue continue
return (tinfoil, d, recipes) return (tinfoil, d, recipes, tempdir)
# XXX: Copied from oe-core recipeutils to avoid import errors. # XXX: Copied from oe-core recipeutils to avoid import errors.
def get_recipe_pv_without_srcpv(pv, uri_type): def get_recipe_pv_without_srcpv(pv, uri_type):

View File

@ -12,6 +12,7 @@ import os.path
import optparse import optparse
import logging import logging
from datetime import datetime from datetime import datetime
import shutil
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__))))
from common import common_setup, load_recipes, \ from common import common_setup, load_recipes, \
@ -108,7 +109,7 @@ if __name__=="__main__":
for item in maintplan.maintenanceplanlayerbranch_set.all(): for item in maintplan.maintenanceplanlayerbranch_set.all():
layerbranch = item.layerbranch layerbranch = item.layerbranch
sys.path = origsyspath sys.path = origsyspath
(tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, (tinfoil, d, recipes, tempdir) = load_recipes(layerbranch, bitbakepath,
fetchdir, settings, logger) fetchdir, settings, logger)
try: try:
if not recipes: if not recipes:
@ -144,6 +145,7 @@ if __name__=="__main__":
str(layerbranch), distro, alias)) str(layerbranch), distro, alias))
finally: finally:
tinfoil.shutdown() tinfoil.shutdown()
shutil.rmtree(tempdir)
if options.dry_run: if options.dry_run:
raise DryRunRollbackException raise DryRunRollbackException
except DryRunRollbackException: except DryRunRollbackException:

View File

@ -12,6 +12,7 @@ import os.path
import optparse import optparse
import logging import logging
from datetime import datetime from datetime import datetime
import shutil
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__))))
from common import common_setup, load_recipes, \ from common import common_setup, load_recipes, \
@ -176,7 +177,7 @@ if __name__=="__main__":
file = str(os.path.join(layerdir, recipe.full_path())) file = str(os.path.join(layerdir, recipe.full_path()))
recipe_files.append(file) 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) fetchdir, settings, logger, recipe_files=recipe_files)
try: try:
@ -208,6 +209,7 @@ if __name__=="__main__":
finally: finally:
tinfoil.shutdown() tinfoil.shutdown()
shutil.rmtree(tempdir)
if options.dry_run: if options.dry_run:
raise DryRunRollbackException raise DryRunRollbackException
except DryRunRollbackException: except DryRunRollbackException:

View File

@ -16,6 +16,7 @@ import optparse
import logging import logging
import re import re
from distutils.version import LooseVersion from distutils.version import LooseVersion
import shutil
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__))))
from common import common_setup, get_pv_type, load_recipes, \ 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) utils.runcmd("git clean -dfx", bitbakepath, logger=logger)
sys.path.insert(0, os.path.join(bitbakepath, 'lib')) 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, fetchdir, settings, logger, recipe_files=fns,
nocheckout=True) nocheckout=True)
try: try:
@ -212,6 +213,7 @@ def generate_history(options, layerbranch_id, commit, logger):
finally: finally:
if tinfoil and hasattr(tinfoil, 'shutdown') and (LooseVersion(bb.__version__) > LooseVersion("1.27")): if tinfoil and hasattr(tinfoil, 'shutdown') and (LooseVersion(bb.__version__) > LooseVersion("1.27")):
tinfoil.shutdown() tinfoil.shutdown()
shutil.rmtree(tempdir)
if __name__=="__main__": if __name__=="__main__":