Skip to contentSkip to conversation

[2.16][PATCH 0/1] Patch review

bitbake Yoann Congal 1 participant 2 messages Jan 20

lore
Share & tools
lore
#0 lore raw

Please review this set of changes for 2.16 and have comments back by end of day Thursday, January 22.

Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/3092

The following changes since commit 663021740bc086bd959a8457ad9ddb6da52a8278:

bin: Hide os.fork() deprecation warning in all bitbake scripts (2026-01-12 09:17:16 +0000)

are available in the Git repository at:

https://git.openembedded.org/bitbake-contrib stable/2.16-nut
https://git.openembedded.org/bitbake-contrib/log/?h=stable/2.16-nut

for you to fetch changes up to 74f8a927ca6a20342072e5579182aea917b6dc30:

bitbake-setup: ensure paths with timestamps in them are unique (2026-01-17 23:15:33 +0100)

----------------------------------------------------------------

Alexander Kanavin (1):
bitbake-setup: ensure paths with timestamps in them are unique

 bin/bitbake-setup | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
#1 lore raw

[bitbake][whinlatter][2.16][PATCH 1/1] bitbake-setup: ensure paths with timestamps in them are unique

From: Alexander Kanavin <[email protected]>

There have been instances where directories with timestamps in them are created within the same second, and their paths clash as the timestamp in them is the same for both, as the timestamp is accurate to 1 second.

This adds a check for the directory existence and then adds an ever-increasing counter until there's a path that isn't yet created.

[YOCTO #16121]

(cherry picked from commit e96b97e176b2fcc0bfdcf0151dff6df3ecaefcb3)
---
 bin/bitbake-setup | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
bin/bitbake-setup +14 -4
index 75be90940..0e0cbb135 100755
@@ -89,6 +89,17 @@ def _write_layer_list(dest, repodirs):
     with open(layers_f, 'w') as f:
         json.dump({"version":"1.0","layers":layers}, f, sort_keys=True, indent=4)
 
+def add_unique_timestamp_to_path(path):
+    timestamp = time.strftime("%Y%m%d%H%M%S")
+    path_unique = "{}.{}".format(path, timestamp)
+    if os.path.exists(path_unique):
+        import itertools
+        for i in itertools.count(start=1):
+            path_unique = "{}.{}.{}".format(path, timestamp, i)
+            if not os.path.exists(path_unique):
+                break
+    return path_unique
+
 def checkout_layers(layers, layerdir, d):
     layers_fixed_revisions = copy.deepcopy(layers)
     repodirs = []
@@ -225,9 +236,8 @@ def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_c
         raise Exception("Cannot complete setting up a bitbake build directory from OpenEmbedded template '{}' as oe-setup-build was not found in any layers; please use oe-init-build-env manually.".format(template))
 
     bitbake_confdir = os.path.join(bitbake_builddir, 'conf')
-    timestamp = time.strftime("%Y%m%d%H%M%S")
-    backup_bitbake_confdir = os.path.join(bitbake_builddir, 'conf-backup.{}'.format(timestamp))
-    upstream_bitbake_confdir = os.path.join(bitbake_builddir, 'conf-upstream.{}'.format(timestamp))
+    backup_bitbake_confdir = add_unique_timestamp_to_path(os.path.join(bitbake_builddir, 'conf-backup'))
+    upstream_bitbake_confdir = add_unique_timestamp_to_path(os.path.join(bitbake_builddir, 'conf-upstream'))
 
     if os.path.exists(bitbake_confdir):
         os.rename(bitbake_confdir, backup_bitbake_confdir)
@@ -714,7 +724,7 @@ def install_buildtools(top_dir, settings, args, d):
         shutil.rmtree(buildtools_install_dir)
 
     install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools')
-    buildtools_download_dir = os.path.join(args.setup_dir, 'buildtools-downloads/{}'.format(time.strftime("%Y%m%d%H%M%S")))
+    buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools'))
     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)