openembedded-core.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] base: Clean up unneeded len() calls
@ 2021-10-13 14:11 Richard Purdie
  2021-10-13 14:11 ` [PATCH 2/3] base: Use repr() for printing exceptions Richard Purdie
  2021-10-13 14:11 ` [PATCH 3/3] bitbake.conf: Add BB_CURRENTTASK to BB_HASHEXCLUDE Richard Purdie
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Purdie @ 2021-10-13 14:11 UTC (permalink / raw)
  To: openembedded-core

This code pattern isn't very pythonic, improve it to drop the unneeded
len() calls.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/base.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 340ebe7d789..35a5e683033 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -153,7 +153,7 @@ do_fetch[vardeps] += "SRCREV"
 python base_do_fetch() {
 
     src_uri = (d.getVar('SRC_URI') or "").split()
-    if len(src_uri) == 0:
+    if not src_uri:
         return
 
     try:
@@ -170,7 +170,7 @@ do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != o
 
 python base_do_unpack() {
     src_uri = (d.getVar('SRC_URI') or "").split()
-    if len(src_uri) == 0:
+    if not src_uri:
         return
 
     try:
@@ -693,7 +693,7 @@ python () {
             if os.path.basename(p) == machine and os.path.isdir(p):
                 paths.append(p)
 
-        if len(paths) != 0:
+        if paths:
             for s in srcuri.split():
                 if not s.startswith("file://"):
                     continue
@@ -726,7 +726,7 @@ do_cleansstate[nostamp] = "1"
 
 python do_cleanall() {
     src_uri = (d.getVar('SRC_URI') or "").split()
-    if len(src_uri) == 0:
+    if not src_uri:
         return
 
     try:
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] base: Use repr() for printing exceptions
  2021-10-13 14:11 [PATCH 1/3] base: Clean up unneeded len() calls Richard Purdie
@ 2021-10-13 14:11 ` Richard Purdie
  2021-10-13 14:11 ` [PATCH 3/3] bitbake.conf: Add BB_CURRENTTASK to BB_HASHEXCLUDE Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2021-10-13 14:11 UTC (permalink / raw)
  To: openembedded-core

Exceptions print more clearly using repr() instead of str(), fix
in fetch and unpack tasks.

Drop part of the test which no longer makes sense after this change.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/base.bbclass               | 4 ++--
 meta/lib/oeqa/selftest/cases/bbtests.py | 3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 35a5e683033..3a94323e403 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -160,7 +160,7 @@ python base_do_fetch() {
         fetcher = bb.fetch2.Fetch(src_uri, d)
         fetcher.download()
     except bb.fetch2.BBFetchException as e:
-        bb.fatal(str(e))
+        bb.fatal("Bitbake Fetcher Error: " + repr(e))
 }
 
 addtask unpack after do_fetch
@@ -177,7 +177,7 @@ python base_do_unpack() {
         fetcher = bb.fetch2.Fetch(src_uri, d)
         fetcher.unpack(d.getVar('WORKDIR'))
     except bb.fetch2.BBFetchException as e:
-        bb.fatal(str(e))
+        bb.fatal("Bitbake Fetcher Error: " + repr(e))
 }
 
 def get_layers_branch_rev(d):
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index 65623640746..6779e621034 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -151,9 +151,6 @@ INHERIT:remove = \"report-error\"
         self.delete_recipeinc('man-db')
         self.assertEqual(result.status, 1, msg="Command succeded when it should have failed. bitbake output: %s" % result.output)
         self.assertIn('Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:', result.output)
-        line = self.getline(result, 'Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.')
-        self.assertTrue(line and line.startswith("ERROR:"), msg = "\"invalid\" file \
-doesn't exist, yet fetcher didn't report any error. bitbake output: %s" % result.output)
 
     def test_rename_downloaded_file(self):
         # TODO unique dldir instead of using cleanall
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] bitbake.conf: Add BB_CURRENTTASK to BB_HASHEXCLUDE
  2021-10-13 14:11 [PATCH 1/3] base: Clean up unneeded len() calls Richard Purdie
  2021-10-13 14:11 ` [PATCH 2/3] base: Use repr() for printing exceptions Richard Purdie
@ 2021-10-13 14:11 ` Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2021-10-13 14:11 UTC (permalink / raw)
  To: openembedded-core

Tasks shouldn't vary dependning on the value of BB_CURRENTTASK. They
happen not to due to when bitbake sets this but to fix other issues,
bitbake needs to set it earlier. Therefore exclude from hashes
globally.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/conf/bitbake.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 030d29b0975..e20b8ef2311 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -906,7 +906,7 @@ BB_HASHEXCLUDE_COMMON ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH BBSERVER DL_DI
     BB_WORKERCONTEXT BB_LIMITEDDEPS BB_UNIHASH extend_recipe_sysroot DEPLOY_DIR \
     SSTATE_HASHEQUIV_METHOD SSTATE_HASHEQUIV_REPORT_TASKDATA \
     SSTATE_HASHEQUIV_OWNER CCACHE_TOP_DIR BB_HASHSERVE GIT_CEILING_DIRECTORIES \
-    OMP_NUM_THREADS"
+    OMP_NUM_THREADS BB_CURRENTTASK"
 BB_HASHBASE_WHITELIST ?= "${BB_HASHEXCLUDE_COMMON} PSEUDO_IGNORE_PATHS BUILDHISTORY_DIR SSTATE_DIR "
 BB_HASHCONFIG_WHITELIST ?= "${BB_HASHEXCLUDE_COMMON} DATE TIME SSH_AGENT_PID \
     SSH_AUTH_SOCK PSEUDO_BUILD BB_ENV_EXTRAWHITE DISABLE_SANITY_CHECKS \
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-13 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 14:11 [PATCH 1/3] base: Clean up unneeded len() calls Richard Purdie
2021-10-13 14:11 ` [PATCH 2/3] base: Use repr() for printing exceptions Richard Purdie
2021-10-13 14:11 ` [PATCH 3/3] bitbake.conf: Add BB_CURRENTTASK to BB_HASHEXCLUDE Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).