[Buildroot] [PATCH 1/1] package/ca-certificates: use host-python

Martin Bark martin at barkynet.com
Wed May 4 10:06:53 UTC 2016


Arnout,

On 3 May 2016 at 18:28, Arnout Vandecappelle <arnout at mind.be> wrote:
> On 05/03/16 13:46, Martin Bark wrote:
>>
>> The ca-certificates Makefile directly calls python and hence does not
>> pickup the buildroot host-python.
>
>
>  Not entirely accurate, I think (didn't check with the autobuild failure
> output, but this is my guess based on the source). I think it does use
> host-python because that comes first in the path. However, at that point,
> host-python is symlinked to python3 instead of python2.

No it's not using python3, certdata2pem.py worked fine with python3
when i tested.  That was my first thought too but as you can see in
the error below it's using python 2.6 off the host.

Traceback (most recent call last):
  File "certdata2pem.py", line 152, in <module>
    encoded = base64.b64encode(obj['CKA_VALUE']).decode('utf-8')
  File "/usr/lib/python2.6/base64.py", line 53, in b64encode
    encoded = binascii.b2a_base64(s)[:-1]
TypeError: b2a_base64() argument 1 must be string or read-only buffer,
not bytearray


you're right it should be picking up the host-python from PATH but
it's clearly not.  I had a deeper look and I now i understand the
issue more.  The steps are as follows:

 - you need to select python3
 - when host-python builds it detects python3 is going to be installed
to the target so does not setup a symlink to
$(HOST_DIR)/usr/bin/python
 - ca-certificates builds and but no $(HOST_DIR)/usr/bin/python exists
so it uses the hosts own python version
 - since the auto build server has python 2.6 installed the script
uses this and fails.
 - To see this error ca-certificates needs to be built before a
package that depends on host-python3 because if
$(HOST_DIR)/usr/bin/python points to python3 then certdata2pem.py will
work fine.

So the fix is using $(HOST_DIR)/usr/bin/python2 and not relying on
$(HOST_DIR)/usr/bin/python existing.  Since you can't rely on
$(HOST_DIR)/usr/bin/python existing or being a particular version of
python I'm wondering why is it even be created?

I'll update my comments and resubmit

>
>>
>> During the build all the Makefile does is execute mozilla/certdata2pem.py.
>> Simplify the build process by directly calling this script using
>> host-python.
>
>
>  While you're at it, you could also add a comment to the code why
> host-python is needed (i.e. why system python is not OK). I couldn't find a
> reference to that in the logs. Something like:
>
> # certdata2pem.py needs python2.7 - not python2.6, not python3. So system
> # can't be used.

Yes that's a good idea, I'll add that comment it needs at least
python2.7 and resubmit.

Thanks

Martin


>
>  With that:
>
> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>
>
>  Regards,
>  Arnout
>
>>
>> This fixes:
>>
>> http://autobuild.buildroot.net/results/a2a4fed293c836b9cf63ff2aaa463b0704dec07e/
>>
>> http://autobuild.buildroot.net/results/bbed4afa8e30382b8892062f31ba64cbb0ea14e4/
>>
>> http://autobuild.buildroot.net/results/1af5562be3c0d233cea81834a898f7ac6ae48271/
>>
>> Signed-off-by: Martin Bark <martin at barkynet.com>
>>
>> ---
>> Note: to reproduce the auto build errors you need to have python 2.6
>> installed on the host.
>> ---
>>  package/ca-certificates/ca-certificates.mk | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/package/ca-certificates/ca-certificates.mk
>> b/package/ca-certificates/ca-certificates.mk
>> index da1b70d..8a3389f 100644
>> --- a/package/ca-certificates/ca-certificates.mk
>> +++ b/package/ca-certificates/ca-certificates.mk
>> @@ -12,7 +12,8 @@ CA_CERTIFICATES_LICENSE = GPLv2+ (script), MPLv2.0
>> (data)
>>  CA_CERTIFICATES_LICENSE_FILES = debian/copyright
>>
>>  define CA_CERTIFICATES_BUILD_CMDS
>> -       $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) all
>> +       cd $(@D)/mozilla ;\
>> +               $(HOST_DIR)/usr/bin/python2 ./certdata2pem.py
>>  endef
>>
>>  define CA_CERTIFICATES_INSTALL_TARGET_CMDS
>>
>
>
> --
> Arnout Vandecappelle                          arnout at mind be
> Senior Embedded Software Architect            +32-16-286500
> Essensium/Mind                                http://www.mind.be
> G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
> LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
> GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF



More information about the buildroot mailing list