Skip to contentSkip to conversation

bitbake-setup: Set DL_DIR and SSTATE_DIR in default site.conf

PATCH Superseded Joshua Watt 2 participants 10 messages Nov 12, 2025 – Nov 19, 2025

lore
Share & tools
lore
#1 lore raw

PATCH 2/2 bitbake-setup: Tell the user what to do if they don't like the top dir

In reply to Joshua Watt

If the top level directory look new (e.g. doesn't contain a site.conf file), then instruct the user on how to choose a different directory if they desire. This should help clarify what bitbake-setup is about to do and how to change it if desired.

---
 bin/bitbake-setup | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
bin/bitbake-setup +10 -1
index 590828c9b..c3a29aacc 100755
@@ -678,7 +678,16 @@ def create_siteconf(top_dir, non_interactive, settings):
     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')
     else:
-        print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
+        print(f'{top_dir} looks like a new top directory. If you would like to use a different directory, answer "n" below and either:')
+        print('\t1) Pass one or more options to bitbake-setup change the top level directory:')
+        print('\t\tbitbake-setup --setting default top-dir-prefix <PATH> ...')
+        print('\t\tbitbake-setup --setting default top-dir-name <NAME> ...')
+        print('\t2) Change the default bitbake-setup configuration with:')
+        print('\t\tbitbake-setup settings set default top-level-prefix <PATH>')
+        print('\t\tbitbake-setup settings set default top-level-name <NAME>')
+        print()
+
+        print('A common site.conf file will be created, please check it is correct before running builds\n    {}\n'.format(siteconfpath))
         prompt_continue(non_interactive)
 
         os.makedirs(os.path.dirname(top_dir), exist_ok=True)
Signature · 1 line
2.51.1
#0 lore raw

PATCH 1/2 bitbake-setup: Set DL_DIR and SSTATE_DIR in default site.conf

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

---
 bin/bitbake-setup | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
bin/bitbake-setup +16 -3
index 59f501948..590828c9b 100755
@@ -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')
Signature · 1 line
2.51.1
#7 lore raw
Quoted 1 line · Joshua Watt via lists.openembedded.org

+ DL_DIR = "{dl_dir}"

This I agree with.

Quoted 1 line

+ 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

#8 lore raw
Quoted 12 lines · Alexander Kanavin
Quoted 1 line · Joshua Watt via lists.openembedded.org

+ DL_DIR = "{dl_dir}"

This I agree with.

Quoted 1 line

+ SSTATE_DIR = "{top_dir}/sstate"

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

Quoted 7 lines

- 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

Quoted 2 lines

Alex

#9 lore raw

PATCH v2 1/1 bitbake-setup: Set DL_DIR in default site.conf

In reply to Joshua Watt

When bitbake-setup writes out a site.conf file, populate it with a default DL_DIR. By default, DL_DIR will point to the same DL_DIR that bitbake-setup is configured to use.

---
 bin/bitbake-setup | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
bin/bitbake-setup +14 -3
index 59f501948..3f0caab80 100755
@@ -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,17 @@ 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}"
+                    """.format(
+                        dl_dir=settings["default"]["dl-dir"],
+                    )
+                )
+            )
+
 
 def topdir_settings_path(top_dir):
     return os.path.join(top_dir, 'settings.conf')
Signature · 1 line
2.51.1
#2 lore raw

PATCH v2 1/1 bitbake-setup: Tell the user what to do if they don't like the top dir

In reply to Joshua Watt

If the top level directory look new (e.g. doesn't contain a site.conf file), then instruct the user on how to choose a different directory if they desire. This should help clarify what bitbake-setup is about to do and how to change it if desired.

---
 bin/bitbake-setup | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
bin/bitbake-setup +10 -1
index 3a281defa..b54e98ba2 100755
@@ -671,7 +671,16 @@ def create_siteconf(top_dir, non_interactive, settings):
     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')
     else:
-        print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
+        print(f'{top_dir} looks like a new top directory. If you would like to use a different directory, answer "n" below and either:')
+        print('\t1) Pass one or more options to bitbake-setup change the top level directory:')
+        print('\t\tbitbake-setup --setting default top-dir-prefix <PATH> ...')
+        print('\t\tbitbake-setup --setting default top-dir-name <NAME> ...')
+        print('\t2) Change the default bitbake-setup configuration with:')
+        print('\t\tbitbake-setup settings set default top-level-prefix <PATH>')
+        print('\t\tbitbake-setup settings set default top-level-name <NAME>')
+        print()
+
+        print('A common site.conf file will be created, please check it is correct before running builds\n    {}\n'.format(siteconfpath))
         if not non_interactive:
             y_or_n = input('Proceed? (y/N): ')
             if y_or_n != 'y':
Signature · 1 line
2.51.1
#3 lore raw

Re: [bitbake-devel][PATCH v2] bitbake-setup: Tell the user what to do if they don't like the top dir

I had the vague feeling during the call there's a patch I've seen which was missed, and this is the patch.

Can you tweak it, so that this message:
Bitbake-setup is using /home/alex/bitbake-builds as top directory ("bitbake-setup settings --help" shows how to change it).

does not anymore include the bit in ( )
(RP pointed out that "bitbake-setup settings --help" doesn't actually show that, but the newly added prints would address that)

Alex

Quoted 45 lines · Joshua Watt via lists.openembedded.org

If the top level directory look new (e.g. doesn't contain a site.conf file), then instruct the user on how to choose a different directory if they desire. This should help clarify what bitbake-setup is about to do and how to change it if desired.

---
 bin/bitbake-setup | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
bin/bitbake-setup +10 -2
index 3a281defa..b54e98ba2 100755
@@ -671,7 +671,16 @@ def create_siteconf(top_dir, non_interactive, settings):
     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')
     else:
-        print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
+        print(f'{top_dir} looks like a new top directory. If you would like to use a different directory, answer "n" below and either:')
+        print('\t1) Pass one or more options to bitbake-setup change the top level directory:')
+        print('\t\tbitbake-setup --setting default top-dir-prefix <PATH> ...')
+        print('\t\tbitbake-setup --setting default top-dir-name <NAME> ...')
+        print('\t2) Change the default bitbake-setup configuration with:')
+        print('\t\tbitbake-setup settings set default top-level-prefix <PATH>')
+        print('\t\tbitbake-setup settings set default top-level-name <NAME>')
+        print()
+
+        print('A common site.conf file will be created, please check it is correct before running builds\n    {}\n'.format(siteconfpath))
         if not non_interactive:
             y_or_n = input('Proceed? (y/N): ')
             if y_or_n != 'y':
--

2.51.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#18379): https://lists.openembedded.org/g/bitbake-devel/message/18379
Mute This Topic: https://lists.openembedded.org/mt/116276734/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw

PATCH v2 1/1 bitbake-setup: Tell the user what to do if they don't like the top dir

In reply to Joshua Watt

If the top level directory look new (e.g. doesn't contain a site.conf file), then instruct the user on how to choose a different directory if they desire. This should help clarify what bitbake-setup is about to do and how to change it if desired.

---
 bin/bitbake-setup | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
bin/bitbake-setup +11 -2
index 3a281defa..7e9491fac 100755
@@ -671,7 +671,16 @@ def create_siteconf(top_dir, non_interactive, settings):
     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')
     else:
-        print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
+        print(f'{top_dir} looks like a new top directory. If you would like to use a different directory, answer "n" below and either:')
+        print('\t1) Pass one or more options to bitbake-setup change the top level directory:')
+        print('\t\tbitbake-setup --setting default top-dir-prefix <PATH> ...')
+        print('\t\tbitbake-setup --setting default top-dir-name <NAME> ...')
+        print('\t2) Change the default bitbake-setup configuration with:')
+        print('\t\tbitbake-setup settings set default top-level-prefix <PATH>')
+        print('\t\tbitbake-setup settings set default top-level-name <NAME>')
+        print()
+
+        print('A common site.conf file will be created, please check it is correct before running builds\n    {}\n'.format(siteconfpath))
         if not non_interactive:
             y_or_n = input('Proceed? (y/N): ')
             if y_or_n != 'y':
@@ -896,7 +905,7 @@ def main():
             settings_func(top_dir, all_settings, args)
             return
 
-        print('Bitbake-setup is using {} as top directory ("bitbake-setup settings --help" shows how to change it).\n'.format(top_dir, global_settings_path(args)))
+        print('Bitbake-setup is using {} as top directory.\n'.format(top_dir, global_settings_path(args)))
 
         d = init_bb_cache(top_dir, all_settings, args)
         args.func(top_dir, all_settings, args, d)
Signature · 1 line
2.51.1
#5 lore raw

Re: [bitbake-devel][PATCH v2] bitbake-setup: Tell the user what to do if they don't like the top dir

This doesn't apply on current master. I'll rebase and resend as part of further tweaks to address the remaining issues.

Alex

Quoted 54 lines · Joshua Watt via lists.openembedded.org

If the top level directory look new (e.g. doesn't contain a site.conf file), then instruct the user on how to choose a different directory if they desire. This should help clarify what bitbake-setup is about to do and how to change it if desired.

---
 bin/bitbake-setup | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
bin/bitbake-setup +11 -3
index 3a281defa..7e9491fac 100755
@@ -671,7 +671,16 @@ def create_siteconf(top_dir, non_interactive, settings):
     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')
     else:
-        print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
+        print(f'{top_dir} looks like a new top directory. If you would like to use a different directory, answer "n" below and either:')
+        print('\t1) Pass one or more options to bitbake-setup change the top level directory:')
+        print('\t\tbitbake-setup --setting default top-dir-prefix <PATH> ...')
+        print('\t\tbitbake-setup --setting default top-dir-name <NAME> ...')
+        print('\t2) Change the default bitbake-setup configuration with:')
+        print('\t\tbitbake-setup settings set default top-level-prefix <PATH>')
+        print('\t\tbitbake-setup settings set default top-level-name <NAME>')
+        print()
+
+        print('A common site.conf file will be created, please check it is correct before running builds\n    {}\n'.format(siteconfpath))
         if not non_interactive:
             y_or_n = input('Proceed? (y/N): ')
             if y_or_n != 'y':
@@ -896,7 +905,7 @@ def main():
             settings_func(top_dir, all_settings, args)
             return
 
-        print('Bitbake-setup is using {} as top directory ("bitbake-setup settings --help" shows how to change it).\n'.format(top_dir, global_settings_path(args)))
+        print('Bitbake-setup is using {} as top directory.\n'.format(top_dir, global_settings_path(args)))
 
         d = init_bb_cache(top_dir, all_settings, args)
         args.func(top_dir, all_settings, args, d)
--

2.51.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#18436): https://lists.openembedded.org/g/bitbake-devel/message/18436
Mute This Topic: https://lists.openembedded.org/mt/116276734/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw

Re: [bitbake-devel][PATCH v2] bitbake-setup: Tell the user what to do if they don't like the top dir

In reply to Joshua Watt

bin/bitbake-setup def create_siteconf(top_dir, non_interactive, settings): · line 680

Quoted 8 lines · Joshua Watt via lists.openembedded.org
bin/bitbake-setup +7 -1
-        print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
+        print(f'{top_dir} looks like a new top directory. If you would like to use a different directory, answer "n" below and either:')
+        print('\t1) Pass one or more options to bitbake-setup change the top level directory:')
+        print('\t\tbitbake-setup --setting default top-dir-prefix <PATH> ...')
+        print('\t\tbitbake-setup --setting default top-dir-name <NAME> ...')
+        print('\t2) Change the default bitbake-setup configuration with:')
+        print('\t\tbitbake-setup settings set default top-level-prefix <PATH>')
+        print('\t\tbitbake-setup settings set default top-level-name <NAME>')

I'm going to slightly tweak this: changing the default should come first, and 'Pass one or more options to bitbake-setup change the top level directory' is not good grammar.

Alex