mirror of
https://git.yoctoproject.org/meta-arm
synced 2026-01-12 03:10:15 +00:00
arm-autonomy: Add external guests to host image
Add ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS variable to let user specifiy a list of guests to be included directly in the host image. The variable can be set to a space separated list of full path to xenguest image files or SRC_URI compatible urls. Each entry can also have a ';guestname=NAME' argument to set the destination name of the guest added. Change-Id: I4fc5e53df979b792ad930066a068ad1d4512c991 Issue-Id: SCM-767 Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> Reviewed-by: Diego Sueiro <diego.sueiro@arm.com> Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
committed by
Jon Mason
parent
df189a806b
commit
b3e13f492a
@@ -5,6 +5,31 @@ DESCRIPTION = "Arm Autonomy stack host minimal image"
|
||||
inherit core-image
|
||||
|
||||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
|
||||
|
||||
# The ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS variable can be used to include in the
|
||||
# image one or several xenguest images.
|
||||
# The list must be space separated and each entry must have the following
|
||||
# format: URL[;guestname=NAME]
|
||||
# - URL can be the full path to a file or a Yocto compatible SRC_URI url
|
||||
# - guestname=NAME can be used to specify the name of the guest. If not
|
||||
# specified the basename of the file (without .xenguest extension) is used.
|
||||
# Here are examples of values:
|
||||
# /home/mydir/myguest.xenguest;guestname=guest1
|
||||
# http://www.url.com/testguest.xenguest
|
||||
#
|
||||
# If you are using the output of an other Yocto project, you should use the
|
||||
# full path syntax instead of the Yocto SRC_URI to be able to use the
|
||||
# symlink version of your image (as the real file has a new name on each
|
||||
# build as it includes the date). You must not use SRC_URI type file:// as
|
||||
# it will try to include the symlink and not the destination file which will
|
||||
# be detected by the recipe and output an error 'Guest file is a symlink'.
|
||||
#
|
||||
# Guests can also be added using a bbapend to this recipe by adding entries
|
||||
# to SRC_URI with parameter ;guestname=NAME to specify the destination
|
||||
# guestname. The parameter guestname must be present as it is used to detect
|
||||
# guests to be added
|
||||
ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS ??= ""
|
||||
|
||||
# Includes minimal set required to start and manage guest. The xen specific
|
||||
# modules are not explicitly included as they are built as part of the kernel
|
||||
@@ -29,4 +54,64 @@ python __anonymous() {
|
||||
|
||||
if bb.utils.contains('DISTRO_FEATURES', 'xen', False, True, d):
|
||||
raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'xen'")
|
||||
|
||||
# Check in ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS for extra guests and add them
|
||||
# to SRC_URI with xenguest parameter if not set
|
||||
guestlist = d.getVar('ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS')
|
||||
if guestlist:
|
||||
for guest in guestlist.split():
|
||||
# If the user just specified a file instead of file://FILE, add
|
||||
# the file:// prefix
|
||||
if guest.startswith('/'):
|
||||
guestfile = ''
|
||||
guestname = ''
|
||||
if ';guestname=' in guest:
|
||||
# user specified a guestname
|
||||
guestname = guest.split(';guestname=')[1]
|
||||
guestfile = guest.split(';guestname=')[0]
|
||||
else:
|
||||
# no guestname so use the basename
|
||||
guestname = os.path.basename(guest)
|
||||
guestfile = guest
|
||||
# in case we have a link we need the destination
|
||||
guestfile = os.path.realpath(guestfile)
|
||||
|
||||
# make sure the file exist to give a meaningfull error
|
||||
if not os.path.exists(guestfile):
|
||||
raise bb.parse.SkipRecipe("ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS entry does not exist: " + guest)
|
||||
|
||||
# In case the file is a symlink make sure we use the destination
|
||||
d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname)
|
||||
else:
|
||||
# we have a Yocto URL
|
||||
try:
|
||||
_, _, path, _, _, parm = bb.fetch.decodeurl(guest)
|
||||
# force guestname param in if not already there
|
||||
if not 'guestname' in parm:
|
||||
guest += ';guestname=' + os.path.basename(path)
|
||||
d.appendVar('SRC_URI', ' ' + guest)
|
||||
except:
|
||||
raise bb.parse.SkipRecipe("ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS contains an invalid entry: " + guest)
|
||||
}
|
||||
|
||||
python add_extern_guests () {
|
||||
# Destination directory on the rootfs
|
||||
guestdir = d.getVar('IMAGE_ROOTFS') + d.getVar('datadir') + '/guests'
|
||||
|
||||
# Parse SRC_URI for files with ;guestname= parameter
|
||||
src_uri = d.getVar('SRC_URI')
|
||||
for entry in src_uri.split():
|
||||
_, _, path, _, _, parm = bb.fetch.decodeurl(entry)
|
||||
if 'guestname' in parm:
|
||||
if os.path.islink(path):
|
||||
bb.fatal("Guest file is a symlink: " + path)
|
||||
bb.utils.mkdirhier(guestdir)
|
||||
dstname = parm['guestname']
|
||||
# Add file extension if not there
|
||||
if not dstname.endswith('.xenguest'):
|
||||
dstname += '.xenguest'
|
||||
bb.utils.copyfile(path, guestdir + '/' + dstname)
|
||||
}
|
||||
|
||||
IMAGE_PREPROCESS_COMMAND += "add_extern_guests; "
|
||||
|
||||
|
||||
Reference in New Issue
Block a user