From e1a661e3d2d4d62aa0c47c2abb0a6824e1b17ede Mon Sep 17 00:00:00 2001 From: Yoann Congal Date: Thu, 12 Jan 2023 20:32:55 +0100 Subject: bitbake: 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] (Bitbake rev: bf681d173263cd42ffc143655f61abe0573fd83c) Signed-off-by: Yoann Congal Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- bitbake/lib/bb/persist_data.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py index ce84a15825..bcca791edf 100644 --- a/bitbake/lib/bb/persist_data.py +++ b/bitbake/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 -- cgit v1.2.3-54-g00ecf