diff mbox series

[1/1] buildcfg: Print bitbake branch and revision when it is in a separate repo

Message ID 8f43b5d81fdd28340c6c14fddd307b55ac05883e.1725456147.git.liezhi.yang@windriver.com
State New
Headers show
Series [1/1] buildcfg: Print bitbake branch and revision when it is in a separate repo | expand

Commit Message

Robert Yang Sept. 4, 2024, 1:23 p.m. UTC
From: Robert Yang <liezhi.yang@windriver.com>

Clone https://git.openembedded.org/bitbake into poky/bitbake
Before the patch:
meta
meta-poky
meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"

Now:
bitbake              = "master:5bd0c65c217394cde4c8e382eba6cf7f4b909c97"
meta
meta-poky
meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/lib/oe/buildcfg.py | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Alexander Kanavin Sept. 4, 2024, 1:36 p.m. UTC | #1
I don't think putting this into get_layer_revisions() is correct.
Bitbake is not a layer, and obtaining its revision should be in a
separate pair of functions:

is_bitbake_in_separate_repo()
get_bitbake_revision()

Alex

On Wed, 4 Sept 2024 at 15:23, Robert Yang via lists.openembedded.org
<liezhi.yang=windriver.com@lists.openembedded.org> wrote:
>
> From: Robert Yang <liezhi.yang@windriver.com>
>
> Clone https://git.openembedded.org/bitbake into poky/bitbake
> Before the patch:
> meta
> meta-poky
> meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"
>
> Now:
> bitbake              = "master:5bd0c65c217394cde4c8e382eba6cf7f4b909c97"
> meta
> meta-poky
> meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"
>
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  meta/lib/oe/buildcfg.py | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py
> index 4b22f18f36..5e2de15127 100644
> --- a/meta/lib/oe/buildcfg.py
> +++ b/meta/lib/oe/buildcfg.py
> @@ -73,6 +73,12 @@ def is_layer_modified(path):
>
>  def get_layer_revisions(d):
>      layers = (d.getVar("BBLAYERS") or "").split()
> +    # bitbake may in a separate git repo
> +    bitbake_dir = bb.__file__.rsplit('/', 3)[0]
> +    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
> +    if os.path.exists(bitbake_git_dir):
> +        layers.insert(0, bitbake_dir)
> +
>      revisions = []
>      for i in layers:
>          revisions.append((i, os.path.basename(i), get_metadata_git_branch(i).strip(), get_metadata_git_revision(i), is_layer_modified(i)))
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#204207): https://lists.openembedded.org/g/openembedded-core/message/204207
> Mute This Topic: https://lists.openembedded.org/mt/108264652/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Robert Yang Sept. 4, 2024, 2:03 p.m. UTC | #2
On 9/4/24 21:36, Alexander Kanavin wrote:
> I don't think putting this into get_layer_revisions() is correct.
> Bitbake is not a layer, and obtaining its revision should be in a
> separate pair of functions:
> 
> is_bitbake_in_separate_repo()
> get_bitbake_revision()

Makes sense, I will send a V2 for it.

// Robert

> 
> Alex
> 
> On Wed, 4 Sept 2024 at 15:23, Robert Yang via lists.openembedded.org
> <liezhi.yang=windriver.com@lists.openembedded.org> wrote:
>>
>> From: Robert Yang <liezhi.yang@windriver.com>
>>
>> Clone https://git.openembedded.org/bitbake into poky/bitbake
>> Before the patch:
>> meta
>> meta-poky
>> meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"
>>
>> Now:
>> bitbake              = "master:5bd0c65c217394cde4c8e382eba6cf7f4b909c97"
>> meta
>> meta-poky
>> meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"
>>
>> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
>> ---
>>   meta/lib/oe/buildcfg.py | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py
>> index 4b22f18f36..5e2de15127 100644
>> --- a/meta/lib/oe/buildcfg.py
>> +++ b/meta/lib/oe/buildcfg.py
>> @@ -73,6 +73,12 @@ def is_layer_modified(path):
>>
>>   def get_layer_revisions(d):
>>       layers = (d.getVar("BBLAYERS") or "").split()
>> +    # bitbake may in a separate git repo
>> +    bitbake_dir = bb.__file__.rsplit('/', 3)[0]
>> +    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
>> +    if os.path.exists(bitbake_git_dir):
>> +        layers.insert(0, bitbake_dir)
>> +
>>       revisions = []
>>       for i in layers:
>>           revisions.append((i, os.path.basename(i), get_metadata_git_branch(i).strip(), get_metadata_git_revision(i), is_layer_modified(i)))
>> --
>> 2.25.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#204207): https://lists.openembedded.org/g/openembedded-core/message/204207
>> Mute This Topic: https://lists.openembedded.org/mt/108264652/1686489
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
Robert Yang Sept. 11, 2024, 1:12 p.m. UTC | #3
Hi Alexander,

On 9/4/24 21:36, Alexander Kanavin wrote:
> I don't think putting this into get_layer_revisions() is correct.
> Bitbake is not a layer, and obtaining its revision should be in a
> separate pair of functions:

After more thoughts, I think always print bitbake branch and revision is better,
this is can make the output consistent whenever bitbake is in a separate repo or 
not.

I've sent a V2 for it.

// Robert

> 
> is_bitbake_in_separate_repo()
> get_bitbake_revision()
> 
> Alex
> 
> On Wed, 4 Sept 2024 at 15:23, Robert Yang via lists.openembedded.org
> <liezhi.yang=windriver.com@lists.openembedded.org> wrote:
>>
>> From: Robert Yang <liezhi.yang@windriver.com>
>>
>> Clone https://git.openembedded.org/bitbake into poky/bitbake
>> Before the patch:
>> meta
>> meta-poky
>> meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"
>>
>> Now:
>> bitbake              = "master:5bd0c65c217394cde4c8e382eba6cf7f4b909c97"
>> meta
>> meta-poky
>> meta-yocto-bsp       = "master:377fd06d86f5f3be80a927ee19c30d9557077a7f"
>>
>> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
>> ---
>>   meta/lib/oe/buildcfg.py | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py
>> index 4b22f18f36..5e2de15127 100644
>> --- a/meta/lib/oe/buildcfg.py
>> +++ b/meta/lib/oe/buildcfg.py
>> @@ -73,6 +73,12 @@ def is_layer_modified(path):
>>
>>   def get_layer_revisions(d):
>>       layers = (d.getVar("BBLAYERS") or "").split()
>> +    # bitbake may in a separate git repo
>> +    bitbake_dir = bb.__file__.rsplit('/', 3)[0]
>> +    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
>> +    if os.path.exists(bitbake_git_dir):
>> +        layers.insert(0, bitbake_dir)
>> +
>>       revisions = []
>>       for i in layers:
>>           revisions.append((i, os.path.basename(i), get_metadata_git_branch(i).strip(), get_metadata_git_revision(i), is_layer_modified(i)))
>> --
>> 2.25.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#204207): https://lists.openembedded.org/g/openembedded-core/message/204207
>> Mute This Topic: https://lists.openembedded.org/mt/108264652/1686489
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
diff mbox series

Patch

diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py
index 4b22f18f36..5e2de15127 100644
--- a/meta/lib/oe/buildcfg.py
+++ b/meta/lib/oe/buildcfg.py
@@ -73,6 +73,12 @@  def is_layer_modified(path):
 
 def get_layer_revisions(d):
     layers = (d.getVar("BBLAYERS") or "").split()
+    # bitbake may in a separate git repo
+    bitbake_dir = bb.__file__.rsplit('/', 3)[0]
+    bitbake_git_dir = os.path.join(bitbake_dir, '.git')
+    if os.path.exists(bitbake_git_dir):
+        layers.insert(0, bitbake_dir)
+
     revisions = []
     for i in layers:
         revisions.append((i, os.path.basename(i), get_metadata_git_branch(i).strip(), get_metadata_git_revision(i), is_layer_modified(i)))