diff mbox series

[meta-swupdate,v2,2/2] swupdate-image: use image link name

Message ID 20211108160840.61647-3-adrian.freihofer@siemens.com
State Accepted
Headers show
Series fix build-time signing issues | expand

Commit Message

Adrian Freihofer Nov. 8, 2021, 4:08 p.m. UTC
Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME contains a
timestamp which causes some sporadic build failures. The problem is that
if the image files have been built by a previous bitbake call and bitbake
skips the task to build them again swupdate fails with searching for images
with the timestamp of the current build job in the file name. The link
refers to the latest available build in any case.

Setting S to WORKDIR should not be needed. It's the default from
bitbake.conf.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 classes/swupdate-image.bbclass | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Stefano Babic Nov. 22, 2021, 12:07 p.m. UTC | #1
Hi Adrian,

On 08.11.21 17:08, Adrian Freihofer wrote:
> Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME contains a
> timestamp which causes some sporadic build failures. The problem is that
> if the image files have been built by a previous bitbake call and bitbake
> skips the task to build them again swupdate fails with searching for images
> with the timestamp of the current build job in the file name. The link
> refers to the latest available build in any case.
> 
> Setting S to WORKDIR should not be needed. It's the default from
> bitbake.conf.
> 
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>   classes/swupdate-image.bbclass | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/classes/swupdate-image.bbclass b/classes/swupdate-image.bbclass
> index d405fe1..de9ee1f 100644
> --- a/classes/swupdate-image.bbclass
> +++ b/classes/swupdate-image.bbclass
> @@ -10,17 +10,14 @@
>   
>   inherit swupdate-common.bbclass
>   
> -S = "${WORKDIR}/${PN}"
> -
>   SRC_URI += "file://sw-description"
> -SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
> +SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
>   
>   python do_swupdate_copy_swdescription() {
> -
>       import shutil
>   
>       workdir = d.getVar('S', True)
> -    image = d.getVar('IMAGE_BASENAME', True)
> +    image = d.getVar('IMAGE_LINK_NAME', True)
>       filespath = d.getVar('FILESPATH')
>       sw_desc_path = bb.utils.which(filespath, "sw-description")
>       shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
> 

I received today after yesterday's merge several reports from users 
because CI breaks. I can reproduce it on one running project of mine, 
and this is caused because IMAGE_LINK_NAME contains the MACHINE name. 
Then all  SWUPDATE_IMAGES_FSTYPES[] are wrong, because with this patch 
the class is looking for SWUPDATE_IMAGES_FSTYPES[imagename-machine] 
instead of SWUPDATE_IMAGES_FSTYPES[imagename]. I had to revert it for now.

Best regards,
Stefano Babic
Jyothi K Nov. 23, 2021, 7:45 a.m. UTC | #2
Hi Stefano,

The signing changes done in the swupdate-common.bbclass with poepen is 
causing an issue for me since I use CUSTOM signing for my images.
I would prefer to use os.system. I will create a patch for this.

Thanks,
Jyothi

On Monday, November 22, 2021 at 5:37:41 PM UTC+5:30 Stefano Babic wrote:

> Hi Adrian,
>
> On 08.11.21 17:08, Adrian Freihofer wrote:
> > Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME contains a
> > timestamp which causes some sporadic build failures. The problem is that
> > if the image files have been built by a previous bitbake call and bitbake
> > skips the task to build them again swupdate fails with searching for 
> images
> > with the timestamp of the current build job in the file name. The link
> > refers to the latest available build in any case.
> > 
> > Setting S to WORKDIR should not be needed. It's the default from
> > bitbake.conf.
> > 
> > Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
> > ---
> > classes/swupdate-image.bbclass | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/classes/swupdate-image.bbclass 
> b/classes/swupdate-image.bbclass
> > index d405fe1..de9ee1f 100644
> > --- a/classes/swupdate-image.bbclass
> > +++ b/classes/swupdate-image.bbclass
> > @@ -10,17 +10,14 @@
> > 
> > inherit swupdate-common.bbclass
> > 
> > -S = "${WORKDIR}/${PN}"
> > -
> > SRC_URI += "file://sw-description"
> > -SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
> > +SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
> > 
> > python do_swupdate_copy_swdescription() {
> > -
> > import shutil
> > 
> > workdir = d.getVar('S', True)
> > - image = d.getVar('IMAGE_BASENAME', True)
> > + image = d.getVar('IMAGE_LINK_NAME', True)
> > filespath = d.getVar('FILESPATH')
> > sw_desc_path = bb.utils.which(filespath, "sw-description")
> > shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
> > 
>
> I received today after yesterday's merge several reports from users 
> because CI breaks. I can reproduce it on one running project of mine, 
> and this is caused because IMAGE_LINK_NAME contains the MACHINE name. 
> Then all SWUPDATE_IMAGES_FSTYPES[] are wrong, because with this patch 
> the class is looking for SWUPDATE_IMAGES_FSTYPES[imagename-machine] 
> instead of SWUPDATE_IMAGES_FSTYPES[imagename]. I had to revert it for now.
>
> Best regards,
> Stefano Babic
>
> -- 
> =====================================================================
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 <+49%208142%206698953> Fax: +49-8142-66989-80 
> <+49%208142%206698980> Email: sba...@denx.de
> =====================================================================
>
Stefano Babic Nov. 23, 2021, 8:19 a.m. UTC | #3
Hi Jyothi,

On 23.11.21 08:45, Jyothi K wrote:
> Hi Stefano,
> 
> The signing changes done in the swupdate-common.bbclass with poepen is 
> causing an issue for me since I use CUSTOM signing for my images.

Can you describe which is the issue, how you sign (which tool / which 
command you set), so that this can be discussed here ?

> I would prefer to use os.system. I will create a patch for this.

Ok

Best regards,
Stefano Babic

> 
> Thanks,
> Jyothi
> 
> On Monday, November 22, 2021 at 5:37:41 PM UTC+5:30 Stefano Babic wrote:
> 
>     Hi Adrian,
> 
>     On 08.11.21 17:08, Adrian Freihofer wrote:
>      > Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME
>     contains a
>      > timestamp which causes some sporadic build failures. The problem
>     is that
>      > if the image files have been built by a previous bitbake call and
>     bitbake
>      > skips the task to build them again swupdate fails with searching
>     for images
>      > with the timestamp of the current build job in the file name. The
>     link
>      > refers to the latest available build in any case.
>      >
>      > Setting S to WORKDIR should not be needed. It's the default from
>      > bitbake.conf.
>      >
>      > Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
>      > ---
>      > classes/swupdate-image.bbclass | 7 ++-----
>      > 1 file changed, 2 insertions(+), 5 deletions(-)
>      >
>      > diff --git a/classes/swupdate-image.bbclass
>     b/classes/swupdate-image.bbclass
>      > index d405fe1..de9ee1f 100644
>      > --- a/classes/swupdate-image.bbclass
>      > +++ b/classes/swupdate-image.bbclass
>      > @@ -10,17 +10,14 @@
>      >
>      > inherit swupdate-common.bbclass
>      >
>      > -S = "${WORKDIR}/${PN}"
>      > -
>      > SRC_URI += "file://sw-description"
>      > -SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
>      > +SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
>      >
>      > python do_swupdate_copy_swdescription() {
>      > -
>      > import shutil
>      >
>      > workdir = d.getVar('S', True)
>      > - image = d.getVar('IMAGE_BASENAME', True)
>      > + image = d.getVar('IMAGE_LINK_NAME', True)
>      > filespath = d.getVar('FILESPATH')
>      > sw_desc_path = bb.utils.which(filespath, "sw-description")
>      > shutil.copyfile(sw_desc_path, os.path.join(workdir,
>     "sw-description"))
>      >
> 
>     I received today after yesterday's merge several reports from users
>     because CI breaks. I can reproduce it on one running project of mine,
>     and this is caused because IMAGE_LINK_NAME contains the MACHINE name.
>     Then all SWUPDATE_IMAGES_FSTYPES[] are wrong, because with this patch
>     the class is looking for SWUPDATE_IMAGES_FSTYPES[imagename-machine]
>     instead of SWUPDATE_IMAGES_FSTYPES[imagename]. I had to revert it
>     for now.
> 
>     Best regards,
>     Stefano Babic
> 
>     -- 
>     =====================================================================
>     DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
>     HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>     Phone: +49-8142-66989-53 <tel:+49%208142%206698953> Fax:
>     +49-8142-66989-80 <tel:+49%208142%206698980> Email: sba...@denx.de
>     =====================================================================
> 
> -- 
> 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/74fdd5e6-d45c-4619-ae81-9d7fdcfebfc0n%40googlegroups.com 
> <https://groups.google.com/d/msgid/swupdate/74fdd5e6-d45c-4619-ae81-9d7fdcfebfc0n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Adrian Freihofer Nov. 23, 2021, 6 p.m. UTC | #4
Hi Stefano

I am not sure if my patch is wrong or if some autobuilders should be fixed. 
The swupdate-image.bbclass is supposed to add the image artifact of the 
currently created image to the swu archive. There are two ways I can see to 
get this working: Either using the IMAGE_NAME variable or using the 
IMAGE_LINK_NAME variable. These two variables refer to the files created by 
bitbake. Using IMAGE_LINK_NAME makes probably more sense.

Using other variables can work if they happen to have the same value as 
IMAGE_LINK_NAME. In the case of swupdate-image.bbclass, IMAGE_BASENAME 
works as long as IMAGE_LINK_NAME is set to its default value. But there are 
many reasons why one needs to set IMAGE_LINK_NAME differently.

I don't know what kind of issues these autobuilders have. But I think 

SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"

should be the default artifact added by swupdate-image.bbclass. Might be 
that this should be overwriteable for special use cases like

SWUPDATE_DEFAULT_IMAGE ?= "${IMAGE_LINK_NAME}"
SWUPDATE_IMAGES += "${SWUPDATE_DEFAULT_IMAGE}"

An implementation like

SWUPDATE_DEFAULT_IMAGE ?= "${IMAGE_BASENAME}"
SWUPDATE_IMAGES += "${SWUPDATE_DEFAULT_IMAGE}"

might be the compromise. It would allow me to overwrite it and be backward 
compatible for other use cases.
Currently swupdate-image.bbclass is not usable for us.

Thank you for the feedback.
Regards,
Adrian

Stefano Babic schrieb am Montag, 22. November 2021 um 13:07:41 UTC+1:

> Hi Adrian,
>
> On 08.11.21 17:08, Adrian Freihofer wrote:
> > Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME contains a
> > timestamp which causes some sporadic build failures. The problem is that
> > if the image files have been built by a previous bitbake call and bitbake
> > skips the task to build them again swupdate fails with searching for 
> images
> > with the timestamp of the current build job in the file name. The link
> > refers to the latest available build in any case.
> > 
> > Setting S to WORKDIR should not be needed. It's the default from
> > bitbake.conf.
> > 
> > Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
> > ---
> > classes/swupdate-image.bbclass | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/classes/swupdate-image.bbclass 
> b/classes/swupdate-image.bbclass
> > index d405fe1..de9ee1f 100644
> > --- a/classes/swupdate-image.bbclass
> > +++ b/classes/swupdate-image.bbclass
> > @@ -10,17 +10,14 @@
> > 
> > inherit swupdate-common.bbclass
> > 
> > -S = "${WORKDIR}/${PN}"
> > -
> > SRC_URI += "file://sw-description"
> > -SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
> > +SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
> > 
> > python do_swupdate_copy_swdescription() {
> > -
> > import shutil
> > 
> > workdir = d.getVar('S', True)
> > - image = d.getVar('IMAGE_BASENAME', True)
> > + image = d.getVar('IMAGE_LINK_NAME', True)
> > filespath = d.getVar('FILESPATH')
> > sw_desc_path = bb.utils.which(filespath, "sw-description")
> > shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
> > 
>
> I received today after yesterday's merge several reports from users 
> because CI breaks. I can reproduce it on one running project of mine, 
> and this is caused because IMAGE_LINK_NAME contains the MACHINE name. 
> Then all SWUPDATE_IMAGES_FSTYPES[] are wrong, because with this patch 
> the class is looking for SWUPDATE_IMAGES_FSTYPES[imagename-machine] 
> instead of SWUPDATE_IMAGES_FSTYPES[imagename]. I had to revert it for now.
>
> Best regards,
> Stefano Babic
>
> -- 
> =====================================================================
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 <+49%208142%206698953> Fax: +49-8142-66989-80 
> <+49%208142%206698980> Email: sba...@denx.de
> =====================================================================
>
Stefano Babic Nov. 23, 2021, 9:30 p.m. UTC | #5
Hi Adrian,

On 23.11.21 19:00, Adrian Freihofer wrote:
> Hi Stefano
> 
> I am not sure if my patch is wrong 

I cannot say if it is wrong, but I got in the morning several reports 
that current builds were broken. On a couple of project of mine, I could 
see this is due to the change in the name for the flag 
SWUPDATE_IMAGES_FSTYPES.

> or if some autobuilders should be 
> fixed. The swupdate-image.bbclass is supposed to add the image artifact 
> of the currently created image to the swu archive.
> There are two ways I 
> can see to get this working: Either using the IMAGE_NAME variable or 
> using the IMAGE_LINK_NAME variable. These two variables refer to the 
> files created by bitbake. Using IMAGE_LINK_NAME makes probably more sense.
> 
> Using other variables can work if they happen to have the same value as 
> IMAGE_LINK_NAME. In the case of swupdate-image.bbclass, IMAGE_BASENAME 
> works as long as IMAGE_LINK_NAME is set to its default value. But there 
> are many reasons why one needs to set IMAGE_LINK_NAME differently.

Then we need an another way to let set in a consistent way the flags 
used by the generation of SWU, like SWUPDATE_IMAGES_FSTYPES[] or 
SWUPDATE_IMAGES_NOAPPEND_MACHINE[].

This patch will ask to set the flag as 
SWUPDATE_IMAGES_FSTYPES[${IMAGE_LINK_NAME}], that is 
SWUPDATE_IMAGES_FSTYPES[${IMAGE_BASE_NAME}-${MACHINE}] when default is 
applied. This is inconsistent because I cannto reuse the same recipe for 
multiple MACHINEs, or I have to add FSTYPES for each machine even if 
they are the same.

> 
> I don't know what kind of issues these autobuilders have. But I think
> 
> SWUPDATE_IMAGES+= "${IMAGE_LINK_NAME}"
> 
> should be the default artifact added by swupdate-image.bbclass.

Issue is caused because flags are missing. Image recipe sets the flag, 
and it is for example SWUPDATE_IMAGE_FSTYPE[core-image]. When patch is 
applied, class search for SWUPDATE_IMAGE_FSTYPES[core-image-machine]. It 
is not set, build stops. We could also say that it was changed, and 
please update the own recipe, but having the flag set with the machine 
is a no way.

> Might be 
> that this should be overwriteable for special use cases like
> 
> SWUPDATE_DEFAULT_IMAGE ?= "${IMAGE_LINK_NAME}"
> SWUPDATE_IMAGES+= "${SWUPDATE_DEFAULT_IMAGE}"
> 
> An implementation like
> 
> SWUPDATE_DEFAULT_IMAGE ?= "${IMAGE_BASENAME}"
> SWUPDATE_IMAGES+= "${SWUPDATE_DEFAULT_IMAGE}"
> 
> might be the compromise. It would allow me to overwrite it and be 
> backward compatible for other use cases.
> Currently swupdate-image.bbclass is not usable for us.

Ok, it works in your case because you are overwriting IMAGE_LINK_NAME. I 
am fine if the flags are then set accordingly.

Best regards,
Stefano

> 
> Thank you for the feedback.
> Regards,
> Adrian
> 
> Stefano Babic schrieb am Montag, 22. November 2021 um 13:07:41 UTC+1:
> 
>     Hi Adrian,
> 
>     On 08.11.21 17:08, Adrian Freihofer wrote:
>      > Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME
>     contains a
>      > timestamp which causes some sporadic build failures. The problem
>     is that
>      > if the image files have been built by a previous bitbake call and
>     bitbake
>      > skips the task to build them again swupdate fails with searching
>     for images
>      > with the timestamp of the current build job in the file name. The
>     link
>      > refers to the latest available build in any case.
>      >
>      > Setting S to WORKDIR should not be needed. It's the default from
>      > bitbake.conf.
>      >
>      > Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
>      > ---
>      > classes/swupdate-image.bbclass | 7 ++-----
>      > 1 file changed, 2 insertions(+), 5 deletions(-)
>      >
>      > diff --git a/classes/swupdate-image.bbclass
>     b/classes/swupdate-image.bbclass
>      > index d405fe1..de9ee1f 100644
>      > --- a/classes/swupdate-image.bbclass
>      > +++ b/classes/swupdate-image.bbclass
>      > @@ -10,17 +10,14 @@
>      >
>      > inherit swupdate-common.bbclass
>      >
>      > -S = "${WORKDIR}/${PN}"
>      > -
>      > SRC_URI += "file://sw-description"
>      > -SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
>      > +SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
>      >
>      > python do_swupdate_copy_swdescription() {
>      > -
>      > import shutil
>      >
>      > workdir = d.getVar('S', True)
>      > - image = d.getVar('IMAGE_BASENAME', True)
>      > + image = d.getVar('IMAGE_LINK_NAME', True)
>      > filespath = d.getVar('FILESPATH')
>      > sw_desc_path = bb.utils.which(filespath, "sw-description")
>      > shutil.copyfile(sw_desc_path, os.path.join(workdir,
>     "sw-description"))
>      >
> 
>     I received today after yesterday's merge several reports from users
>     because CI breaks. I can reproduce it on one running project of mine,
>     and this is caused because IMAGE_LINK_NAME contains the MACHINE name.
>     Then all SWUPDATE_IMAGES_FSTYPES[] are wrong, because with this patch
>     the class is looking for SWUPDATE_IMAGES_FSTYPES[imagename-machine]
>     instead of SWUPDATE_IMAGES_FSTYPES[imagename]. I had to revert it
>     for now.
> 
>     Best regards,
>     Stefano Babic
> 
>     -- 
>     =====================================================================
>     DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
>     HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>     Phone: +49-8142-66989-53 <tel:+49%208142%206698953> Fax:
>     +49-8142-66989-80 <tel:+49%208142%206698980> Email: sba...@denx.de
>     =====================================================================
> 
> -- 
> 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/6c2ac02a-6d06-49e3-9bc8-ae34937ae909n%40googlegroups.com 
> <https://groups.google.com/d/msgid/swupdate/6c2ac02a-6d06-49e3-9bc8-ae34937ae909n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Stefano Babic Nov. 24, 2021, 10:34 a.m. UTC | #6
Hi Adrian,

On 23.11.21 22:30, Stefano Babic wrote:
> Hi Adrian,
> 
> On 23.11.21 19:00, Adrian Freihofer wrote:
>> Hi Stefano
>>
>> I am not sure if my patch is wrong 
> 
> I cannot say if it is wrong, but I got in the morning several reports 
> that current builds were broken. On a couple of project of mine, I could 
> see this is due to the change in the name for the flag 
> SWUPDATE_IMAGES_FSTYPES.
> 
>> or if some autobuilders should be fixed. The swupdate-image.bbclass is 
>> supposed to add the image artifact of the currently created image to 
>> the swu archive.
>> There are two ways I can see to get this working: Either using the 
>> IMAGE_NAME variable or using the IMAGE_LINK_NAME variable. These two 
>> variables refer to the files created by bitbake. Using IMAGE_LINK_NAME 
>> makes probably more sense.
>>
>> Using other variables can work if they happen to have the same value 
>> as IMAGE_LINK_NAME. In the case of swupdate-image.bbclass, 
>> IMAGE_BASENAME works as long as IMAGE_LINK_NAME is set to its default 
>> value. But there are many reasons why one needs to set IMAGE_LINK_NAME 
>> differently.
> 
> Then we need an another way to let set in a consistent way the flags 
> used by the generation of SWU, like SWUPDATE_IMAGES_FSTYPES[] or 
> SWUPDATE_IMAGES_NOAPPEND_MACHINE[].
> 
> This patch will ask to set the flag as 
> SWUPDATE_IMAGES_FSTYPES[${IMAGE_LINK_NAME}], that is 
> SWUPDATE_IMAGES_FSTYPES[${IMAGE_BASE_NAME}-${MACHINE}] when default is 
> applied. This is inconsistent because I cannto reuse the same recipe for 
> multiple MACHINEs, or I have to add FSTYPES for each machine even if 
> they are the same.
> 
>>
>> I don't know what kind of issues these autobuilders have. But I think
>>
>> SWUPDATE_IMAGES+= "${IMAGE_LINK_NAME}"
>>
>> should be the default artifact added by swupdate-image.bbclass.
> 
> Issue is caused because flags are missing. Image recipe sets the flag, 
> and it is for example SWUPDATE_IMAGE_FSTYPE[core-image]. When patch is 
> applied, class search for SWUPDATE_IMAGE_FSTYPES[core-image-machine]. It 
> is not set, build stops. We could also say that it was changed, and 
> please update the own recipe, but having the flag set with the machine 
> is a no way.
> 
>> Might be that this should be overwriteable for special use cases like
>>
>> SWUPDATE_DEFAULT_IMAGE ?= "${IMAGE_LINK_NAME}"
>> SWUPDATE_IMAGES+= "${SWUPDATE_DEFAULT_IMAGE}"
>>
>> An implementation like
>>
>> SWUPDATE_DEFAULT_IMAGE ?= "${IMAGE_BASENAME}"
>> SWUPDATE_IMAGES+= "${SWUPDATE_DEFAULT_IMAGE}"
>>
>> might be the compromise. It would allow me to overwrite it and be 
>> backward compatible for other use cases.
>> Currently swupdate-image.bbclass is not usable for us.
> 
> Ok, it works in your case because you are overwriting IMAGE_LINK_NAME. I 
> am fine if the flags are then set accordingly.

What about if we copy the flags via an anonymous function so that they 
are filled even if IMAGE_LINK_NAME is set ? I mean somethink like 
(reworking your patch):


diff --git a/classes/swupdate-image.bbclass b/classes/swupdate-image.bbclass
index d405fe1..f73e5ed 100644
--- a/classes/swupdate-image.bbclass
+++ b/classes/swupdate-image.bbclass
@@ -10,23 +10,27 @@

  inherit swupdate-common.bbclass

-S = "${WORKDIR}/${PN}"
-
  SRC_URI += "file://sw-description"
-SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
+SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"

-python do_swupdate_copy_swdescription() {
+python () {
+    image = d.getVar('IMAGE_LINK_NAME', True)
+    if d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) is None:
+       flag = d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", 
d.getVar('IMAGE_BASENAME'))
+       if flag:
+          d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", image, flag)
+       else:
+          bb.fatal("SWUPDATE_IMAGES_FSTYPES[%s] is not set !" % image)
+}

+python do_swupdate_copy_swdescription() {
      import shutil

      workdir = d.getVar('S', True)
-    image = d.getVar('IMAGE_BASENAME', True)
+    image = d.getVar('IMAGE_LINK_NAME', True)
      filespath = d.getVar('FILESPATH')
      sw_desc_path = bb.utils.which(filespath, "sw-description")
      shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
-
-    if d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) is None:
-       bb.fatal("SWUPDATE_IMAGES_FSTYPES[%s] is not set !" % image)
  }


Best regards,
Stefano


> 
>>
>> Thank you for the feedback.
>> Regards,
>> Adrian
>>
>> Stefano Babic schrieb am Montag, 22. November 2021 um 13:07:41 UTC+1:
>>
>>     Hi Adrian,
>>
>>     On 08.11.21 17:08, Adrian Freihofer wrote:
>>      > Use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME
>>     contains a
>>      > timestamp which causes some sporadic build failures. The problem
>>     is that
>>      > if the image files have been built by a previous bitbake call and
>>     bitbake
>>      > skips the task to build them again swupdate fails with searching
>>     for images
>>      > with the timestamp of the current build job in the file name. The
>>     link
>>      > refers to the latest available build in any case.
>>      >
>>      > Setting S to WORKDIR should not be needed. It's the default from
>>      > bitbake.conf.
>>      >
>>      > Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
>>      > ---
>>      > classes/swupdate-image.bbclass | 7 ++-----
>>      > 1 file changed, 2 insertions(+), 5 deletions(-)
>>      >
>>      > diff --git a/classes/swupdate-image.bbclass
>>     b/classes/swupdate-image.bbclass
>>      > index d405fe1..de9ee1f 100644
>>      > --- a/classes/swupdate-image.bbclass
>>      > +++ b/classes/swupdate-image.bbclass
>>      > @@ -10,17 +10,14 @@
>>      >
>>      > inherit swupdate-common.bbclass
>>      >
>>      > -S = "${WORKDIR}/${PN}"
>>      > -
>>      > SRC_URI += "file://sw-description"
>>      > -SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
>>      > +SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
>>      >
>>      > python do_swupdate_copy_swdescription() {
>>      > -
>>      > import shutil
>>      >
>>      > workdir = d.getVar('S', True)
>>      > - image = d.getVar('IMAGE_BASENAME', True)
>>      > + image = d.getVar('IMAGE_LINK_NAME', True)
>>      > filespath = d.getVar('FILESPATH')
>>      > sw_desc_path = bb.utils.which(filespath, "sw-description")
>>      > shutil.copyfile(sw_desc_path, os.path.join(workdir,
>>     "sw-description"))
>>      >
>>
>>     I received today after yesterday's merge several reports from users
>>     because CI breaks. I can reproduce it on one running project of mine,
>>     and this is caused because IMAGE_LINK_NAME contains the MACHINE name.
>>     Then all SWUPDATE_IMAGES_FSTYPES[] are wrong, because with this patch
>>     the class is looking for SWUPDATE_IMAGES_FSTYPES[imagename-machine]
>>     instead of SWUPDATE_IMAGES_FSTYPES[imagename]. I had to revert it
>>     for now.
>>
>>     Best regards,
>>     Stefano Babic
>>
>>     --     
>> =====================================================================
>>     DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
>>     HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>>     Phone: +49-8142-66989-53 <tel:+49%208142%206698953> Fax:
>>     +49-8142-66989-80 <tel:+49%208142%206698980> Email: sba...@denx.de
>>     =====================================================================
>>
>> -- 
>> 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/6c2ac02a-6d06-49e3-9bc8-ae34937ae909n%40googlegroups.com 
>> <https://groups.google.com/d/msgid/swupdate/6c2ac02a-6d06-49e3-9bc8-ae34937ae909n%40googlegroups.com?utm_medium=email&utm_source=footer>. 
>>
>
diff mbox series

Patch

diff --git a/classes/swupdate-image.bbclass b/classes/swupdate-image.bbclass
index d405fe1..de9ee1f 100644
--- a/classes/swupdate-image.bbclass
+++ b/classes/swupdate-image.bbclass
@@ -10,17 +10,14 @@ 
 
 inherit swupdate-common.bbclass
 
-S = "${WORKDIR}/${PN}"
-
 SRC_URI += "file://sw-description"
-SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
+SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"
 
 python do_swupdate_copy_swdescription() {
-
     import shutil
 
     workdir = d.getVar('S', True)
-    image = d.getVar('IMAGE_BASENAME', True)
+    image = d.getVar('IMAGE_LINK_NAME', True)
     filespath = d.getVar('FILESPATH')
     sw_desc_path = bb.utils.which(filespath, "sw-description")
     shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))