aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Congal <yoann.congal@smile.fr>2023-01-12 20:32:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-13 17:34:00 +0000
commitbf681d173263cd42ffc143655f61abe0573fd83c (patch)
tree4c4673265adf2794129b33fe0c2439b89b431f63
parent0f9a0c7853b181817bf01863a26da21412376294 (diff)
downloadbitbake-contrib-bf681d173263cd42ffc143655f61abe0573fd83c.tar.gz
persist_data: Handle sqlite error when cachefile path is too long
Sqlite can't open the cachefile when its path is too long (>= 505 char by my tests). We do have a path length check in sanity.bbclass but this code is called before sanity checks. Treat the error in the exception instead of checking before hand in case sqlite eventually fixes this. Fixes [YOCTO #12374] Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/persist_data.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py
index ce84a1582..bcca791ed 100644
--- a/lib/bb/persist_data.py
+++ b/lib/bb/persist_data.py
@@ -249,4 +249,23 @@ def persist(domain, d):
bb.utils.mkdirhier(cachedir)
cachefile = os.path.join(cachedir, "bb_persist_data.sqlite3")
- return SQLTable(cachefile, domain)
+
+ try:
+ return SQLTable(cachefile, domain)
+ except sqlite3.OperationalError:
+ # Sqlite fails to open database when its path is too long.
+ # After testing, 504 is the biggest path length that can be opened by
+ # sqlite.
+ # Note: This code is called before sanity.bbclass and its path length
+ # check
+ max_len = 504
+ if len(cachefile) > max_len:
+ logger.critical("The path of the cache file is too long "
+ "({0} chars > {1}) to be opened by sqlite! "
+ "Your cache file is \"{2}\"".format(
+ len(cachefile),
+ max_len,
+ cachefile))
+ sys.exit(1)
+ else:
+ raise