From 3d35d09ff2a9bb79f99ee45923fbe74c8fd6d0d7 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 6 Nov 2023 14:51:12 +0000 Subject: 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 --- meta/lib/oe/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'meta/lib/oe') 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 @@ 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 -- cgit v1.2.3-54-g00ecf