mirror of
https://git.yoctoproject.org/poky
synced 2026-09-13 09:49:32 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
1bfd9be4dc
commit
f8be2d88cd
@@ -306,18 +306,17 @@ def sstate_install(ss, d):
|
|||||||
sharedfiles.append(ss['fixmedir'] + "/fixmepath")
|
sharedfiles.append(ss['fixmedir'] + "/fixmepath")
|
||||||
|
|
||||||
# Write out the manifest
|
# Write out the manifest
|
||||||
f = open(manifest, "w")
|
with open(manifest, "w") as f:
|
||||||
for file in sharedfiles:
|
for file in sharedfiles:
|
||||||
f.write(file + "\n")
|
f.write(file + "\n")
|
||||||
|
|
||||||
# We want to ensure that directories appear at the end of the manifest
|
# We want to ensure that directories appear at the end of the manifest
|
||||||
# so that when we test to see if they should be deleted any contents
|
# so that when we test to see if they should be deleted any contents
|
||||||
# added by the task will have been removed first.
|
# added by the task will have been removed first.
|
||||||
dirs = sorted(shareddirs, key=len)
|
dirs = sorted(shareddirs, key=len)
|
||||||
# Must remove children first, which will have a longer path than the parent
|
# Must remove children first, which will have a longer path than the parent
|
||||||
for di in reversed(dirs):
|
for di in reversed(dirs):
|
||||||
f.write(di + "\n")
|
f.write(di + "\n")
|
||||||
f.close()
|
|
||||||
|
|
||||||
# Append to the list of manifests for this PACKAGE_ARCH
|
# Append to the list of manifests for this PACKAGE_ARCH
|
||||||
|
|
||||||
@@ -481,9 +480,8 @@ def sstate_clean_cachefiles(d):
|
|||||||
def sstate_clean_manifest(manifest, d, canrace=False, prefix=None):
|
def sstate_clean_manifest(manifest, d, canrace=False, prefix=None):
|
||||||
import oe.path
|
import oe.path
|
||||||
|
|
||||||
mfile = open(manifest)
|
with open(manifest) as mfile:
|
||||||
entries = mfile.readlines()
|
entries = mfile.readlines()
|
||||||
mfile.close()
|
|
||||||
|
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
entry = entry.strip()
|
entry = entry.strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user