summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOla x Nilsson <olani@axis.com>2025-08-26 15:41:34 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-08-28 10:47:08 +0100
commitf8be2d88cd41c0ec11a62d8242bb6abfcc1c8c73 (patch)
tree11b29d088a77796aa9279c087b3f4672c5154038
parent1bfd9be4dce4c79767026bb6c2e96f4582089f65 (diff)
downloadpoky-f8be2d88cd41c0ec11a62d8242bb6abfcc1c8c73.tar.gz
sstate: Open file with context manager
In sstat_install and sstate_clean_cache. (From OE-Core rev: 040aeaf3a4fbc780148d725aa666954ad1ab20e7) Signed-off-by: Ola x Nilsson <olani@axis.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-global/sstate.bbclass28
1 files changed, 13 insertions, 15 deletions
diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index e3d6373b3f..2fd29d7323 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -306,18 +306,17 @@ def sstate_install(ss, d):
306 sharedfiles.append(ss['fixmedir'] + "/fixmepath") 306 sharedfiles.append(ss['fixmedir'] + "/fixmepath")
307 307
308 # Write out the manifest 308 # Write out the manifest
309 f = open(manifest, "w") 309 with open(manifest, "w") as f:
310 for file in sharedfiles: 310 for file in sharedfiles:
311 f.write(file + "\n") 311 f.write(file + "\n")
312 312
313 # We want to ensure that directories appear at the end of the manifest 313 # We want to ensure that directories appear at the end of the manifest
314 # so that when we test to see if they should be deleted any contents 314 # so that when we test to see if they should be deleted any contents
315 # added by the task will have been removed first. 315 # added by the task will have been removed first.
316 dirs = sorted(shareddirs, key=len) 316 dirs = sorted(shareddirs, key=len)
317 # Must remove children first, which will have a longer path than the parent 317 # Must remove children first, which will have a longer path than the parent
318 for di in reversed(dirs): 318 for di in reversed(dirs):
319 f.write(di + "\n") 319 f.write(di + "\n")
320 f.close()
321 320
322 # Append to the list of manifests for this PACKAGE_ARCH 321 # Append to the list of manifests for this PACKAGE_ARCH
323 322
@@ -481,9 +480,8 @@ def sstate_clean_cachefiles(d):
481def sstate_clean_manifest(manifest, d, canrace=False, prefix=None): 480def sstate_clean_manifest(manifest, d, canrace=False, prefix=None):
482 import oe.path 481 import oe.path
483 482
484 mfile = open(manifest) 483 with open(manifest) as mfile:
485 entries = mfile.readlines() 484 entries = mfile.readlines()
486 mfile.close()
487 485
488 for entry in entries: 486 for entry in entries:
489 entry = entry.strip() 487 entry = entry.strip()