Skip to content

Commit

Permalink
classes: bundle: add simple mechanism for adding extra artifacts to b…
Browse files Browse the repository at this point in the history
…undle

This introduces variables RAUC_BUNDLE_EXTRA_DEPENDS and
RAUC_BUNDLE_EXTRA_FILES.

With RAUC_BUNDLE_EXTRA_FILES one specifies a space-separated list of
artifacts that are first search in DEPLOY_DIR_IMAGE and then in WORKDIR.

This allows both to add artifact via SRC_URI as well as by grabbing the
generated files from other deploy recipes.

To ensure the artifacts are placed in the deploy dir before fetching
them bundle generation one must add their recipe's name to the
RAUC_BUNDLE_EXTRA_DEPENDS variable:

  RAUC_BUNDLE_EXTRA_DEPENDS += "recipe-name"

The dependency defaults to the do_deploy task. If something else is
required, than one can optionally do this with the recipe-deptask
notation:

  RAUC_BUNDLE_EXTRA_DEPENDS += "recipe-name:do_<taskname>"

Signed-off-by: Enrico Jorns <[email protected]>
  • Loading branch information
ejoerns committed Dec 3, 2019
1 parent a6b9cc6 commit e98d810
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions classes/bundle.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
# RAUC_SLOT_dtb[type] ?= "file"
# RAUC_SLOT_dtb[file] ?= "${MACHINE}-variant1.dtb"
#
# To add additional artifacts to the bundle you can use RAUC_BUNDLE_EXTRA_FILES
# and RAUC_BUNDLE_EXTRA_DEPENDS.
# For files from the WORKDIR (fetched using SRC_URI) you can write:
#
# SRC_URI += "file://myfile"
# RAUC_BUNDLE_EXTRA_FILES += "myfile"
#
# For files from the DEPLOY_DIR_IMAGE (generated by another recipe) you can write:
#
# RAUC_BUNDLE_EXTRA_DEPENDS += "myfile-recipe-pn"
# RAUC_BUNDLE_EXTRA_FILES += "myfile.img"
#
# Additionally you need to provide a certificate and a key file
#
# RAUC_KEY_FILE ?= "development-1.key.pem"
Expand Down Expand Up @@ -74,6 +86,9 @@ RAUC_BUNDLE_BUILD[doc] = "Specifies the bundle build stamp. See RAUC documentati
RAUC_BUNDLE_SLOTS[doc] = "Space-separated list of slot classes to include in bundle (manifest)"
RAUC_BUNDLE_HOOKS[doc] = "Allows to specify an additional hook executable and bundle hooks (via varflags '[file'] and ['hooks'])"

RAUC_BUNDLE_EXTRA_FILES[doc] = "Specifies list of additional files to add to bundle. Files must either be located in WORKDIR (added by SRC_URI) or DEPLOY_DIR_IMAGE (assured by RAUC_BUNDLE_EXTRA_DEPENDS)"
RAUC_BUNDLE_EXTRA_DEPENDS[doc] = "Specifies list of recipes that create artifacts in DEPLOY_DIR_IMAGE. For recipes not depending on do_deploy task also <recipename>:do_<taskname> notation is supported"

# Create dependency list from images
python __anonymous() {
d.appendVarFlag('do_unpack', 'vardeps', ' RAUC_BUNDLE_HOOKS')
Expand All @@ -99,6 +114,12 @@ python __anonymous() {
d.appendVarFlag('do_unpack', 'depends', ' ' + image + ':do_image_complete')
else:
d.appendVarFlag('do_unpack', 'depends', ' ' + image + ':do_deploy')

for image in (d.getVar('RAUC_BUNDLE_EXTRA_DEPENDS') or "").split():
imagewithdep = image.split(':')
deptask = imagewithdep[1] if len(imagewithdep) > 1 else 'do_deploy'
d.appendVarFlag('do_unpack', 'depends', ' %s:%s' % (image, deptask))
bb.note('adding extra dependency %s:%s' % (image, deptask))
}

S = "${WORKDIR}"
Expand Down Expand Up @@ -214,6 +235,22 @@ do_unpack_append() {
shutil.copy(d.expand("${WORKDIR}/%s" % hf), dsthook)
st = os.stat(dsthook)
os.chmod(dsthook, st.st_mode | stat.S_IEXEC)

for file in (d.getVar('RAUC_BUNDLE_EXTRA_FILES') or "").split():
searchpath = d.expand("${DEPLOY_DIR_IMAGE}/%s") % file
destpath = d.expand("${BUNDLE_DIR}/%s") % file
if os.path.isfile(searchpath):
bb.note("adding extra file from deploy dir to bundle dir: '%s'" % file)
shutil.copy(searchpath, destpath)
continue

searchpath = d.expand("${WORKDIR}/%s") % file
if os.path.isfile(searchpath):
bb.note("adding extra file from workdir to bundle dir: '%s'" % file)
shutil.copy(searchpath, destpath)
continue

bb.error("extra file '%s' neither found in workdir nor in deploy dir!" % file)
}

BUNDLE_BASENAME ??= "${PN}"
Expand Down

0 comments on commit e98d810

Please sign in to comment.