]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
sstate: Ensure sstate searches update file mtime
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 6 Nov 2023 14:51:12 +0000 (14:51 +0000)
committerSteve Sakoman <steve@sakoman.com>
Fri, 8 Dec 2023 17:15:08 +0000 (07:15 -1000)
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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit a27fc0bd5706ab5b9c68a0271fcf57377a678cdf)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/classes-global/sstate.bbclass
meta/lib/oe/utils.py

index 2676f18e0a2d60880e77079cd7f81385ddcb970d..5b27a1f0f9805aa8782e958a24723c8e94d6e762 100644 (file)
@@ -937,6 +937,7 @@ def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
         sstatefile = d.expand("${SSTATE_DIR}/" + getsstatefile(tid, siginfo, d))
 
         if os.path.exists(sstatefile):
+            oe.utils.touch(sstatefile)
             found.add(tid)
             bb.debug(2, "SState: Found valid sstate file %s" % sstatefile)
         else:
@@ -1183,16 +1184,7 @@ python sstate_eventhandler() {
         if not os.path.exists(siginfo):
             bb.siggen.dump_this_task(siginfo, d)
         else:
-            try:
-                os.utime(siginfo, None)
-            except PermissionError:
-                pass
-            except OSError as e:
-                # Handle read-only file systems gracefully
-                import errno
-                if e.errno != errno.EROFS:
-                    raise e
-
+            oe.utils.touch(siginfo)
 }
 
 SSTATE_PRUNE_OBSOLETEWORKDIR ?= "1"
index a3b1bb1087d368414634b8cf07dadeb1a0d0f9b1..14a7d07ef011b0860404c4d88cb591c6e3dabfeb 100644 (file)
@@ -7,6 +7,7 @@
 import subprocess
 import multiprocessing
 import traceback
+import errno
 
 def read_file(filename):
     try:
@@ -528,3 +529,14 @@ def directory_size(root, blocksize=4096):
         total += sum(roundup(getsize(os.path.join(root, name))) for name in files)
         total += roundup(getsize(root))
     return total
+
+# Update the mtime of a file, skip if permission/read-only issues
+def touch(filename):
+    try:
+        os.utime(filename, None)
+    except PermissionError:
+        pass
+    except OSError as e:
+        # Handle read-only file systems gracefully
+        if e.errno != errno.EROFS:
+            raise e