[meta-swupdate][PATCH 0/2] fix build-time signing issues

198 views
Skip to first unread message

Adrian Freihofer

unread,
Nov 4, 2021, 2:19:01 PM11/4/21
to swup...@googlegroups.com, Adrian Freihofer
Fix some sporadic build errors in the signing implementation. It's
tested against dunfell using the swupdate-image.bbclass.

Adrian Freihofer (2):
swupdate-common: improve signing
swupdate-image: remove sw-description copy

classes/swupdate-common.bbclass | 70 ++++++++++++++-------------------
classes/swupdate-image.bbclass | 21 +---------
2 files changed, 32 insertions(+), 59 deletions(-)

--
2.31.1

Adrian Freihofer

unread,
Nov 4, 2021, 2:19:01 PM11/4/21
to swup...@googlegroups.com, Adrian Freihofer
Since the taskdeps should now be fixed in swudpate-common,
do_swupdate_copy_swdescription is redundant. do_unpack should be executed
whenever it is needed.

It will now use IMAGE_LINK_NAME instead of IMAGE_BASENAME. IMAGE_BASENAME
contains a timestamp which sporadically causes errors during creation. The
problem is that if the image files were created by a previous bitbake call
and bitbake skips the task of creating them again, swupdate fails when
searching for images with the current build job's timestamp in the file name.
In any case, the link points to the last available build.

Setting S to WORKDIR should not be necessary. It is the default from
bitbake.conf.

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

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

inherit swupdate-common.bbclass

-S = "${WORKDIR}/${PN}"
-
SRC_URI += "file://sw-description"
-SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
-
-python do_swupdate_copy_swdescription() {
-
- import shutil
-
- workdir = d.getVar('S', True)
- image = d.getVar('IMAGE_BASENAME', 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)
-}
+SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}"

-addtask swupdate_copy_swdescription before do_image_complete after do_unpack
-addtask swuimage after do_swupdate_copy_swdescription do_image_complete before do_build
+addtask swuimage after do_image_complete before do_build

# Read all variables from sw-description file and add them to the vardeps of the do_swuimage task. Bitbake
# cannot know that the do_swuimage task which evaluates the templated sw-description file needs to be executed
--
2.31.1

Adrian Freihofer

unread,
Nov 4, 2021, 2:19:01 PM11/4/21
to swup...@googlegroups.com, Adrian Freihofer
Improve the implementation of signatures and related task dependencies.

os.system gets replaced by subprocess.run. os.system does not display helpful
error messages and therefore signing fails without a useful error description.
Since os.system has been replaced by the more modern subprocess.run, some
interesting error patterns have become visible. In particular, when running
more complex build flows when rm_work was active, the signing step sometimes
failed becaus:

- openssl binary not found: fixed dependencies
- openssl fails because the parameter "-passin file:'%s' " is invalid.
With the list-based syntax of subprocess.run, this is handled without '

Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
---
classes/swupdate-common.bbclass | 70 ++++++++++++++-------------------
1 file changed, 30 insertions(+), 40 deletions(-)

diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass
index f483398..9d81cfb 100644
--- a/classes/swupdate-common.bbclass
+++ b/classes/swupdate-common.bbclass
@@ -1,8 +1,3 @@
-DEPENDS += "\
- cpio-native \
- ${@ 'openssl-native' if d.getVar('SWUPDATE_SIGNING', True) else ''} \
-"
-
do_swuimage[umask] = "022"
SSTATETASKS += "do_swuimage"
SSTATE_SKIP_CREATION_task-swuimage = '1'
@@ -15,26 +10,36 @@ do_swuimage[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
do_swuimage[stamp-extra-info] = "${MACHINE}"

python () {
- deps = " " + swupdate_getdepends(d)
+ deps = " " + swuimage_getdepends(d)
d.appendVarFlag('do_swuimage', 'depends', deps)
d.delVarFlag('do_fetch', 'noexec')
d.delVarFlag('do_unpack', 'noexec')
}

-def swupdate_getdepends(d):
+def swuimage_getdepends(d):
def adddep(depstr, deps):
for i in (depstr or "").split():
if i not in deps:
deps.append(i)

+ # Artifacts
deps = []
images = (d.getVar('IMAGE_DEPENDS', True) or "").split()
for image in images:
- adddep(image , deps)
+ adddep(image , deps)

depstr = ""
for dep in deps:
depstr += " " + dep + ":do_build"
+
+ # openssl
+ if d.getVar('SWUPDATE_SIGNING') or d.getVar('SWUPDATE_ENCRYPT_SWDESC') or d.getVarFlags('SWUPDATE_IMAGES_ENCRYPTED'):
+ depstr += " openssl-native:do_populate_sysroot"
+ # cpio
+ depstr += " cpio-native:do_populate_sysroot"
+ # Always (also with rm_work active) files to workdir
+ depstr += ' ' + d.getVar('PN') + ":do_unpack"
+
return depstr

def swupdate_get_sha256(s, filename):
@@ -228,6 +233,7 @@ def swupdate_expand_auto_versions(d, s):

def prepare_sw_description(d):
import shutil
+ import subprocess

s = d.getVar('S', True)
swupdate_expand_bitbake_variables(d, s)
@@ -247,13 +253,19 @@ def prepare_sw_description(d):
bb.warn('SWUPDATE_SIGNING = "1" is deprecated, falling back to "RSA". It is advised to set it to "RSA" if using RSA signing.')
signing = "RSA"
if signing:
+ def get_pwd_file_args():
+ pwd_args = []
+ pwd_file = d.getVar('SWUPDATE_PASSWORD_FILE', True)
+ if pwd_file:
+ pwd_args = ["-passin", "file:%s" % pwd_file]
+ return pwd_args
+
+ sw_desc_sig = os.path.join(s, 'sw-description.sig')
+ sw_desc = os.path.join(s, 'sw-description.plain' if encrypt else 'sw-description')
+
if signing == "CUSTOM":
- sign_tool = d.getVar('SWUPDATE_SIGN_TOOL', True)
- if sign_tool:
- ret = os.system(sign_tool)
- if ret != 0:
- bb.fatal("Failed to sign with %s" % (sign_tool))
- else:
+ signcmd = d.getVar('SWUPDATE_SIGN_TOOL', True)
+ if not sign_tool:
bb.fatal("Custom SWUPDATE_SIGN_TOOL is not given")
elif signing == "RSA":
privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True)
@@ -261,18 +273,7 @@ def prepare_sw_description(d):
bb.fatal("SWUPDATE_PRIVATE_KEY isn't set")
if not os.path.exists(privkey):
bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey))
- passout = d.getVar('SWUPDATE_PASSWORD_FILE', True)
- if passout:
- passout = "-passin file:'%s' " % (passout)
- else:
- passout = ""
- signcmd = "openssl dgst -sha256 -sign '%s' %s -out '%s' '%s'" % (
- privkey,
- passout,
- os.path.join(s, 'sw-description.sig'),
- os.path.join(s, 'sw-description.plain' if encrypt else 'sw-description'))
- if os.system(signcmd) != 0:
- bb.fatal("Failed to sign sw-description with %s" % (privkey))
+ signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args() + ["-out", sw_desc_sig, sw_desc]
elif signing == "CMS":
cms_cert = d.getVar('SWUPDATE_CMS_CERT', True)
if not cms_cert:
@@ -284,21 +285,10 @@ def prepare_sw_description(d):
bb.fatal("SWUPDATE_CMS_KEY isn't set")
if not os.path.exists(cms_key):
bb.fatal("SWUPDATE_CMS_KEY %s doesn't exist" % (cms_key))
- passout = d.getVar('SWUPDATE_PASSWORD_FILE', True)
- if passout:
- passout = "-passin file:'%s' " % (passout)
- else:
- passout = ""
- signcmd = "openssl cms -sign -in '%s' -out '%s' -signer '%s' -inkey '%s' %s -outform DER -nosmimecap -binary" % (
- os.path.join(s, 'sw-description.plain' if encrypt else 'sw-description'),
- os.path.join(s, 'sw-description.sig'),
- cms_cert,
- cms_key,
- passout)
- if os.system(signcmd) != 0:
- bb.fatal("Failed to sign sw-description with %s" % (privkey))
+ signcmd = ["openssl", "cms", "-sign", "-in", sw_desc, "-out", sw_desc_sig, "-signer", cms_cert, "-inkey", cms_key] + get_pwd_file_args() + ["-outform", "DER", "-nosmimecap", "-binary"]
else:
- bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism.");
+ bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism.")
+ subprocess.run(signcmd, check=True)


def swupdate_add_src_uri(d, list_for_cpio):
--
2.31.1

Adrian Freihofer

unread,
Nov 7, 2021, 6:06:58 PM11/7/21
to swupdate
Hi Stefano

This patchset has causes an issue when running in the eSDK. I'm working and testing a V2.

Regards,
Adrian

Adrian Freihofer

unread,
Nov 8, 2021, 11:08:52 AM11/8/21
to swup...@googlegroups.com, Adrian Freihofer
Comparison to V1:
- Reduce amount of chagnes
- Fix an error related to the eSDK introduced by V1

Adrian Freihofer (2):
swupdate-common: improve signing
swupdate-image: use image link name

classes/swupdate-common.bbclass | 54 ++++++++++++---------------------
classes/swupdate-image.bbclass | 7 ++---
2 files changed, 22 insertions(+), 39 deletions(-)

--
2.31.1

Adrian Freihofer

unread,
Nov 8, 2021, 11:08:53 AM11/8/21
to swup...@googlegroups.com, Adrian Freihofer
Improve signing implementation and related task dependencies.

Replace os.system with subprocess.run. os.system does not show any helpful
error messages and therefore signing simply fails. Since os.system was
replaced by the more verbose subprocess.run, several interesting error
patterns occurred. Especially when running more complex build flows with
rm_work active the signing step failed sometimes.

subprocess.run exceptions showed different errors:
- openssl binary not found: Fixed dependencies
- openssl fails because the "-passin file:'%s' " parameter is invalid.
With the list based syntax of subprocess.run this gets fixed without '

Signed-off-by: Adrian Freihofer <adrian.f...@siemens.com>
---
classes/swupdate-common.bbclass | 54 ++++++++++++---------------------
1 file changed, 20 insertions(+), 34 deletions(-)

diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass
index f483398..c91ee4e 100644
--- a/classes/swupdate-common.bbclass
+++ b/classes/swupdate-common.bbclass
@@ -1,6 +1,6 @@
DEPENDS += "\
cpio-native \
- ${@ 'openssl-native' if d.getVar('SWUPDATE_SIGNING', True) else ''} \
+ ${@ 'openssl-native' if d.getVar('SWUPDATE_SIGNING') or d.getVar('SWUPDATE_ENCRYPT_SWDESC') or d.getVarFlags('SWUPDATE_IMAGES_ENCRYPTED') else ''} \
"

do_swuimage[umask] = "022"
@@ -30,11 +30,12 @@ def swupdate_getdepends(d):
deps = []
images = (d.getVar('IMAGE_DEPENDS', True) or "").split()
for image in images:
- adddep(image , deps)
+ adddep(image , deps)

depstr = ""
for dep in deps:
depstr += " " + dep + ":do_build"
+
return depstr

def swupdate_get_sha256(s, filename):
@@ -228,6 +229,7 @@ def swupdate_expand_auto_versions(d, s):

def prepare_sw_description(d):
import shutil
+ import subprocess

s = d.getVar('S', True)
swupdate_expand_bitbake_variables(d, s)
@@ -247,13 +249,19 @@ def prepare_sw_description(d):
@@ -261,18 +269,7 @@ def prepare_sw_description(d):
bb.fatal("SWUPDATE_PRIVATE_KEY isn't set")
if not os.path.exists(privkey):
bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey))
- passout = d.getVar('SWUPDATE_PASSWORD_FILE', True)
- if passout:
- passout = "-passin file:'%s' " % (passout)
- else:
- passout = ""
- signcmd = "openssl dgst -sha256 -sign '%s' %s -out '%s' '%s'" % (
- privkey,
- passout,
- os.path.join(s, 'sw-description.sig'),
- os.path.join(s, 'sw-description.plain' if encrypt else 'sw-description'))
- if os.system(signcmd) != 0:
- bb.fatal("Failed to sign sw-description with %s" % (privkey))
+ signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args() + ["-out", sw_desc_sig, sw_desc]
elif signing == "CMS":
cms_cert = d.getVar('SWUPDATE_CMS_CERT', True)
if not cms_cert:
@@ -284,21 +281,10 @@ def prepare_sw_description(d):

Adrian Freihofer

unread,
Nov 8, 2021, 11:08:53 AM11/8/21
to swup...@googlegroups.com, Adrian Freihofer
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"))
--
2.31.1

Stefano Babic

unread,
Nov 21, 2021, 6:04:00 AM11/21/21
to Adrian Freihofer, swup...@googlegroups.com, Adrian Freihofer
Applied to :

To github.com:sbabic/meta-swupdate.git
9659220..89d059e dunfell -> dunfell
0b4523b..cc07581 hardknott -> hardknott
3793af1..557b1b5 honister -> honister
b935dff..01968a3 master -> master

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 Fax: +49-8142-66989-80 Email: sba...@denx.de
=====================================================================

Jyothi K

unread,
Nov 22, 2021, 4:52:13 AM11/22/21
to swupdate
Hello all,

After this update there is a build error w.r.t sign_tool 

=============================================================================
meta-swupdate/classes/swupdate-common.bbclass', lineno: 264, function: prepare_sw_description 0260: sw_desc = os.path.join(s, 'sw-description.plain' if encrypt else 'sw-description') 0261: 0262: if signing == "CUSTOM": 0263: signcmd = d.getVar('SWUPDATE_SIGN_TOOL', True) *** 0264: if not sign_tool: 0265: bb.fatal("Custom SWUPDATE_SIGN_TOOL is not given") 0266: elif signing == "RSA": 0267: privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True) 0268: if not privkey: Exception: NameError: name 'sign_tool' is not defined
===============================================================================
I think the sign_tool to be updated to signcmd.

please provide the fix to resolve build issues.

Thanks,
Jyothi

Stefano Babic

unread,
Nov 22, 2021, 4:55:42 AM11/22/21
to Jyothi K, swupdate
Hi Jyothi,

On 22.11.21 10:52, Jyothi K wrote:
> Hello all,
>
> After this update there is a build error w.r.t sign_tool
>
> =============================================================================
> meta-swupdate/classes/swupdate-common.bbclass', lineno: 264, function:
> prepare_sw_description 0260: sw_desc = os.path.join(s,
> 'sw-description.plain' if encrypt else 'sw-description') 0261: 0262: if
> signing == "CUSTOM": 0263: signcmd = d.getVar('SWUPDATE_SIGN_TOOL',
> True) *** 0264: if not sign_tool: 0265: bb.fatal("Custom
> SWUPDATE_SIGN_TOOL is not given") 0266: elif signing == "RSA": 0267:
> privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True) 0268: if not privkey:
> Exception: NameError: name 'sign_tool' is not defined
> ===============================================================================
> I think the sign_tool to be updated to signcmd.
>

Agree.

> please provide the fix to resolve build issues.
>

Could you send the patch, please ?

Best regards,
Stefanmo Babic
> 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+u...@googlegroups.com
> <mailto:swupdate+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/490618e6-5b13-42f5-91b6-142822b3ec75n%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/490618e6-5b13-42f5-91b6-142822b3ec75n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Stefano Babic

unread,
Nov 22, 2021, 7:07:41 AM11/22/21
to Adrian Freihofer, swup...@googlegroups.com, Adrian Freihofer
Hi Adrian,

On 08.11.21 17:08, Adrian Freihofer wrote:
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

Jyothi K

unread,
Nov 23, 2021, 2:45:41 AM11/23/21
to swupdate
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

Stefano Babic

unread,
Nov 23, 2021, 3:19:47 AM11/23/21
to Jyothi K, swupdate
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
> 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+u...@googlegroups.com
> <mailto:swupdate+u...@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

unread,
Nov 23, 2021, 1:00:13 PM11/23/21
to swupdate
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

unread,
Nov 23, 2021, 4:30:05 PM11/23/21
to Adrian Freihofer, swupdate
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
> 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+u...@googlegroups.com
> <mailto:swupdate+u...@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

unread,
Nov 24, 2021, 5:34:59 AM11/24/21
to Adrian Freihofer, swupdate
Hi Adrian,
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)
}


Reply all
Reply to author
Forward
0 new messages