classes/retain: add ability to ignore certain tasks
PATCH 1/1 classes/retain: add ability to ignore certain tasks
From: Paul Eggleton <[email protected]>
If you have retain enabled and RETAIN_DIRS_ALWAYS set, then run certain tasks by themselves (e.g. -c clean), it can be annoying to have that trigger retention. Add a RETAIN_IGNORE_TASKS variable that enables specifying tasks that should be ignored by this class, and set a reasonable default.
Signed-off-by Paul Eggleton <[email protected]>
--- meta/classes-global/retain.bbclass | 8 +++++++- meta/lib/oeqa/selftest/cases/retain.py | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-)
meta/classes-global/retain.bbclass +7 -1
@@ -46,6 +46,8 @@ # is writing out the data that you wish to save. # * The tarballs have the tarball name as a top-level directory so that # multiple tarballs can be extracted side-by-side easily. +# * Some tasks shouldn't by themselves trigger retention (e.g. do_clean). +# For that we have RETAIN_IGNORE_TASKS. # # Copyright (c) 2020, 2024 Microsoft Corporation #
@@ -59,6 +61,7 @@ RETAIN_DIRS_GLOBAL_FAILURE ?= "" RETAIN_DIRS_GLOBAL_ALWAYS ?= "" RETAIN_TARBALL_SUFFIX ?= "${DATETIME}.tar.gz" RETAIN_ENABLED ?= "1" +RETAIN_IGNORE_TASKS ?= "do_clean do_cleansstate do_cleanall do_listtasks do_addto_recipe_sysroot" def retain_retain_dir(desc, tarprefix, path, tarbasepath, d):
@@ -99,6 +102,10 @@ python retain_task_handler() { if d.getVar('RETAIN_ENABLED') != '1': return + taskname = d.getVar('BB_CURRENTTASK') + if 'do_' + taskname in d.getVar('RETAIN_IGNORE_TASKS').split(): + return + dirs = d.getVar('RETAIN_DIRS_ALWAYS') if isinstance(e, bb.build.TaskFailed): dirs += ' ' + d.getVar('RETAIN_DIRS_FAILURE')
@@ -109,7 +116,6 @@ python retain_task_handler() { bb.utils.mkdirhier(outdir) dirlist_file = os.path.join(outdir, 'retain_dirs.list') pn = d.getVar('PN') - taskname = d.getVar('BB_CURRENTTASK') with open(dirlist_file, 'a') as f: for entry in dirs: f.write('%s %s %s\n' % (pn, taskname, entry))
meta/lib/oeqa/selftest/cases/retain.py +2 -4
@@ -39,10 +39,8 @@ class Retain(OESelftestTestCase): self.fail('RETAIN_OUTDIR value "%s" is invalid' % retain_outdir) if not oe.path.is_path_parent(tmpdir, retain_outdir): self.fail('RETAIN_OUTDIR (%s) is not underneath TMPDIR (%s)' % (retain_outdir, tmpdir)) - try: - shutil.rmtree(retain_outdir) - except FileNotFoundError: - pass + if os.path.exists(retain_outdir) and os.listdir(retain_outdir): + self.fail('RETAIN_OUTDIR should be empty after -c clean') bitbake(test_recipe) if not glob.glob(os.path.join(retain_outdir, '%s_temp_*.tar.gz' % test_recipe)):
Signature · 1 line
2.43.7