Openembedded Bitbake Development
 help / color / mirror / Atom feed
From: Babanpreet Singh <bbnpreetsingh@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>,
	Babanpreet Singh <bbnpreetsingh@gmail.com>
Subject: [PATCH] cooker: fix -w with a file name that has no directory
Date: Sat, 14 Nov 2026 18:55:34 +0000	[thread overview]
Message-ID: <20261114185534.7-1-bbnpreetsingh@gmail.com> (raw)

"bitbake -w events.json" fails with:

  FileNotFoundError: [Errno 2] No such file or directory: ''

There is no directory to create for a bare file name, so don't try.

Fixes: ee174b231897 ("cooker: Add support for BB_DEFAULT_EVENTLOG")
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---

Notes:
    Found while looking at YOCTO #16492. Applies with or without Mathieu's
    patch for that bug.

 lib/bb/cooker.py       |  5 +++--
 lib/bb/tests/cooker.py | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 8a422e506..f79cd5e6c 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -457,8 +457,9 @@ You can also remove the BB_HASHSERVE_UPSTREAM setting, but this may result in si
         if not self.eventlog or self.eventlog[0] != eventlog:
             # we log all events to a file if so directed
             # register the log file writer as UI Handler
-            if not os.path.exists(os.path.dirname(eventlog)):
-                bb.utils.mkdirhier(os.path.dirname(eventlog))
+            dirname = os.path.dirname(eventlog)
+            if dirname and not os.path.exists(dirname):
+                bb.utils.mkdirhier(dirname)
             writer = EventWriter(self, eventlog)
             EventLogWriteHandler = namedtuple('EventLogWriteHandler', ['event'])
             self.eventlog = (eventlog, bb.event.register_UIHhandler(EventLogWriteHandler(writer)), writer)
diff --git a/lib/bb/tests/cooker.py b/lib/bb/tests/cooker.py
index db4104d40..c6a0cac2a 100644
--- a/lib/bb/tests/cooker.py
+++ b/lib/bb/tests/cooker.py
@@ -409,3 +409,21 @@ addtask marker
             with open(os.path.join(builddir, "marker.log")) as f:
                 self.assertEqual(f.read(), "bbappend-applied",
                                  "bitbake -b did not apply the recipe's bbappend")
+
+
+class EventLogTest(_BitbakeSubprocessTestCase):
+    """Tests for the event log ("bitbake -w")."""
+
+    _parsetests = os.path.realpath(os.path.join(os.path.dirname(__file__), "parse-tests"))
+
+    def test_write_log_bare_filename(self):
+        """bitbake -w must accept a file name without a directory."""
+        with self._build_dir(prefix="eventlogtest") as builddir:
+            env = os.environ.copy()
+            env["BBPATH"] = self._parsetests
+            env["BB_ENV_PASSTHROUGH_ADDITIONS"] = "TOPDIR"
+            env["TOPDIR"] = builddir
+
+            self._run_subprocess(["bitbake", "-w", "events.json", "-e"], env, builddir)
+
+            self.assertTrue(os.path.exists(os.path.join(builddir, "events.json")))
-- 
2.43.0


                 reply	other threads:[~2026-11-14 18: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=20261114185534.7-1-bbnpreetsingh@gmail.com \
    --to=bbnpreetsingh@gmail.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=mathieu.dubois-briand@bootlin.com \
    /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