Skip to content

Commit

Permalink
feat(bundle.bbclass): simplify varflag usage
Browse files Browse the repository at this point in the history
In many case `getVarFlag` is used but `slotflags` coming from `getVarFlags`
previous call in bitbake task (`do_configure`) it's already expanded.
This improvement use `slotflags`.
It simplify also the loop over `RAUC_META_SECTIONS`.

Signed-off-by: Jean-Pierre Geslin <[email protected]>
  • Loading branch information
Jarsop committed Nov 8, 2023
1 parent 6c5faed commit 859f8d6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions classes-recipe/bundle.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -252,37 +252,37 @@ def write_manifest(d):

if imgtype == 'image':
if slotflags and 'file' in slotflags:
imgsource = d.getVarFlag('RAUC_SLOT_%s' % slot, 'file')
imgsource = slotflags.get('file')
else:
imgsource = "%s-%s.rootfs.%s" % (d.getVar('RAUC_SLOT_%s' % slot), machine, img_fstype)
imgname = imgsource
elif imgtype == 'kernel':
# TODO: Add image type support
if slotflags and 'file' in slotflags:
imgsource = d.getVarFlag('RAUC_SLOT_%s' % slot, 'file')
imgsource = slotflags.get('file')
else:
imgsource = "%s-%s.bin" % ("zImage", machine)
imgname = "%s.%s" % (imgsource, "img")
elif imgtype == 'boot':
if slotflags and 'file' in slotflags:
imgsource = d.getVarFlag('RAUC_SLOT_%s' % slot, 'file')
imgsource = slotflags.get('file')
else:
imgsource = "%s" % ("barebox.img")
imgname = imgsource
elif imgtype == 'file':
if slotflags and 'file' in slotflags:
imgsource = d.getVarFlag('RAUC_SLOT_%s' % slot, 'file')
imgsource = slotflags.get('file')
else:
bb.fatal('Unknown file for slot: %s' % slot)
imgname = "%s.%s" % (imgsource, "img")
else:
bb.fatal('Unknown image type: %s' % imgtype)

if slotflags and 'rename' in slotflags:
imgname = d.getVarFlag('RAUC_SLOT_%s' % slot, 'rename')
imgname = slotflags.get('rename')
if slotflags and 'offset' in slotflags:
padding = 'seek'
imgoffset = d.getVarFlag('RAUC_SLOT_%s' % slot, 'offset')
imgoffset = slotflags.get('offset')
if imgoffset:
sign, magnitude = imgoffset[:1], imgoffset[1:]
if sign == '+':
Expand All @@ -300,9 +300,9 @@ def write_manifest(d):
if slotflags and 'hooks' in slotflags:
if not have_hookfile:
bb.warn("A hook is defined for slot %s, but RAUC_BUNDLE_HOOKS[file] is not defined" % slot)
manifest.write("hooks=%s\n" % d.getVarFlag('RAUC_SLOT_%s' % slot, 'hooks'))
manifest.write("hooks=%s\n" % slotflags.get('hooks'))
if slotflags and 'adaptive' in slotflags:
manifest.write("adaptive=%s\n" % d.getVarFlag('RAUC_SLOT_%s' % slot, 'adaptive'))
manifest.write("adaptive=%s\n" % slotflags.get('adaptive'))
manifest.write("\n")

bundle_imgpath = "%s/%s" % (bundle_path, imgname)
Expand All @@ -327,8 +327,7 @@ def write_manifest(d):

for meta_section in (d.getVar('RAUC_META_SECTIONS') or "").split():
manifest.write("[meta.%s]\n" % meta_section)
for meta_key in d.getVarFlags('RAUC_META_%s' % meta_section):
meta_value = d.getVarFlag('RAUC_META_%s' % meta_section, meta_key)
for meta_key, meta_value in d.getVarFlags('RAUC_META_%s' % meta_section).items():
manifest.write("%s=%s\n" % (meta_key, meta_value))
manifest.write("\n");

Expand Down

0 comments on commit 859f8d6

Please sign in to comment.