Skip to contentSkip to conversation

classes: Print bitbake branch and revision

PATCH In review [email protected] 3 participants 7 messages Sep 11, 2024 – Sep 18, 2024

lore
Share & tools
lore
#0 lore raw

v3 cover classes: Print bitbake branch and revision

From: Robert Yang <[email protected]>

* V3:
- Add is_bitbake_in_separate_repo() as Alexander suggested

* V2:
- Move the code out of get_layer_revisions() as Alexander suggested
- Always print bitbake branch and revision to make the output consistent whenever bitbake is in a separate repo or not.

* V1:
- Initial version

// Robert

The following changes since commit 918e2b266eba6779f19f65349f85caa880ba45e7:

libedit: Make docs generation deterministic (2024-09-11 11:56:34 +0100)

are available in the Git repository at:

https://github.com/robertlinux/yocto rbt/bbrev
https://github.com/robertlinux/yocto/tree/rbt/bbrev

Robert Yang (2):
classes: Print bitbake branch and revision
lib/buildcfg: Add is_bitbake_in_separate_repo()

 meta/classes-global/base.bbclass     | 10 +++++++---
 meta/classes/buildhistory.bbclass    |  5 +++--
 meta/classes/image-buildinfo.bbclass | 13 +++++++++++--
 meta/lib/oe/buildcfg.py              | 23 +++++++++++++++++++++++
 4 files changed, 44 insertions(+), 7 deletions(-)
Signature · 1 line
2.44.1
#1 lore raw

PATCH v3 1/2 classes: Print bitbake branch and revision

From: Robert Yang <[email protected]>

There is no bitbake revision when it is in a separate repo, then we have no way to know which version of bitbake is used from the log, this patch always prints it.

* console-latest.log
bitbake = "master:165368bad152a14b32b5216b938aa4b915d72a70"
meta
meta-poky
meta-yocto-bsp = "master:165368bad152a14b32b5216b938aa4b915d72a70"

* buildhistory/metadata-revs
bitbake = master:165368bad152a14b32b5216b938aa4b915d72a70 -- modified
[snip]

* buildhistory/metadata-revs
-----------------------
Build Configuration: |
-----------------------
DISTRO = poky
DISTRO_VERSION = 5.0+snapshot-165368bad152a14b32b5216b938aa4b915d72a70
-----------------------
Bitbake Revision: |
-----------------------
bitbake = master:165368bad152a14b32b5216b938aa4b915d72a70 -- modified
-----------------------
Layer Revisions: |
-----------------------
[snip]

---
 meta/classes-global/base.bbclass     | 10 +++++++---
 meta/classes/buildhistory.bbclass    |  5 +++--
 meta/classes/image-buildinfo.bbclass | 13 +++++++++++--
 meta/lib/oe/buildcfg.py              | 13 +++++++++++++
 4 files changed, 34 insertions(+), 7 deletions(-)
meta/classes-global/base.bbclass +7 -3
index b6940bbb6f..85c7cb8c24 100644
@@ -226,9 +226,13 @@ do_unpack[postfuncs] += "create_source_date_epoch_stamp"
 def get_source_date_epoch_value(d):
     return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
 
+def get_bitbake_branch_rev(d):
+    revisions = oe.buildcfg.get_bitbake_revision()
+    return oe.buildcfg.get_branch_rev3(revisions)
+
 def get_layers_branch_rev(d):
     revisions = oe.buildcfg.get_layer_revisions(d)
-    layers_branch_rev = ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
+    layers_branch_rev = oe.buildcfg.get_branch_rev3(revisions)
     i = len(layers_branch_rev)-1
     p1 = layers_branch_rev[i].find("=")
     s1 = layers_branch_rev[i][p1:]
@@ -241,11 +245,11 @@ def get_layers_branch_rev(d):
         else:
             i -= 1
             p1 = layers_branch_rev[i].find("=")
-            s1= layers_branch_rev[i][p1:]
+            s1 = layers_branch_rev[i][p1:]
     return layers_branch_rev
 
 
-BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars"
+BUILDCFG_FUNCS ??= "buildcfg_vars get_bitbake_branch_rev get_layers_branch_rev buildcfg_neededvars"
 BUILDCFG_FUNCS[type] = "list"
 
 def buildcfg_vars(d):
meta/classes/buildhistory.bbclass +3 -2
index ce3abaa69d..50516e6533 100644
@@ -764,8 +764,9 @@ def buildhistory_get_build_id(d):
 
 def buildhistory_get_metadata_revs(d):
     # We want an easily machine-readable format here
-    revisions = oe.buildcfg.get_layer_revisions(d)
-    medadata_revs = ["%-17s = %s:%s%s" % (r[1], r[2], r[3], r[4]) for r in revisions]
+    revisions = oe.buildcfg.get_bitbake_revision()
+    revisions.extend(oe.buildcfg.get_layer_revisions(d))
+    medadata_revs = oe.buildcfg.get_branch_rev4(revisions)
     return '\n'.join(medadata_revs)
 
 def outputvars(vars, listvars, d):
meta/classes/image-buildinfo.bbclass +11 -2
index b83ce650ad..7b5f84854c 100644
@@ -27,11 +27,14 @@ def image_buildinfo_outputvars(vars, d):
         ret += "%s = %s\n" % (var, value)
     return ret.rstrip('\n')
 
+def get_bitbake_rev(d):
+    revision = oe.buildcfg.get_bitbake_revision()
+    return '\n'.join(oe.buildcfg.get_branch_rev4(revision))
+
 # Returns layer revisions along with their respective status
 def get_layer_revs(d):
     revisions = oe.buildcfg.get_layer_revisions(d)
-    medadata_revs = ["%-17s = %s:%s%s" % (r[1], r[2], r[3], r[4]) for r in revisions]
-    return '\n'.join(medadata_revs)
+    return '\n'.join(oe.buildcfg.get_branch_rev4(revisions))
 
 def buildinfo_target(d):
         # Get context
@@ -55,6 +58,12 @@ Build Configuration:  |
             buildinfo_target(d),
             '''
 -----------------------
+Bitbake Revision:      |
+-----------------------
+''',
+            get_bitbake_rev(d),
+            '''
+-----------------------
 Layer Revisions:      |
 -----------------------
 ''',
meta/lib/oe/buildcfg.py +13 -0
index 4b22f18f36..dab4aa7831 100644
@@ -71,6 +71,19 @@ def is_layer_modified(path):
         # output and a 129 return code when a layer isn't a git repo at all.
         return " -- modified"
 
+def get_branch_rev3(revisions):
+    # Return 3 items for each revision
+    return ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
+
+def get_branch_rev4(revisions):
+    # Return 4 items for each revision
+    return ["%-17s = %s:%s%s" % (r[1], r[2], r[3], r[4]) for r in revisions]
+
+def get_bitbake_revision():
+    bbdir = bb.__file__.rsplit('/', 3)[0]
+    return [(bbdir, os.path.basename(bbdir), get_metadata_git_branch(bbdir).strip(), \
+            get_metadata_git_revision(bbdir), is_layer_modified(bbdir))]
+
 def get_layer_revisions(d):
     layers = (d.getVar("BBLAYERS") or "").split()
     revisions = []
Signature · 1 line
2.44.1
#2 lore raw
Quoted 11 lines · Robert Yang via lists.openembedded.org

From: Robert Yang <[email protected]>

There is no bitbake revision when it is in a separate repo, then we have no way to know which version of bitbake is used from the log, this patch always prints it.

* console-latest.log
bitbake              = "master:165368bad152a14b32b5216b938aa4b915d72a70" meta
meta-poky
meta-yocto-bsp       = "master:165368bad152a14b32b5216b938aa4b915d72a70"

I think this is confusing as it implies that revision is in the bitbake repository which it isn't, that is a poky revision. The current output tries to make that clear, this patch starts to confuse that.

We're really close to release and I'm not going to rush into changing this so close to a release build. I don't mind printing a bitbake revision but it should probably only be when it is a separate repo. The change is too late for 5.1 IMO.

Cheers,

Richard

#3 lore raw
Quoted 13 lines · Richard Purdie
Quoted 11 lines · Robert Yang via lists.openembedded.org

From: Robert Yang <[email protected]>

There is no bitbake revision when it is in a separate repo, then we have no way to know which version of bitbake is used from the log, this patch always prints it.

* console-latest.log
bitbake              = "master:165368bad152a14b32b5216b938aa4b915d72a70" meta
meta-poky
meta-yocto-bsp       = "master:165368bad152a14b32b5216b938aa4b915d72a70"

Quoted 8 lines

I think this is confusing as it implies that revision is in the bitbake repository which it isn't, that is a poky revision. The current output tries to make that clear, this patch starts to confuse that.

We're really close to release and I'm not going to rush into changing this so close to a release build. I don't mind printing a bitbake revision but it should probably only be when it is a separate repo. The change is too late for 5.1 IMO.

Thanks, I will send a V4 for 5.2.

// Robert

Quoted 4 lines

Cheers,

Richard

#4 lore raw

PATCH v3 2/2 lib/buildcfg: Add is_bitbake_in_separate_repo()

In reply to [email protected]

From: Robert Yang <[email protected]>

This would help various tooling that is being developed for setting up layers and builds, or creating configurations for those tasks out of pre-existing yocto setups.

---
 meta/lib/oe/buildcfg.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/lib/oe/buildcfg.py +10 -0
index dab4aa7831..9256b327ed 100644
@@ -71,6 +71,16 @@ def is_layer_modified(path):
         # output and a 129 return code when a layer isn't a git repo at all.
         return " -- modified"
 
+def is_bitbake_in_separate_repo(bitbake_dir):
+    """
+    Check whether bitbake is in a separate git repo
+    """
+    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
+    if os.path.exists(bitbake_git_dir):
+        return True
+    else:
+        return False
+
 def get_branch_rev3(revisions):
     # Return 3 items for each revision
     return ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
Signature · 1 line
2.44.1
#5 lore raw

RE: [OE-core] [PATCH v3 2/2] lib/buildcfg: Add is_bitbake_in_separate_repo()

Quoted 26 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Robert Yang via lists.openembedded.org
Sent: den 11 september 2024 16:36
To: [email protected]
Cc: [email protected]
Subject: [OE-core] [PATCH v3 2/2] lib/buildcfg: Add is_bitbake_in_separate_repo()

From: Robert Yang <[email protected]>

This would help various tooling that is being developed for setting up layers and builds, or creating configurations for those tasks out of pre-existing yocto setups.

---
 meta/lib/oe/buildcfg.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/lib/oe/buildcfg.py +0 -0
index dab4aa7831..9256b327ed 100644
@@ -71,6 +71,16 @@ def is_layer_modified(path):
         # output and a 129 return code when a layer isn't a git repo at all.
         return " -- modified"

meta/lib/oe/buildcfg.py def is_layer_modified(path): · line 82

Quoted 10 lines
meta/lib/oe/buildcfg.py +9 -0
 
+def is_bitbake_in_separate_repo(bitbake_dir):
+    """
+    Check whether bitbake is in a separate git repo
+    """
+    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
+    if os.path.exists(bitbake_git_dir):
+        return True
+    else:
+        return False

That if-statement can be simplified to:

return os.path.exists(bitbake_git_dir)

Quoted 6 lines
meta/lib/oe/buildcfg.py +1 -1
+
 def get_branch_rev3(revisions):
     # Return 3 items for each revision
     return ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
--

2.44.1

//Peter

#6 lore raw

Re: [OE-core] [PATCH v3 2/2] lib/buildcfg: Add is_bitbake_in_separate_repo()

Quoted 39 lines · Peter Kjellerstedt
Quoted 26 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Robert Yang via lists.openembedded.org
Sent: den 11 september 2024 16:36
To: [email protected]
Cc: [email protected]
Subject: [OE-core] [PATCH v3 2/2] lib/buildcfg: Add is_bitbake_in_separate_repo()

From: Robert Yang <[email protected]>

This would help various tooling that is being developed for setting up layers and builds, or creating configurations for those tasks out of pre-existing yocto setups.

---
  meta/lib/oe/buildcfg.py | 10 ++++++++++
  1 file changed, 10 insertions(+)
meta/lib/oe/buildcfg.py +0 -0
index dab4aa7831..9256b327ed 100644
@@ -71,6 +71,16 @@ def is_layer_modified(path):
          # output and a 129 return code when a layer isn't a git repo at all.
          return " -- modified"

meta/lib/oe/buildcfg.py def is_layer_modified(path): · line 82

Quoted 10 lines
meta/lib/oe/buildcfg.py +9 -0
 
+def is_bitbake_in_separate_repo(bitbake_dir):
+    """
+    Check whether bitbake is in a separate git repo
+    """
+    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
+    if os.path.exists(bitbake_git_dir):
+        return True
+    else:
+        return False

That if-statement can be simplified to:

Quoted 1 line

return os.path.exists(bitbake_git_dir)

Thanks, updated in the pull request:

https://github.com/robertlinux/yocto rbt/bbrev
https://github.com/robertlinux/yocto/tree/rbt/bbrev

// Robert

Quoted 10 lines
Quoted 7 lines
meta/lib/oe/buildcfg.py +1 -1
+
  def get_branch_rev3(revisions):
      # Return 3 items for each revision
      return ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
--

2.44.1

//Peter