Move manifest entry cleanup code from sstate_clean_manifest() to its own function, so it can be reused.
Signed-off-by: Ovidiu Panait <[email protected]> --- meta/classes-global/sstate.bbclass | 40 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass index 567de4aba4..af93546b04 100644 --- a/meta/classes-global/sstate.bbclass +++ b/meta/classes-global/sstate.bbclass @@ -501,6 +501,27 @@ def sstate_clean_cachefiles(d): ss = sstate_state_fromvars(ld, task) sstate_clean_cachefile(ss, ld) +def sstate_clean_entry(entry, canrace, prefix): + entry = entry.strip() + if prefix and not entry.startswith("/"): + entry = prefix + "/" + entry + + bb.debug(2, "Removing manifest: %s" % entry) + # We can race against another package populating directories as we're removing them + # so we ignore errors here. + try: + if entry.endswith("/"): + if os.path.islink(entry[:-1]): + os.remove(entry[:-1]) + elif os.path.exists(entry) and len(os.listdir(entry)) == 0 and not canrace: + # Removing directories whilst builds are in progress exposes a race. Only + # do it in contexts where it is safe to do so. + os.rmdir(entry[:-1]) + else: + os.remove(entry) + except OSError: + pass + def sstate_clean_manifest(manifest, d, canrace=False, prefix=None): import oe.path @@ -509,24 +530,7 @@ def sstate_clean_manifest(manifest, d, canrace=False, prefix=None): mfile.close() for entry in entries: - entry = entry.strip() - if prefix and not entry.startswith("/"): - entry = prefix + "/" + entry - bb.debug(2, "Removing manifest: %s" % entry) - # We can race against another package populating directories as we're removing them - # so we ignore errors here. - try: - if entry.endswith("/"): - if os.path.islink(entry[:-1]): - os.remove(entry[:-1]) - elif os.path.exists(entry) and len(os.listdir(entry)) == 0 and not canrace: - # Removing directories whilst builds are in progress exposes a race. Only - # do it in contexts where it is safe to do so. - os.rmdir(entry[:-1]) - else: - os.remove(entry) - except OSError: - pass + sstate_clean_entry(entry, canrace, prefix) postrm = manifest + ".postrm" if os.path.exists(manifest + ".postrm"): -- 2.39.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#177797): https://lists.openembedded.org/g/openembedded-core/message/177797 Mute This Topic: https://lists.openembedded.org/mt/97268629/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
