diff mbox series

[bitbake-devel,1/2] bitbake-setup: Set DL_DIR and SSTATE_DIR in default site.conf

Message ID 20251112154121.3750738-1-JPEWhacker@gmail.com
State New
Headers show
Series [bitbake-devel,1/2] bitbake-setup: Set DL_DIR and SSTATE_DIR in default site.conf | expand

Commit Message

Joshua Watt Nov. 12, 2025, 3:41 p.m. UTC
When bitbake-setup writes out a site.conf file, populate it with a
default DL_DIR and SSTATE_DIR. By default, DL_DIR will point to the same
DL_DIR that bitbake-setup is configured to use, and SSTATE_DIR will be a
"sstate" directory under the top level bitbake setup directory

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 bin/bitbake-setup | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Alexander Kanavin Nov. 12, 2025, 4:18 p.m. UTC | #1
On Wed, 12 Nov 2025 at 16:41, Joshua Watt via lists.openembedded.org
<JPEWhacker=gmail.com@lists.openembedded.org> wrote:
> +                    DL_DIR = "{dl_dir}"

This I agree with.

> +                    SSTATE_DIR = "{top_dir}/sstate"

This needs further discussion and should be taken out of this patch
and added separately. Particularly:

- it should be a setting like dl-dir, and not hardcoded to top_dir/sstate.

- if it is shared in this way, shouldn't we also figure out how to
share the hashequiv server? Right now each build will start their own
private server, which will use their own private database, which will
lead to baffling lack of sstate reuse, despite builds sharing the
sstate dir.

Alex
Joshua Watt Nov. 12, 2025, 5:23 p.m. UTC | #2
On Wed, Nov 12, 2025 at 9:18 AM Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
>
> On Wed, 12 Nov 2025 at 16:41, Joshua Watt via lists.openembedded.org
> <JPEWhacker=gmail.com@lists.openembedded.org> wrote:
> > +                    DL_DIR = "{dl_dir}"
>
> This I agree with.
>
> > +                    SSTATE_DIR = "{top_dir}/sstate"
>
> This needs further discussion and should be taken out of this patch
> and added separately. Particularly:
>
> - it should be a setting like dl-dir, and not hardcoded to top_dir/sstate.
>
> - if it is shared in this way, shouldn't we also figure out how to
> share the hashequiv server? Right now each build will start their own
> private server, which will use their own private database, which will
> lead to baffling lack of sstate reuse, despite builds sharing the
> sstate dir.

Right that was the intention. I think it probably makes sense to do
both SSTATE_DIR and hash equivalence together in a separate patch
though. I'll send a V2

>
> Alex
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 59f501948..590828c9b 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -19,6 +19,7 @@  import datetime
 import glob
 import subprocess
 import copy
+import textwrap
 
 default_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
 
@@ -469,7 +470,7 @@  def init_config(top_dir, settings, args, d):
         progress = event.progress if event.progress > 0 else 0
         print("{}% {}                ".format(progress, rate), file=stdout, end='\r')
 
-    create_siteconf(top_dir, args.non_interactive)
+    create_siteconf(top_dir, args.non_interactive, settings)
     source_overrides = json.load(open(args.source_overrides)) if args.source_overrides else {'sources':{}}
     upstream_config = obtain_config(top_dir, settings, args, source_overrides, d)
     print("\nRun 'bitbake-setup init --non-interactive {}' to select this configuration non-interactively.\n".format(" ".join(upstream_config['non-interactive-cmdline-options'])))
@@ -672,7 +673,7 @@  def install_buildtools(top_dir, settings, args, d):
     print("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir))
     subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True)
 
-def create_siteconf(top_dir, non_interactive=True):
+def create_siteconf(top_dir, non_interactive, settings):
     siteconfpath = os.path.join(top_dir, 'site.conf')
     if os.path.exists(siteconfpath):
         print('A site.conf file already exists. Please remove it if you would like to replace it with a default one')
@@ -682,7 +683,19 @@  def create_siteconf(top_dir, non_interactive=True):
 
         os.makedirs(os.path.dirname(top_dir), exist_ok=True)
         with open(siteconfpath, 'w') as siteconffile:
-            siteconffile.write('# This file is intended for build host-specific bitbake settings\n')
+            siteconffile.write(
+                textwrap.dedent(
+                    """\
+                    # This file is intended for build host-specific bitbake settings
+                    DL_DIR = "{dl_dir}"
+                    SSTATE_DIR = "{top_dir}/sstate"
+                    """.format(
+                        dl_dir=settings["default"]["dl-dir"],
+                        top_dir=top_dir,
+                    )
+                )
+            )
+
 
 def topdir_settings_path(top_dir):
     return os.path.join(top_dir, 'settings.conf')