public inbox for bitbake-devel@lists.openembedded.org
 help / color / mirror / Atom feed
From: Alexander Kanavin <alex.kanavin@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Alexander Kanavin <alex@linutronix.de>
Subject: [PATCH v2] cooker: warn when sstate is outside of build dir, but hash equiv database is inside it
Date: Tue, 24 Feb 2026 18:54:55 +0100	[thread overview]
Message-ID: <20260224175455.2135473-1-alex.kanavin@gmail.com> (raw)

From: Alexander Kanavin <alex@linutronix.de>

This should help with the long-standing usability problem: when
someone tweaks the configuration to put sstate somewhere else than
the default (so that it can be shared between local builds, or over NFS),
they should also share the hash equivalency database, but there would not
be any indication to do so.

This will issue a warning and recommend to start a dedicated hash equivalency
server (if sstate is on NFS), or set BB_HASHSERVE_DB_DIR (if it isn't).

Signed-off-by: Alexander Kanavin <alex@linutronix.de>

---
v2: guard against relevant variables not being defined
---
 lib/bb/cooker.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 4b6ba3196..88be266bc 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -336,6 +336,25 @@ cannot be on a NFS mount due to potential NFS locking issues between sqlite clie
 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")
+
+                topdir = self.data.getVar("TOPDIR")
+                sstatedir = self.data.getVar("SSTATE_DIR")
+                if (dbdir and topdir and sstatedir and dbdir.startswith(topdir) and not sstatedir.startswith(topdir)):
+                    if utils.is_path_on_nfs(sstatedir):
+                        bb.warn("""Sstate directory is on a shared NFS (it is set via SSTATE_DIR to {}),
+but hash equivalency database is inside this particular build directory {}.
+
+This will prevent sstate reuse, and it is recommended to set up a permanently running hash equivalency server
+according to https://docs.yoctoproject.org/dev-manual/hashequivserver.html""".format(sstatedir, topdir))
+                    else:
+                        bb.warn("""Sstate directory is shared between several builds (it is set via SSTATE_DIR to {}),
+but hash equivalency database is inside this particular build directory {}.
+
+This will prevent sstate reuse, and it is recommended to set the location for the database to a common path
+via BB_HASHSERVE_DB_DIR, for example:
+
+BB_HASHSERVE_DB_DIR = \"${{SSTATE_DIR}}\"""".format(sstatedir, topdir))
+
                 os.makedirs(dbdir, exist_ok=True)
                 dbfile = dbdir + "/hashserv.db"
                 upstream = self.data.getVar("BB_HASHSERVE_UPSTREAM") or None
-- 
2.47.3



                 reply	other threads:[~2026-02-24 17:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260224175455.2135473-1-alex.kanavin@gmail.com \
    --to=alex.kanavin@gmail.com \
    --cc=alex@linutronix.de \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox