[1/5] recipetool-create: add ensure_native_cmd function

Message ID 20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com
State New
Headers show
Series [1/5] recipetool-create: add ensure_native_cmd function | expand

Commit Message

Stefan Herbrechtsmeier May 6, 2022, 6:59 a.m. UTC
From: Lukas Funke <lukas.funke@weidmueller.com>

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

 scripts/lib/recipetool/create.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Alexander Kanavin May 6, 2022, 7:09 a.m. UTC | #1
I think the terminology is a bit confused here, instead of 'command'
it should say 'recipe'. Also:
"""Check if the command is available in the recipes""" is not
everything it does, it also builds the recipe.

And please write a commit message that explains what and why.

Alex

On Fri, 6 May 2022 at 09:00, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> From: Lukas Funke <lukas.funke@weidmueller.com>
>
> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> ---
>
>  scripts/lib/recipetool/create.py | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
> index 824ac6350d..efcb82173e 100644
> --- a/scripts/lib/recipetool/create.py
> +++ b/scripts/lib/recipetool/create.py
> @@ -1375,6 +1375,29 @@ def convert_rpm_xml(xmlfile):
>                      values[varname] = child[0].text
>      return values
>
> +def ensure_native_cmd(tinfoil, cmd):
> +    """Check if the command is available in the recipes"""
> +    if not tinfoil.recipes_parsed:
> +        tinfoil.parse_recipes()
> +
> +    try:
> +        d = tinfoil.parse_recipe("%s-native" % cmd)
> +    except bb.providers.NoProvider:
> +        bb.error("Nothing provides '%s-native' which is required for the build" % cmd)
> +        bb.note("You will likely need to add a layer that provides %s" % cmd)
> +        sys.exit(14)
> +
> +    bindir = d.getVar("STAGING_BINDIR_NATIVE")
> +    cmdpath = os.path.join(bindir, cmd)
> +
> +    if not os.path.exists(cmdpath):
> +        tinfoil.build_targets("%s-native" % cmd, "addto_recipe_sysroot")
> +
> +        if not os.path.exists(cmdpath):
> +            bb.error("Failed to add '%s' to sysroot" % cmd)
> +            sys.exit(14)
> +
> +    return bindir
>
>  def register_commands(subparsers):
>      parser_create = subparsers.add_parser('create',
> --
> 2.30.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#165323): https://lists.openembedded.org/g/openembedded-core/message/165323
> Mute This Topic: https://lists.openembedded.org/mt/90928682/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Luca Ceresoli May 9, 2022, 9:46 p.m. UTC | #2
Hello Stefan,

Il giorno Fri,  6 May 2022 08:59:13 +0200
"Stefan Herbrechtsmeier" <stefan.herbrechtsmeier-oss@weidmueller.com>
ha scritto:

> From: Lukas Funke <lukas.funke@weidmueller.com>
> 
> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
> Signed-off-by: Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier@weidmueller.com>

Testing builds with your series trigger many build failures related to
recipetool. Can you check these logs?

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/3557/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/3506/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/3527/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3566/steps/14/logs/stdio
Stefan Herbrechtsmeier May 11, 2022, 6:54 a.m. UTC | #3
Hi Luca,

Lukas will check the logs and fix the problem.

Regards
   Stefan

Am 09.05.2022 um 23:46 schrieb Luca Ceresoli:
> Hello Stefan,
> 
> Il giorno Fri,  6 May 2022 08:59:13 +0200
> "Stefan Herbrechtsmeier" <stefan.herbrechtsmeier-oss@weidmueller.com>
> ha scritto:
> 
>> From: Lukas Funke <lukas.funke@weidmueller.com>
>>
>> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
>> Signed-off-by: Stefan Herbrechtsmeier
>> <stefan.herbrechtsmeier@weidmueller.com>
> 
> Testing builds with your series trigger many build failures related to
> recipetool. Can you check these logs?
> 
> https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/3557/steps/15/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/3506/steps/14/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/3527/steps/14/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3566/steps/14/logs/stdio
> 
> 
>
Mark Asselstine May 11, 2022, 7:45 p.m. UTC | #4
On 2022-05-06 03:09, Alexander Kanavin wrote:
> I think the terminology is a bit confused here, instead of 'command'
> it should say 'recipe'. Also:
> """Check if the command is available in the recipes""" is not
> everything it does, it also builds the recipe.
> 
> And please write a commit message that explains what and why.

Additionally, I would squash commits 1/5 and 2/5. Most people, including 
myself, will review the commits in order, in doing so commit 1/5 is 
reviewed as original work, only to find in 2/5 that it was an existing 
function, just made generic. Combining these also makes it easier when 
mining history.

MarkA


> 
> Alex
> 
> On Fri, 6 May 2022 at 09:00, Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>
>> From: Lukas Funke <lukas.funke@weidmueller.com>
>>
>> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
>> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>> ---
>>
>>   scripts/lib/recipetool/create.py | 23 +++++++++++++++++++++++
>>   1 file changed, 23 insertions(+)
>>
>> diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
>> index 824ac6350d..efcb82173e 100644
>> --- a/scripts/lib/recipetool/create.py
>> +++ b/scripts/lib/recipetool/create.py
>> @@ -1375,6 +1375,29 @@ def convert_rpm_xml(xmlfile):
>>                       values[varname] = child[0].text
>>       return values
>>
>> +def ensure_native_cmd(tinfoil, cmd):
>> +    """Check if the command is available in the recipes"""
>> +    if not tinfoil.recipes_parsed:
>> +        tinfoil.parse_recipes()
>> +
>> +    try:
>> +        d = tinfoil.parse_recipe("%s-native" % cmd)
>> +    except bb.providers.NoProvider:
>> +        bb.error("Nothing provides '%s-native' which is required for the build" % cmd)
>> +        bb.note("You will likely need to add a layer that provides %s" % cmd)
>> +        sys.exit(14)
>> +
>> +    bindir = d.getVar("STAGING_BINDIR_NATIVE")
>> +    cmdpath = os.path.join(bindir, cmd)
>> +
>> +    if not os.path.exists(cmdpath):
>> +        tinfoil.build_targets("%s-native" % cmd, "addto_recipe_sysroot")
>> +
>> +        if not os.path.exists(cmdpath):
>> +            bb.error("Failed to add '%s' to sysroot" % cmd)
>> +            sys.exit(14)
>> +
>> +    return bindir
>>
>>   def register_commands(subparsers):
>>       parser_create = subparsers.add_parser('create',
>> --
>> 2.30.2
>>
>>
>>
>>
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#165330): https://lists.openembedded.org/g/openembedded-core/message/165330
>> Mute This Topic: https://lists.openembedded.org/mt/90928682/3616946
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mark.asselstine@windriver.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
Mark Asselstine May 11, 2022, 7:47 p.m. UTC | #5
On 2022-05-11 15:45, Mark Asselstine wrote:
> 
> 
> On 2022-05-06 03:09, Alexander Kanavin wrote:
>> I think the terminology is a bit confused here, instead of 'command'
>> it should say 'recipe'. Also:
>> """Check if the command is available in the recipes""" is not
>> everything it does, it also builds the recipe.
>>
>> And please write a commit message that explains what and why.
> 
> Additionally, I would squash commits 1/5 and 2/5. Most people, including 
> myself, will review the commits in order, in doing so commit 1/5 is 
> reviewed as original work, only to find in 2/5 that it was an existing 
> function, just made generic. Combining these also makes it easier when 
> mining history.
> 

I suspect this will need rework as the assumption that a command and 
package name are 1:1 might have only been valid with NPM but definitely 
won't be the case for many commands.

MarkA


> MarkA
> 
> 
>>
>> Alex
>>
>> On Fri, 6 May 2022 at 09:00, Stefan Herbrechtsmeier
>> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>>
>>> From: Lukas Funke <lukas.funke@weidmueller.com>
>>>
>>> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
>>> Signed-off-by: Stefan Herbrechtsmeier 
>>> <stefan.herbrechtsmeier@weidmueller.com>
>>> ---
>>>
>>>   scripts/lib/recipetool/create.py | 23 +++++++++++++++++++++++
>>>   1 file changed, 23 insertions(+)
>>>
>>> diff --git a/scripts/lib/recipetool/create.py 
>>> b/scripts/lib/recipetool/create.py
>>> index 824ac6350d..efcb82173e 100644
>>> --- a/scripts/lib/recipetool/create.py
>>> +++ b/scripts/lib/recipetool/create.py
>>> @@ -1375,6 +1375,29 @@ def convert_rpm_xml(xmlfile):
>>>                       values[varname] = child[0].text
>>>       return values
>>>
>>> +def ensure_native_cmd(tinfoil, cmd):
>>> +    """Check if the command is available in the recipes"""
>>> +    if not tinfoil.recipes_parsed:
>>> +        tinfoil.parse_recipes()
>>> +
>>> +    try:
>>> +        d = tinfoil.parse_recipe("%s-native" % cmd)
>>> +    except bb.providers.NoProvider:
>>> +        bb.error("Nothing provides '%s-native' which is required for 
>>> the build" % cmd)
>>> +        bb.note("You will likely need to add a layer that provides 
>>> %s" % cmd)
>>> +        sys.exit(14)
>>> +
>>> +    bindir = d.getVar("STAGING_BINDIR_NATIVE")
>>> +    cmdpath = os.path.join(bindir, cmd)
>>> +
>>> +    if not os.path.exists(cmdpath):
>>> +        tinfoil.build_targets("%s-native" % cmd, 
>>> "addto_recipe_sysroot")
>>> +
>>> +        if not os.path.exists(cmdpath):
>>> +            bb.error("Failed to add '%s' to sysroot" % cmd)
>>> +            sys.exit(14)
>>> +
>>> +    return bindir
>>>
>>>   def register_commands(subparsers):
>>>       parser_create = subparsers.add_parser('create',
>>> -- 
>>> 2.30.2
>>>
>>>
>>>
>>>
>>>
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#165330): 
>>> https://lists.openembedded.org/g/openembedded-core/message/165330
>>> Mute This Topic: https://lists.openembedded.org/mt/90928682/3616946
>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
>>> [mark.asselstine@windriver.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>

Patch

diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 824ac6350d..efcb82173e 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -1375,6 +1375,29 @@  def convert_rpm_xml(xmlfile):
                     values[varname] = child[0].text
     return values
 
+def ensure_native_cmd(tinfoil, cmd):
+    """Check if the command is available in the recipes"""
+    if not tinfoil.recipes_parsed:
+        tinfoil.parse_recipes()
+
+    try:
+        d = tinfoil.parse_recipe("%s-native" % cmd)
+    except bb.providers.NoProvider:
+        bb.error("Nothing provides '%s-native' which is required for the build" % cmd)
+        bb.note("You will likely need to add a layer that provides %s" % cmd)
+        sys.exit(14)
+
+    bindir = d.getVar("STAGING_BINDIR_NATIVE")
+    cmdpath = os.path.join(bindir, cmd)
+
+    if not os.path.exists(cmdpath):
+        tinfoil.build_targets("%s-native" % cmd, "addto_recipe_sysroot")
+
+        if not os.path.exists(cmdpath):
+            bb.error("Failed to add '%s' to sysroot" % cmd)
+            sys.exit(14)
+
+    return bindir
 
 def register_commands(subparsers):
     parser_create = subparsers.add_parser('create',