summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-06 14:51:12 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-08 10:56:35 +0000
commit3d35d09ff2a9bb79f99ee45923fbe74c8fd6d0d7 (patch)
tree1bf09224000df61f266845eb460b760023e45386
parent6806bd23499aa66942c2b6b8fbc52dbec8ff8483 (diff)
downloadpoky-3d35d09ff2a9bb79f99ee45923fbe74c8fd6d0d7.tar.gz
sstate: Ensure sstate searches update file mtime
Commands like "bitbake XXX -S printdiff" search for sstate files but don't download them. This means that local files aren't touched as the download code would do, meaning the sstate cleanup scripts can delete them. This can then lead to obtuse build failures. Have the search code touch local files in the same way as the main code paths would to avoid these files disappearing. Move the function to a common touch() function in lib/oe instead of duplicating code. (From OE-Core rev: a27fc0bd5706ab5b9c68a0271fcf57377a678cdf) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-global/sstate.bbclass12
-rw-r--r--meta/lib/oe/utils.py12
2 files changed, 14 insertions, 10 deletions
diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index 2676f18e0a..5b27a1f0f9 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -937,6 +937,7 @@ def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
937 sstatefile = d.expand("${SSTATE_DIR}/" + getsstatefile(tid, siginfo, d)) 937 sstatefile = d.expand("${SSTATE_DIR}/" + getsstatefile(tid, siginfo, d))
938 938
939 if os.path.exists(sstatefile): 939 if os.path.exists(sstatefile):
940 oe.utils.touch(sstatefile)
940 found.add(tid) 941 found.add(tid)
941 bb.debug(2, "SState: Found valid sstate file %s" % sstatefile) 942 bb.debug(2, "SState: Found valid sstate file %s" % sstatefile)
942 else: 943 else:
@@ -1183,16 +1184,7 @@ python sstate_eventhandler() {
1183 if not os.path.exists(siginfo): 1184 if not os.path.exists(siginfo):
1184 bb.siggen.dump_this_task(siginfo, d) 1185 bb.siggen.dump_this_task(siginfo, d)
1185 else: 1186 else:
1186 try: 1187 oe.utils.touch(siginfo)
1187 os.utime(siginfo, None)
1188 except PermissionError:
1189 pass
1190 except OSError as e:
1191 # Handle read-only file systems gracefully
1192 import errno
1193 if e.errno != errno.EROFS:
1194 raise e
1195
1196} 1188}
1197 1189
1198SSTATE_PRUNE_OBSOLETEWORKDIR ?= "1" 1190SSTATE_PRUNE_OBSOLETEWORKDIR ?= "1"
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index a3b1bb1087..14a7d07ef0 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -7,6 +7,7 @@
7import subprocess 7import subprocess
8import multiprocessing 8import multiprocessing
9import traceback 9import traceback
10import errno
10 11
11def read_file(filename): 12def read_file(filename):
12 try: 13 try:
@@ -528,3 +529,14 @@ def directory_size(root, blocksize=4096):
528 total += sum(roundup(getsize(os.path.join(root, name))) for name in files) 529 total += sum(roundup(getsize(os.path.join(root, name))) for name in files)
529 total += roundup(getsize(root)) 530 total += roundup(getsize(root))
530 return total 531 return total
532
533# Update the mtime of a file, skip if permission/read-only issues
534def touch(filename):
535 try:
536 os.utime(filename, None)
537 except PermissionError:
538 pass
539 except OSError as e:
540 # Handle read-only file systems gracefully
541 if e.errno != errno.EROFS:
542 raise e