diff mbox series

qemuboot: Fix NoneType error in do_write_qemuboot_conf

Message ID 20220209095307.4080727-1-zboszor@pr.hu
State New
Headers show
Series qemuboot: Fix NoneType error in do_write_qemuboot_conf | expand

Commit Message

Böszörményi Zoltán Feb. 9, 2022, 9:53 a.m. UTC
From: Zoltán Böszörményi <zboszor@gmail.com>

I got this error on current master:

File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_write_qemuboot_conf(d)
     0003:
File: '.../layers/openembedded-core/meta/classes/qemuboot.bbclass', lineno: 141, function: do_write_qemuboot_conf
     0137:        else:
     0138:            val = d.getVar(k)
     0139:        # we only want to write out relative paths so that we can relocate images
     0140:        # and still run them
 *** 0141:        if val.startswith(topdir):
     0142:            val = os.path.relpath(val, finalpath)
     0143:        cf.set('config_bsp', k, '%s' % val)
     0144:
     0145:    # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
Exception: AttributeError: 'NoneType' object has no attribute 'startswith'

Do nothing if "val" is None.

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
 meta/classes/qemuboot.bbclass | 2 ++
 1 file changed, 2 insertions(+)

Comments

Böszörményi Zoltán Feb. 9, 2022, 10:53 a.m. UTC | #1
(Resending from the address I am subscribed with.)

I have no idea.

It was working a week ago for me but today after "repo sync"
the image build failed on me with the quoted error.

With this fix, the image is built with the expected contents.

The change with "if val.startswith()" was from 2017,
something around it must have changed very recently.

Zoltán

2022. 02. 09. 11:35 keltezéssel, Alexander Kanavin írta:
> Wait, why val is none in the first place? Why aren't others seeing it?
> 
> Alex
> 
> On Wed, 9 Feb 2022 at 10:53, Zoltan Boszormenyi via
> lists.openembedded.org <zboszor=pr.hu@lists.openembedded.org> wrote:
>>
>> From: Zoltán Böszörményi <zboszor@gmail.com>
>>
>> I got this error on current master:
>>
>> File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
>>       0001:
>>   *** 0002:do_write_qemuboot_conf(d)
>>       0003:
>> File: '.../layers/openembedded-core/meta/classes/qemuboot.bbclass', lineno: 141, function: do_write_qemuboot_conf
>>       0137:        else:
>>       0138:            val = d.getVar(k)
>>       0139:        # we only want to write out relative paths so that we can relocate images
>>       0140:        # and still run them
>>   *** 0141:        if val.startswith(topdir):
>>       0142:            val = os.path.relpath(val, finalpath)
>>       0143:        cf.set('config_bsp', k, '%s' % val)
>>       0144:
>>       0145:    # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
>> Exception: AttributeError: 'NoneType' object has no attribute 'startswith'
>>
>> Do nothing if "val" is None.
>>
>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>> ---
>>   meta/classes/qemuboot.bbclass | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
>> index 229bd88527..755d49acd6 100644
>> --- a/meta/classes/qemuboot.bbclass
>> +++ b/meta/classes/qemuboot.bbclass
>> @@ -136,6 +136,8 @@ python do_write_qemuboot_conf() {
>>                                  'qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/')
>>           else:
>>               val = d.getVar(k)
>> +        if val is None:
>> +            continue
>>           # we only want to write out relative paths so that we can relocate images
>>           # and still run them
>>           if val.startswith(topdir):
>> --
>> 2.34.1
>>
>>
>> 
>>
Böszörményi Zoltán Feb. 9, 2022, 2:55 p.m. UTC | #2
I have added a bb.error line to print the value of "k".
It's "UNINATIVE_LOADER".

I am not touching this variable in my custom distro layer. Should I?

Zoltán

2022. 02. 09. 11:56 keltezéssel, Alexander Kanavin írta:
> Right, but this might be fixing the symptom, and not the problem.
> 
> Alex
> 
> On Wed, 9 Feb 2022 at 11:53, Böszörményi Zoltán <zboszor@pr.hu> wrote:
>>
>> (Resending from the address I am subscribed with.)
>>
>> I have no idea.
>>
>> It was working a week ago for me but today after "repo sync"
>> the image build failed on me with the quoted error.
>>
>> With this fix, the image is built with the expected contents.
>>
>> The change with "if val.startswith()" was from 2017,
>> something around it must have changed very recently.
>>
>> Zoltán
>>
>> 2022. 02. 09. 11:35 keltezéssel, Alexander Kanavin írta:
>>> Wait, why val is none in the first place? Why aren't others seeing it?
>>>
>>> Alex
>>>
>>> On Wed, 9 Feb 2022 at 10:53, Zoltan Boszormenyi via
>>> lists.openembedded.org <zboszor=pr.hu@lists.openembedded.org> wrote:
>>>>
>>>> From: Zoltán Böszörményi <zboszor@gmail.com>
>>>>
>>>> I got this error on current master:
>>>>
>>>> File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
>>>>        0001:
>>>>    *** 0002:do_write_qemuboot_conf(d)
>>>>        0003:
>>>> File: '.../layers/openembedded-core/meta/classes/qemuboot.bbclass', lineno: 141, function: do_write_qemuboot_conf
>>>>        0137:        else:
>>>>        0138:            val = d.getVar(k)
>>>>        0139:        # we only want to write out relative paths so that we can relocate images
>>>>        0140:        # and still run them
>>>>    *** 0141:        if val.startswith(topdir):
>>>>        0142:            val = os.path.relpath(val, finalpath)
>>>>        0143:        cf.set('config_bsp', k, '%s' % val)
>>>>        0144:
>>>>        0145:    # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
>>>> Exception: AttributeError: 'NoneType' object has no attribute 'startswith'
>>>>
>>>> Do nothing if "val" is None.
>>>>
>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>> ---
>>>>    meta/classes/qemuboot.bbclass | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
>>>> index 229bd88527..755d49acd6 100644
>>>> --- a/meta/classes/qemuboot.bbclass
>>>> +++ b/meta/classes/qemuboot.bbclass
>>>> @@ -136,6 +136,8 @@ python do_write_qemuboot_conf() {
>>>>                                   'qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/')
>>>>            else:
>>>>                val = d.getVar(k)
>>>> +        if val is None:
>>>> +            continue
>>>>            # we only want to write out relative paths so that we can relocate images
>>>>            # and still run them
>>>>            if val.startswith(topdir):
>>>> --
>>>> 2.34.1
>>>>
>>>>
>>>> 
>>>>
>>
Böszörményi Zoltán Feb. 9, 2022, 3:27 p.m. UTC | #3
I guess this commit below is what broke the image build for me,
as it added UNINATIVE_LOADER handling to qemuboot.bbclass.

commit 39c10816d5ec9d9c7952d786d7a3f942d25d0c27
Author: Alexander Kanavin <alex@linutronix.de>
Date:   Fri Feb 4 20:59:43 2022 +0100

     runqemu: preload uninative libraries when host gl drivers are in use

     Some of the host distributions build the drivers in a way (RPATH/RUNPATH)
     that tricks uninative loader into loading pieces of the host libc, if
     the same pieces haven't been previously loaded by native binaries. Mixing
     the two libc versions leads to failures.

     This change ensures that the correct (uninative) versions are always in use.

     Signed-off-by: Alexander Kanavin <alex@linutronix.de>
     Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>


Zoltán

2022. 02. 09. 15:55 keltezéssel, Zoltan Boszormenyi via lists.openembedded.org írta:
> I have added a bb.error line to print the value of "k".
> It's "UNINATIVE_LOADER".
> 
> I am not touching this variable in my custom distro layer. Should I?
> 
> Zoltán
> 
> 2022. 02. 09. 11:56 keltezéssel, Alexander Kanavin írta:
>> Right, but this might be fixing the symptom, and not the problem.
>>
>> Alex
>>
>> On Wed, 9 Feb 2022 at 11:53, Böszörményi Zoltán <zboszor@pr.hu> wrote:
>>>
>>> (Resending from the address I am subscribed with.)
>>>
>>> I have no idea.
>>>
>>> It was working a week ago for me but today after "repo sync"
>>> the image build failed on me with the quoted error.
>>>
>>> With this fix, the image is built with the expected contents.
>>>
>>> The change with "if val.startswith()" was from 2017,
>>> something around it must have changed very recently.
>>>
>>> Zoltán
>>>
>>> 2022. 02. 09. 11:35 keltezéssel, Alexander Kanavin írta:
>>>> Wait, why val is none in the first place? Why aren't others seeing it?
>>>>
>>>> Alex
>>>>
>>>> On Wed, 9 Feb 2022 at 10:53, Zoltan Boszormenyi via
>>>> lists.openembedded.org <zboszor=pr.hu@lists.openembedded.org> wrote:
>>>>>
>>>>> From: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>
>>>>> I got this error on current master:
>>>>>
>>>>> File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
>>>>>        0001:
>>>>>    *** 0002:do_write_qemuboot_conf(d)
>>>>>        0003:
>>>>> File: '.../layers/openembedded-core/meta/classes/qemuboot.bbclass', lineno: 141, 
>>>>> function: do_write_qemuboot_conf
>>>>>        0137:        else:
>>>>>        0138:            val = d.getVar(k)
>>>>>        0139:        # we only want to write out relative paths so that we can 
>>>>> relocate images
>>>>>        0140:        # and still run them
>>>>>    *** 0141:        if val.startswith(topdir):
>>>>>        0142:            val = os.path.relpath(val, finalpath)
>>>>>        0143:        cf.set('config_bsp', k, '%s' % val)
>>>>>        0144:
>>>>>        0145:    # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
>>>>> Exception: AttributeError: 'NoneType' object has no attribute 'startswith'
>>>>>
>>>>> Do nothing if "val" is None.
>>>>>
>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>> ---
>>>>>    meta/classes/qemuboot.bbclass | 2 ++
>>>>>    1 file changed, 2 insertions(+)
>>>>>
>>>>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
>>>>> index 229bd88527..755d49acd6 100644
>>>>> --- a/meta/classes/qemuboot.bbclass
>>>>> +++ b/meta/classes/qemuboot.bbclass
>>>>> @@ -136,6 +136,8 @@ python do_write_qemuboot_conf() {
>>>>>                                   
>>>>> 'qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/')
>>>>>            else:
>>>>>                val = d.getVar(k)
>>>>> +        if val is None:
>>>>> +            continue
>>>>>            # we only want to write out relative paths so that we can relocate images
>>>>>            # and still run them
>>>>>            if val.startswith(topdir):
>>>>> -- 
>>>>> 2.34.1
>>>>>
>>>>>
>>>>>
>>>>>
>>>
> 
> 
> 
> 
>
diff mbox series

Patch

diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index 229bd88527..755d49acd6 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -136,6 +136,8 @@  python do_write_qemuboot_conf() {
                                'qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/')
         else:
             val = d.getVar(k)
+        if val is None:
+            continue
         # we only want to write out relative paths so that we can relocate images
         # and still run them
         if val.startswith(topdir):