@@ -475,6 +475,29 @@ overview of their function and contents.
equivalences that correspond to Share State caches that are
only available on specific clients.
+ :term:`BB_HASHSERVE_DB_DIR`
+ When :term:`BB_HASHSERVE` is set to ``auto``, bitbake will use
+ a private location inside a particular build directory for the sqlite
+ database file that holds hash equivalency data.
+
+ This variable allows using a different path, which can be shared
+ between multiple build directories and bitbake instances
+ that operate on them. This enables using a common ``${SSTATE_DIR}``
+ together with common hash equivalency data for local builds, without having to
+ separately manage a hash equivalency server.
+
+ .. note::
+
+ This variable cannot be set to a NFS mount and bitbake will error out then.
+ The reason is that NFS implementations can have file locking issues, which
+ can cause data loss and corruption when there are multiple writers operating
+ on a file at the same time as explained in https://sqlite.org/faq.html#q5
+
+ If you'd like to share hash equivalency data between multiple computers, you
+ need to set up a hash equivalency server separately and point :term:`BB_HASHSERVE`
+ to it. See https://docs.yoctoproject.org/dev-manual/hashequivserver.html for
+ additional information.
+
:term:`BB_HASHSERVE_UPSTREAM`
Specifies an upstream Hash Equivalence server.
@@ -328,7 +328,16 @@ class BBCooker:
if self.data.getVar("BB_HASHSERVE") == "auto":
# Create a new hash server bound to a unix domain socket
if not self.hashserv:
- dbfile = (self.data.getVar("PERSISTENT_DIR") or self.data.getVar("CACHE")) + "/hashserv.db"
+ bb_hashserve_db_dir = self.data.getVar("BB_HASHSERVE_DB_DIR")
+ if bb_hashserve_db_dir and utils.is_path_on_nfs(bb_hashserve_db_dir):
+ bb.fatal("""Hash equivalency database location (set via BB_HASHSERVE_DB_DIR to {})
+cannot be on a NFS mount due to potential NFS locking issues between sqlite clients, per https://sqlite.org/faq.html#q5
+
+If you need to share the database between several computers, set up a permanently running hash equivalency server
+according to https://docs.yoctoproject.org/dev-manual/hashequivserver.html""".format(bb_hashserve_db_dir))
+ dbdir = bb_hashserve_db_dir or self.data.getVar("PERSISTENT_DIR") or self.data.getVar("CACHE")
+ os.makedirs(dbdir, exist_ok=True)
+ dbfile = dbdir + "/hashserv.db"
upstream = self.data.getVar("BB_HASHSERVE_UPSTREAM") or None
if upstream:
try:
@@ -2264,3 +2264,11 @@ def lock_timeout_nocheck(lock):
if l:
lock.release()
sigmask(signal.SIG_SETMASK, s)
+
+def is_path_on_nfs(path):
+ """
+ Returns True if ``path`` argument is on a NFS mount.
+ """
+ import bb.process
+ fstype = bb.process.run("stat -f -c %T {}".format(path))[0].strip()
+ return fstype == "nfs"