diff mbox series

Broken update image generation on gatesgarth

Message ID a202d4bf-05c0-4169-b459-967e5b41562dn@googlegroups.com
State Accepted
Headers show
Series Broken update image generation on gatesgarth | expand

Commit Message

Guy Morand Nov. 30, 2020, 11:45 a.m. UTC
Hallo swupdate developers!

Since Friday, I cannot generate an update image with yocto on gatesgarth 
branch:

File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_swuimage(d)
     0003:
File: 'meta-swupdate/classes/swupdate.bbclass', lineno: 104, function: 
do_swuimage
     0100:        local = fetch.localpath(url)
     0101:        filename = os.path.basename(local)
     0102:        if (filename != 'sw-description') and 
(os.path.isfile(local)):
     0103:            encrypted = 
(d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "")
 *** 0104:            key,iv,salt = 
swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
     0105:            dst = os.path.join(s, "%s" % filename )
     0106:            if encrypted == '1':
     0107:                bb.note("Encryption requested for %s" %(filename))
     0108:                swupdate_encrypt_file(local, dst, key, iv, salt)
File: 'meta-swupdate/classes/swupdate-common.bbclass', lineno: 23, 
function: swupdate_extract_keys
     0019:    return m.hexdigest()
     0020:
     0021:def swupdate_extract_keys(keyfile):
     0022:    try:
 *** 0023:        keys = open(keyfile)
     0024:    except IOError:
     0025:        bb.fatal("Failed to open file with keys %s" % (keyfile))
     0026:    lines = keys.read()
     0027:    keys.close()
Exception: TypeError: expected str, bytes or os.PathLike object, not 
NoneType

I could fix it with the following patch:
                 swupdate_encrypt_file(local, dst, key, iv, salt)
             else:
                 shutil.copyfile(local, dst)
@@ -148,7 +148,7 @@ python do_swuimage () {
                 if not image_found:
                     bb.fatal("swupdate cannot find image file: %s" % 
os.path.join(deploydir, imagebase + fstype))
         else:  # Allow also complete entries like "image.ext4.gz" in 
SWUPDATE_IMAGES
-            if not add_image_to_swu(deploydir, image, s):
+            if not add_image_to_swu(deploydir, image, s, encrypted):
                 bb.fatal("swupdate cannot find %s image file" % image)

     prepare_sw_description(d, s, list_for_cpio)

Not sure if I'm doing wrong and if this patch would make sense.

Any advice or should I prepare an pull request?

Best regards,

Guy

Comments

Stefano Babic Nov. 30, 2020, noon UTC | #1
Hi Guy,

On 30.11.20 12:45, Guy Morand wrote:
> Hallo swupdate developers!
> 
> Since Friday, I cannot generate an update image with yocto on gatesgarth
> branch:
> 

New patches merged.

> File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
>      0001:
>  *** 0002:do_swuimage(d)
>      0003:
> File: 'meta-swupdate/classes/swupdate.bbclass', lineno: 104, function:
> do_swuimage
>      0100:        local = fetch.localpath(url)
>      0101:        filename = os.path.basename(local)
>      0102:        if (filename != 'sw-description') and
> (os.path.isfile(local)):
>      0103:            encrypted =
> (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "")
>  *** 0104:            key,iv,salt =
> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>      0105:            dst = os.path.join(s, "%s" % filename )
>      0106:            if encrypted == '1':
>      0107:                bb.note("Encryption requested for %s" %(filename))
>      0108:                swupdate_encrypt_file(local, dst, key, iv, salt)
> File: 'meta-swupdate/classes/swupdate-common.bbclass', lineno: 23,
> function: swupdate_extract_keys
>      0019:    return m.hexdigest()
>      0020:
>      0021:def swupdate_extract_keys(keyfile):
>      0022:    try:
>  *** 0023:        keys = open(keyfile)
>      0024:    except IOError:
>      0025:        bb.fatal("Failed to open file with keys %s" % (keyfile))
>      0026:    lines = keys.read()
>      0027:    keys.close()
> Exception: TypeError: expected str, bytes or os.PathLike object, not
> NoneType
> 
> I could fix it with the following patch:
> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
> index b94955c..9a58436 100644
> --- a/classes/swupdate.bbclass
> +++ b/classes/swupdate.bbclass
> @@ -101,10 +101,10 @@ python do_swuimage () {
>          filename = os.path.basename(local)
>          if (filename != 'sw-description') and (os.path.isfile(local)):
>              encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED",
> filename, True) or "")
> -            key,iv,salt =
> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>              dst = os.path.join(s, "%s" % filename )
>              if encrypted == '1':
>                  bb.note("Encryption requested for %s" %(filename))
> +                key,iv,salt =
> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>                  swupdate_encrypt_file(local, dst, key, iv, salt)
>              else:
>                  shutil.copyfile(local, dst)
> @@ -148,7 +148,7 @@ python do_swuimage () {
>                  if not image_found:
>                      bb.fatal("swupdate cannot find image file: %s" %
> os.path.join(deploydir, imagebase + fstype))
>          else:  # Allow also complete entries like "image.ext4.gz" in
> SWUPDATE_IMAGES
> -            if not add_image_to_swu(deploydir, image, s):
> +            if not add_image_to_swu(deploydir, image, s, encrypted):
>                  bb.fatal("swupdate cannot find %s image file" % image)
> 
>      prepare_sw_description(d, s, list_for_cpio)
> 
> Not sure if I'm doing wrong and if this patch would make sense.
> 

It seems corrrect.

> Any advice or should I prepare an pull request?
> 

Pull request ? Please send a patch to this ML according to
http://sbabic.github.io/swupdate/contributing.html - thanks !

Best regards,
Stefano Babic

> Best regards,
> 
> Guy
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+unsubscribe@googlegroups.com
> <mailto:swupdate+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
Guy Morand Nov. 30, 2020, 12:24 p.m. UTC | #2
Hi Stefano,

Thanks for your quick reply!

> New patches merged.

Not sure if I understand well, do you mean the issue is due to new
patches or there is a new patch to fix the issue?

> Pull request ? Please send a patch to this ML according to
> http://sbabic.github.io/swupdate/contributing.html - thanks !

I just wanted to hear your opinion, I will do my best to send a patch
as described. I was working on gatesgarth branch, should I adapt for
master or how should I inform maintainer(s) that the patch is for
gatesgarth?

Best regards,

Guy

On Mon, Nov 30, 2020 at 1:00 PM Stefano Babic <sbabic@denx.de> wrote:
>
> Hi Guy,
>
> On 30.11.20 12:45, Guy Morand wrote:
> > Hallo swupdate developers!
> >
> > Since Friday, I cannot generate an update image with yocto on gatesgarth
> > branch:
> >
>
> New patches merged.
>
> > File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
> >      0001:
> >  *** 0002:do_swuimage(d)
> >      0003:
> > File: 'meta-swupdate/classes/swupdate.bbclass', lineno: 104, function:
> > do_swuimage
> >      0100:        local = fetch.localpath(url)
> >      0101:        filename = os.path.basename(local)
> >      0102:        if (filename != 'sw-description') and
> > (os.path.isfile(local)):
> >      0103:            encrypted =
> > (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "")
> >  *** 0104:            key,iv,salt =
> > swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
> >      0105:            dst = os.path.join(s, "%s" % filename )
> >      0106:            if encrypted == '1':
> >      0107:                bb.note("Encryption requested for %s" %(filename))
> >      0108:                swupdate_encrypt_file(local, dst, key, iv, salt)
> > File: 'meta-swupdate/classes/swupdate-common.bbclass', lineno: 23,
> > function: swupdate_extract_keys
> >      0019:    return m.hexdigest()
> >      0020:
> >      0021:def swupdate_extract_keys(keyfile):
> >      0022:    try:
> >  *** 0023:        keys = open(keyfile)
> >      0024:    except IOError:
> >      0025:        bb.fatal("Failed to open file with keys %s" % (keyfile))
> >      0026:    lines = keys.read()
> >      0027:    keys.close()
> > Exception: TypeError: expected str, bytes or os.PathLike object, not
> > NoneType
> >
> > I could fix it with the following patch:
> > diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
> > index b94955c..9a58436 100644
> > --- a/classes/swupdate.bbclass
> > +++ b/classes/swupdate.bbclass
> > @@ -101,10 +101,10 @@ python do_swuimage () {
> >          filename = os.path.basename(local)
> >          if (filename != 'sw-description') and (os.path.isfile(local)):
> >              encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED",
> > filename, True) or "")
> > -            key,iv,salt =
> > swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
> >              dst = os.path.join(s, "%s" % filename )
> >              if encrypted == '1':
> >                  bb.note("Encryption requested for %s" %(filename))
> > +                key,iv,salt =
> > swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
> >                  swupdate_encrypt_file(local, dst, key, iv, salt)
> >              else:
> >                  shutil.copyfile(local, dst)
> > @@ -148,7 +148,7 @@ python do_swuimage () {
> >                  if not image_found:
> >                      bb.fatal("swupdate cannot find image file: %s" %
> > os.path.join(deploydir, imagebase + fstype))
> >          else:  # Allow also complete entries like "image.ext4.gz" in
> > SWUPDATE_IMAGES
> > -            if not add_image_to_swu(deploydir, image, s):
> > +            if not add_image_to_swu(deploydir, image, s, encrypted):
> >                  bb.fatal("swupdate cannot find %s image file" % image)
> >
> >      prepare_sw_description(d, s, list_for_cpio)
> >
> > Not sure if I'm doing wrong and if this patch would make sense.
> >
>
> It seems corrrect.
>
> > Any advice or should I prepare an pull request?
> >
>
> Pull request ? Please send a patch to this ML according to
> http://sbabic.github.io/swupdate/contributing.html - thanks !
>
> Best regards,
> Stefano Babic
>
> > Best regards,
> >
> > Guy
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "swupdate" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to swupdate+unsubscribe@googlegroups.com
> > <mailto:swupdate+unsubscribe@googlegroups.com>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com
> > <https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
> --
> =====================================================================
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> =====================================================================
Stefano Babic Nov. 30, 2020, 12:27 p.m. UTC | #3
On 30.11.20 13:24, Guy Morand wrote:
> Hi Stefano,
> 
> Thanks for your quick reply!
> 
>> New patches merged.
> 
> Not sure if I understand well, do you mean the issue is due to new
> patches or there is a new patch to fix the issue?

New patch, encryption in swupdate class:

commit 44a454226065cb2fa8fa9d34562e1a641d7a67ae
Author: Stefano Babic <sbabic@denx.de>
Date:   Thu Nov 26 14:25:03 2020 +0100

    swupdate: encrypt artefact when building SWU



> 
>> Pull request ? Please send a patch to this ML according to
>> http://sbabic.github.io/swupdate/contributing.html - thanks !
> 
> I just wanted to hear your opinion, I will do my best to send a patch
> as described. I was working on gatesgarth branch, should I adapt for
> master or how should I inform maintainer(s) that the patch is for
> gatesgarth?

The maintainer is me and I considered myself informed ;-)

Nevermind, I have a patch fix this and another issue reported by someone
else, I am sending it now.

Best regards,
Stefano Babic

> 
> Best regards,
> 
> Guy
> 
> On Mon, Nov 30, 2020 at 1:00 PM Stefano Babic <sbabic@denx.de> wrote:
>>
>> Hi Guy,
>>
>> On 30.11.20 12:45, Guy Morand wrote:
>>> Hallo swupdate developers!
>>>
>>> Since Friday, I cannot generate an update image with yocto on gatesgarth
>>> branch:
>>>
>>
>> New patches merged.
>>
>>> File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
>>>      0001:
>>>  *** 0002:do_swuimage(d)
>>>      0003:
>>> File: 'meta-swupdate/classes/swupdate.bbclass', lineno: 104, function:
>>> do_swuimage
>>>      0100:        local = fetch.localpath(url)
>>>      0101:        filename = os.path.basename(local)
>>>      0102:        if (filename != 'sw-description') and
>>> (os.path.isfile(local)):
>>>      0103:            encrypted =
>>> (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "")
>>>  *** 0104:            key,iv,salt =
>>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>>>      0105:            dst = os.path.join(s, "%s" % filename )
>>>      0106:            if encrypted == '1':
>>>      0107:                bb.note("Encryption requested for %s" %(filename))
>>>      0108:                swupdate_encrypt_file(local, dst, key, iv, salt)
>>> File: 'meta-swupdate/classes/swupdate-common.bbclass', lineno: 23,
>>> function: swupdate_extract_keys
>>>      0019:    return m.hexdigest()
>>>      0020:
>>>      0021:def swupdate_extract_keys(keyfile):
>>>      0022:    try:
>>>  *** 0023:        keys = open(keyfile)
>>>      0024:    except IOError:
>>>      0025:        bb.fatal("Failed to open file with keys %s" % (keyfile))
>>>      0026:    lines = keys.read()
>>>      0027:    keys.close()
>>> Exception: TypeError: expected str, bytes or os.PathLike object, not
>>> NoneType
>>>
>>> I could fix it with the following patch:
>>> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
>>> index b94955c..9a58436 100644
>>> --- a/classes/swupdate.bbclass
>>> +++ b/classes/swupdate.bbclass
>>> @@ -101,10 +101,10 @@ python do_swuimage () {
>>>          filename = os.path.basename(local)
>>>          if (filename != 'sw-description') and (os.path.isfile(local)):
>>>              encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED",
>>> filename, True) or "")
>>> -            key,iv,salt =
>>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>>>              dst = os.path.join(s, "%s" % filename )
>>>              if encrypted == '1':
>>>                  bb.note("Encryption requested for %s" %(filename))
>>> +                key,iv,salt =
>>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>>>                  swupdate_encrypt_file(local, dst, key, iv, salt)
>>>              else:
>>>                  shutil.copyfile(local, dst)
>>> @@ -148,7 +148,7 @@ python do_swuimage () {
>>>                  if not image_found:
>>>                      bb.fatal("swupdate cannot find image file: %s" %
>>> os.path.join(deploydir, imagebase + fstype))
>>>          else:  # Allow also complete entries like "image.ext4.gz" in
>>> SWUPDATE_IMAGES
>>> -            if not add_image_to_swu(deploydir, image, s):
>>> +            if not add_image_to_swu(deploydir, image, s, encrypted):
>>>                  bb.fatal("swupdate cannot find %s image file" % image)
>>>
>>>      prepare_sw_description(d, s, list_for_cpio)
>>>
>>> Not sure if I'm doing wrong and if this patch would make sense.
>>>
>>
>> It seems corrrect.
>>
>>> Any advice or should I prepare an pull request?
>>>
>>
>> Pull request ? Please send a patch to this ML according to
>> http://sbabic.github.io/swupdate/contributing.html - thanks !
>>
>> Best regards,
>> Stefano Babic
>>
>>> Best regards,
>>>
>>> Guy
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "swupdate" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to swupdate+unsubscribe@googlegroups.com
>>> <mailto:swupdate+unsubscribe@googlegroups.com>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>>
>> --
>> =====================================================================
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
>> =====================================================================
> 
> 
>
Guy Morand Nov. 30, 2020, 12:36 p.m. UTC | #4
Hoo so disappointing, I wish I could have contributed... Alright then,
I can wait a little more!

Thanks and keep the great work!

Guy

On Mon, Nov 30, 2020 at 1:27 PM Stefano Babic <sbabic@denx.de> wrote:
>
> On 30.11.20 13:24, Guy Morand wrote:
> > Hi Stefano,
> >
> > Thanks for your quick reply!
> >
> >> New patches merged.
> >
> > Not sure if I understand well, do you mean the issue is due to new
> > patches or there is a new patch to fix the issue?
>
> New patch, encryption in swupdate class:
>
> commit 44a454226065cb2fa8fa9d34562e1a641d7a67ae
> Author: Stefano Babic <sbabic@denx.de>
> Date:   Thu Nov 26 14:25:03 2020 +0100
>
>     swupdate: encrypt artefact when building SWU
>
>
>
> >
> >> Pull request ? Please send a patch to this ML according to
> >> http://sbabic.github.io/swupdate/contributing.html - thanks !
> >
> > I just wanted to hear your opinion, I will do my best to send a patch
> > as described. I was working on gatesgarth branch, should I adapt for
> > master or how should I inform maintainer(s) that the patch is for
> > gatesgarth?
>
> The maintainer is me and I considered myself informed ;-)
>
> Nevermind, I have a patch fix this and another issue reported by someone
> else, I am sending it now.
>
> Best regards,
> Stefano Babic
>
> >
> > Best regards,
> >
> > Guy
> >
> > On Mon, Nov 30, 2020 at 1:00 PM Stefano Babic <sbabic@denx.de> wrote:
> >>
> >> Hi Guy,
> >>
> >> On 30.11.20 12:45, Guy Morand wrote:
> >>> Hallo swupdate developers!
> >>>
> >>> Since Friday, I cannot generate an update image with yocto on gatesgarth
> >>> branch:
> >>>
> >>
> >> New patches merged.
> >>
> >>> File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
> >>>      0001:
> >>>  *** 0002:do_swuimage(d)
> >>>      0003:
> >>> File: 'meta-swupdate/classes/swupdate.bbclass', lineno: 104, function:
> >>> do_swuimage
> >>>      0100:        local = fetch.localpath(url)
> >>>      0101:        filename = os.path.basename(local)
> >>>      0102:        if (filename != 'sw-description') and
> >>> (os.path.isfile(local)):
> >>>      0103:            encrypted =
> >>> (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "")
> >>>  *** 0104:            key,iv,salt =
> >>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
> >>>      0105:            dst = os.path.join(s, "%s" % filename )
> >>>      0106:            if encrypted == '1':
> >>>      0107:                bb.note("Encryption requested for %s" %(filename))
> >>>      0108:                swupdate_encrypt_file(local, dst, key, iv, salt)
> >>> File: 'meta-swupdate/classes/swupdate-common.bbclass', lineno: 23,
> >>> function: swupdate_extract_keys
> >>>      0019:    return m.hexdigest()
> >>>      0020:
> >>>      0021:def swupdate_extract_keys(keyfile):
> >>>      0022:    try:
> >>>  *** 0023:        keys = open(keyfile)
> >>>      0024:    except IOError:
> >>>      0025:        bb.fatal("Failed to open file with keys %s" % (keyfile))
> >>>      0026:    lines = keys.read()
> >>>      0027:    keys.close()
> >>> Exception: TypeError: expected str, bytes or os.PathLike object, not
> >>> NoneType
> >>>
> >>> I could fix it with the following patch:
> >>> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
> >>> index b94955c..9a58436 100644
> >>> --- a/classes/swupdate.bbclass
> >>> +++ b/classes/swupdate.bbclass
> >>> @@ -101,10 +101,10 @@ python do_swuimage () {
> >>>          filename = os.path.basename(local)
> >>>          if (filename != 'sw-description') and (os.path.isfile(local)):
> >>>              encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED",
> >>> filename, True) or "")
> >>> -            key,iv,salt =
> >>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
> >>>              dst = os.path.join(s, "%s" % filename )
> >>>              if encrypted == '1':
> >>>                  bb.note("Encryption requested for %s" %(filename))
> >>> +                key,iv,salt =
> >>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
> >>>                  swupdate_encrypt_file(local, dst, key, iv, salt)
> >>>              else:
> >>>                  shutil.copyfile(local, dst)
> >>> @@ -148,7 +148,7 @@ python do_swuimage () {
> >>>                  if not image_found:
> >>>                      bb.fatal("swupdate cannot find image file: %s" %
> >>> os.path.join(deploydir, imagebase + fstype))
> >>>          else:  # Allow also complete entries like "image.ext4.gz" in
> >>> SWUPDATE_IMAGES
> >>> -            if not add_image_to_swu(deploydir, image, s):
> >>> +            if not add_image_to_swu(deploydir, image, s, encrypted):
> >>>                  bb.fatal("swupdate cannot find %s image file" % image)
> >>>
> >>>      prepare_sw_description(d, s, list_for_cpio)
> >>>
> >>> Not sure if I'm doing wrong and if this patch would make sense.
> >>>
> >>
> >> It seems corrrect.
> >>
> >>> Any advice or should I prepare an pull request?
> >>>
> >>
> >> Pull request ? Please send a patch to this ML according to
> >> http://sbabic.github.io/swupdate/contributing.html - thanks !
> >>
> >> Best regards,
> >> Stefano Babic
> >>
> >>> Best regards,
> >>>
> >>> Guy
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "swupdate" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> >>> an email to swupdate+unsubscribe@googlegroups.com
> >>> <mailto:swupdate+unsubscribe@googlegroups.com>.
> >>> To view this discussion on the web visit
> >>> https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com
> >>> <https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
> >>
> >>
> >> --
> >> =====================================================================
> >> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> >> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> >> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> >> =====================================================================
> >
> >
> >
>
>
> --
> =====================================================================
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> =====================================================================
Stefano Babic Nov. 30, 2020, 12:42 p.m. UTC | #5
On 30.11.20 13:36, Guy Morand wrote:
> Hoo so disappointing, I wish I could have contributed...

Never mind, there will be so many chances to do it !

> Alright then,
> I can wait a little more!
> 

Patch on the way.

Best regards,
Stefano Babic

> Thanks and keep the great work!
> 
> Guy
> 
> On Mon, Nov 30, 2020 at 1:27 PM Stefano Babic <sbabic@denx.de> wrote:
>>
>> On 30.11.20 13:24, Guy Morand wrote:
>>> Hi Stefano,
>>>
>>> Thanks for your quick reply!
>>>
>>>> New patches merged.
>>>
>>> Not sure if I understand well, do you mean the issue is due to new
>>> patches or there is a new patch to fix the issue?
>>
>> New patch, encryption in swupdate class:
>>
>> commit 44a454226065cb2fa8fa9d34562e1a641d7a67ae
>> Author: Stefano Babic <sbabic@denx.de>
>> Date:   Thu Nov 26 14:25:03 2020 +0100
>>
>>     swupdate: encrypt artefact when building SWU
>>
>>
>>
>>>
>>>> Pull request ? Please send a patch to this ML according to
>>>> http://sbabic.github.io/swupdate/contributing.html - thanks !
>>>
>>> I just wanted to hear your opinion, I will do my best to send a patch
>>> as described. I was working on gatesgarth branch, should I adapt for
>>> master or how should I inform maintainer(s) that the patch is for
>>> gatesgarth?
>>
>> The maintainer is me and I considered myself informed ;-)
>>
>> Nevermind, I have a patch fix this and another issue reported by someone
>> else, I am sending it now.
>>
>> Best regards,
>> Stefano Babic
>>
>>>
>>> Best regards,
>>>
>>> Guy
>>>
>>> On Mon, Nov 30, 2020 at 1:00 PM Stefano Babic <sbabic@denx.de> wrote:
>>>>
>>>> Hi Guy,
>>>>
>>>> On 30.11.20 12:45, Guy Morand wrote:
>>>>> Hallo swupdate developers!
>>>>>
>>>>> Since Friday, I cannot generate an update image with yocto on gatesgarth
>>>>> branch:
>>>>>
>>>>
>>>> New patches merged.
>>>>
>>>>> File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
>>>>>      0001:
>>>>>  *** 0002:do_swuimage(d)
>>>>>      0003:
>>>>> File: 'meta-swupdate/classes/swupdate.bbclass', lineno: 104, function:
>>>>> do_swuimage
>>>>>      0100:        local = fetch.localpath(url)
>>>>>      0101:        filename = os.path.basename(local)
>>>>>      0102:        if (filename != 'sw-description') and
>>>>> (os.path.isfile(local)):
>>>>>      0103:            encrypted =
>>>>> (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "")
>>>>>  *** 0104:            key,iv,salt =
>>>>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>>>>>      0105:            dst = os.path.join(s, "%s" % filename )
>>>>>      0106:            if encrypted == '1':
>>>>>      0107:                bb.note("Encryption requested for %s" %(filename))
>>>>>      0108:                swupdate_encrypt_file(local, dst, key, iv, salt)
>>>>> File: 'meta-swupdate/classes/swupdate-common.bbclass', lineno: 23,
>>>>> function: swupdate_extract_keys
>>>>>      0019:    return m.hexdigest()
>>>>>      0020:
>>>>>      0021:def swupdate_extract_keys(keyfile):
>>>>>      0022:    try:
>>>>>  *** 0023:        keys = open(keyfile)
>>>>>      0024:    except IOError:
>>>>>      0025:        bb.fatal("Failed to open file with keys %s" % (keyfile))
>>>>>      0026:    lines = keys.read()
>>>>>      0027:    keys.close()
>>>>> Exception: TypeError: expected str, bytes or os.PathLike object, not
>>>>> NoneType
>>>>>
>>>>> I could fix it with the following patch:
>>>>> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
>>>>> index b94955c..9a58436 100644
>>>>> --- a/classes/swupdate.bbclass
>>>>> +++ b/classes/swupdate.bbclass
>>>>> @@ -101,10 +101,10 @@ python do_swuimage () {
>>>>>          filename = os.path.basename(local)
>>>>>          if (filename != 'sw-description') and (os.path.isfile(local)):
>>>>>              encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED",
>>>>> filename, True) or "")
>>>>> -            key,iv,salt =
>>>>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>>>>>              dst = os.path.join(s, "%s" % filename )
>>>>>              if encrypted == '1':
>>>>>                  bb.note("Encryption requested for %s" %(filename))
>>>>> +                key,iv,salt =
>>>>> swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
>>>>>                  swupdate_encrypt_file(local, dst, key, iv, salt)
>>>>>              else:
>>>>>                  shutil.copyfile(local, dst)
>>>>> @@ -148,7 +148,7 @@ python do_swuimage () {
>>>>>                  if not image_found:
>>>>>                      bb.fatal("swupdate cannot find image file: %s" %
>>>>> os.path.join(deploydir, imagebase + fstype))
>>>>>          else:  # Allow also complete entries like "image.ext4.gz" in
>>>>> SWUPDATE_IMAGES
>>>>> -            if not add_image_to_swu(deploydir, image, s):
>>>>> +            if not add_image_to_swu(deploydir, image, s, encrypted):
>>>>>                  bb.fatal("swupdate cannot find %s image file" % image)
>>>>>
>>>>>      prepare_sw_description(d, s, list_for_cpio)
>>>>>
>>>>> Not sure if I'm doing wrong and if this patch would make sense.
>>>>>
>>>>
>>>> It seems corrrect.
>>>>
>>>>> Any advice or should I prepare an pull request?
>>>>>
>>>>
>>>> Pull request ? Please send a patch to this ML according to
>>>> http://sbabic.github.io/swupdate/contributing.html - thanks !
>>>>
>>>> Best regards,
>>>> Stefano Babic
>>>>
>>>>> Best regards,
>>>>>
>>>>> Guy
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "swupdate" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to swupdate+unsubscribe@googlegroups.com
>>>>> <mailto:swupdate+unsubscribe@googlegroups.com>.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/swupdate/a202d4bf-05c0-4169-b459-967e5b41562dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>>
>>>>
>>>> --
>>>> =====================================================================
>>>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>>>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>>>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
>>>> =====================================================================
>>>
>>>
>>>
>>
>>
>> --
>> =====================================================================
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
>> =====================================================================
> 
> 
>
diff mbox series

Patch

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index b94955c..9a58436 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -101,10 +101,10 @@  python do_swuimage () {
         filename = os.path.basename(local)
         if (filename != 'sw-description') and (os.path.isfile(local)):
             encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", 
filename, True) or "")
-            key,iv,salt = 
swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))
             dst = os.path.join(s, "%s" % filename )
             if encrypted == '1':
                 bb.note("Encryption requested for %s" %(filename))
+                key,iv,salt = 
swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True))