summaryrefslogtreecommitdiffstats
path: root/bsp/meta-arm/meta-arm-autonomy/classes
diff options
context:
space:
mode:
authortakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-11-02 11:07:33 +0900
committertakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-11-02 11:07:33 +0900
commit1c7d6584a7811b7785ae5c1e378f14b5ba0971cf (patch)
treecd70a267a5ef105ba32f200aa088e281fbd85747 /bsp/meta-arm/meta-arm-autonomy/classes
parent4204309872da5cb401cbb2729d9e2d4869a87f42 (diff)
recipes
Diffstat (limited to 'bsp/meta-arm/meta-arm-autonomy/classes')
-rw-r--r--bsp/meta-arm/meta-arm-autonomy/classes/arm-autonomy-features.bbclass5
-rw-r--r--bsp/meta-arm/meta-arm-autonomy/classes/image_types_xenguest.bbclass108
-rw-r--r--bsp/meta-arm/meta-arm-autonomy/classes/kernel-xenguest.bbclass34
-rw-r--r--bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image-extra.bbclass102
-rw-r--r--bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image.bbclass195
5 files changed, 444 insertions, 0 deletions
diff --git a/bsp/meta-arm/meta-arm-autonomy/classes/arm-autonomy-features.bbclass b/bsp/meta-arm/meta-arm-autonomy/classes/arm-autonomy-features.bbclass
new file mode 100644
index 00000000..15549d89
--- /dev/null
+++ b/bsp/meta-arm/meta-arm-autonomy/classes/arm-autonomy-features.bbclass
@@ -0,0 +1,5 @@
+# Include arm-autonomy distro config files if the distro features are set
+
+require ${@bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', '${ARM_AUTONOMY_DISTRO_CFGDIR}/arm-autonomy-host.inc', '', d)}
+require ${@bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-guest', '${ARM_AUTONOMY_DISTRO_CFGDIR}/arm-autonomy-guest.inc', '', d)}
+
diff --git a/bsp/meta-arm/meta-arm-autonomy/classes/image_types_xenguest.bbclass b/bsp/meta-arm/meta-arm-autonomy/classes/image_types_xenguest.bbclass
new file mode 100644
index 00000000..195d6ed2
--- /dev/null
+++ b/bsp/meta-arm/meta-arm-autonomy/classes/image_types_xenguest.bbclass
@@ -0,0 +1,108 @@
+# Create a xenguest image with kernel and filesystem produced by Yocto
+# This will create a .xenguest file that the xenguest-manager can use.
+
+inherit xenguest-image
+
+# We are creating our guest in a local subdirectory
+# force the value so that we are not impacted if the user is changing it
+XENGUEST_IMAGE_DEPLOY_DIR = "${WORKDIR}/tmp-xenguest"
+
+# Name of deployed file (keep standard image name and add .xenguest)
+XENGUEST_IMAGE_DEPLOY ??= "${IMAGE_NAME}"
+
+# Add kernel XENGUEST_IMAGE_KERNEL from DEPLOY_DIR_IMAGE to image
+xenguest_image_add_kernel() {
+ srcfile="${1:-}"
+ if [ -z "${srcfile}" ]; then
+ srcfile="${DEPLOY_DIR_IMAGE}/${XENGUEST_IMAGE_KERNEL}"
+ fi
+ call_xenguest_mkimage partial --xen-kernel=$srcfile
+}
+
+# Add rootfs file to the image
+xenguest_image_add_rootfs() {
+ call_xenguest_mkimage partial \
+ --disk-add-file=${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMAGE_TYPEDEP_xenguest}:rootfs.${IMAGE_TYPEDEP_xenguest}
+}
+
+# Pack xenguest image
+xenguest_image_pack() {
+ mkdir -p ${IMGDEPLOYDIR}
+ rm -f ${IMGDEPLOYDIR}/${XENGUEST_IMAGE_DEPLOY}.xenguest
+ call_xenguest_mkimage pack \
+ ${IMGDEPLOYDIR}/${XENGUEST_IMAGE_DEPLOY}.xenguest
+}
+
+#
+# Task finishing the bootimg
+# We need this task to actually create the symlinks
+#
+python do_bootimg_xenguest() {
+ subtasks = d.getVarFlag('do_bootimg_xenguest', 'subtasks')
+
+ bb.build.exec_func('xenguest_image_clone', d)
+ if subtasks:
+ for tk in subtasks.split():
+ bb.build.exec_func(tk, d)
+ bb.build.exec_func('xenguest_image_pack', d)
+ bb.build.exec_func('create_symlinks', d)
+}
+# This is used to add sub-tasks to do_bootimg_xenguest
+do_bootimg_xenguest[subtasks] = ""
+# Those are required by create_symlinks to find our image
+do_bootimg_xenguest[subimages] = "xenguest"
+do_bootimg_xenguest[imgsuffix] = "."
+do_bootimg_xenguest[depends] += "xenguest-base-image:do_deploy"
+# Need to have rootfs so all recipes have deployed their content
+do_bootimg_xenguest[depends] += "${PN}:do_rootfs"
+
+# This set in python anonymous after, just set a default value here
+IMAGE_TYPEDEP_xenguest ?= "tar"
+
+# We must not be built at rootfs build time because we need the kernel
+IMAGE_TYPES_MASKED += "xenguest"
+IMAGE_TYPES += "xenguest"
+
+python __anonymous() {
+ # Do not do anything if we are not in the want FSTYPES
+ if bb.utils.contains_any('IMAGE_FSTYPES', 'xenguest', '1', '0', d):
+
+ # Check the coherency of the configuration
+ rootfs_needed = False
+ rootfs_file = ''
+ kernel_needed = False
+
+ rootfs_file = xenguest_image_rootfs_file(d)
+ if rootfs_file:
+ rootfs_needed = True
+
+ if d.getVar('XENGUEST_IMAGE_KERNEL') and not d.getVar('INITRAMFS_IMAGE'):
+ # If INITRAMFS_IMAGE is set, even if INITRAMFS_IMAGE_BUNDLE is not
+ # set to 1 to bundle the initramfs with the kernel, kernel.bbclass
+ # is setting a dependency on ${PN}:do_image_complete. We cannot
+ # in this case depend on do_deploy as it would create a circular
+ # dependency:
+ # do_image_complete would depend on kernel:do_deploy which would
+ # depend on ${PN}:do_image_complete
+ # In the case INITRAMFS_IMAGE_BUNDLE = 1, the kernel-xenguest class
+ # will handle the creation of a xenguest image with the kernel.
+ # In the other case the kernel can be added manually to the image.
+ kernel_needed = True
+
+ bb.build.addtask('do_bootimg_xenguest', 'do_image_complete', None, d)
+
+ if rootfs_needed:
+ # tell do_bootimg_xenguest to call add_rootfs
+ d.appendVarFlag('do_bootimg_xenguest', 'subtasks', ' xenguest_image_add_rootfs')
+ # do_bootimg_xenguest will need the tar file
+ d.appendVarFlag('do_bootimg_xenguest', 'depends', ' %s:do_image_tar' % (d.getVar('PN')))
+ # set our TYPEDEP to the proper compression
+ d.setVar('IMAGE_TYPEDEP_xenguest', 'tar' + (rootfs_file.split('.tar', 1)[1] or ''))
+
+ if kernel_needed:
+ # Tell do_bootimg_xenguest to call xenguest_image_add_kernel
+ d.appendVarFlag('do_bootimg_xenguest', 'subtasks', ' xenguest_image_add_kernel')
+ # we will need kernel do_deploy
+ d.appendVarFlag('do_bootimg_xenguest', 'depends', ' virtual/kernel:do_deploy')
+}
+
diff --git a/bsp/meta-arm/meta-arm-autonomy/classes/kernel-xenguest.bbclass b/bsp/meta-arm/meta-arm-autonomy/classes/kernel-xenguest.bbclass
new file mode 100644
index 00000000..a4954aaa
--- /dev/null
+++ b/bsp/meta-arm/meta-arm-autonomy/classes/kernel-xenguest.bbclass
@@ -0,0 +1,34 @@
+# Create a xenguest image containing the kernel with initramfs when
+# initramfs is activated
+# This is done using kernel-fitimage as model
+# To activate this, kernel-xenguest must be added to KERNEL_CLASSES
+
+inherit xenguest-image
+
+# use a local copy to pack all together
+XENGUEST_IMAGE_DEPLOY_DIR = "${WORKDIR}/tmp-xenguest"
+
+python __anonymous () {
+ # only if xenguest image type is present
+ if bb.utils.contains('IMAGE_FSTYPES', 'xenguest', '1', '0', d):
+ # only if initramfs bundle is activated
+ if d.getVar('INITRAMFS_IMAGE') and d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
+ if not bb.utils.contains('KERNEL_IMAGETYPES', 'Image', '1', '0', d):
+ bb.fatal("xenguest image type with initramfs require Image kernel image type")
+ bb.build.addtask('do_assemble_xenguest_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
+}
+
+do_assemble_xenguest_initramfs() {
+ xenguest_image_clone
+ call_xenguest_mkimage partial --xen-kernel=${B}/${KERNEL_OUTPUT_DIR}/Image.initramfs
+ rm -f ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest
+ call_xenguest_mkimage pack ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest
+}
+do_assemble_xenguest_initramfs[depends] += "${INITRAMFS_IMAGE}:do_image_complete"
+
+kernel_do_deploy_append() {
+ if [ -f "${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest" ]; then
+ install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest "$deployDir/Image-${INITRAMFS_NAME}.xenguest"
+ ln -snf Image-${INITRAMFS_NAME}.xenguest $deployDir/Image-${INITRAMFS_LINK_NAME}.xenguest
+ fi
+}
diff --git a/bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image-extra.bbclass b/bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image-extra.bbclass
new file mode 100644
index 00000000..502a083f
--- /dev/null
+++ b/bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image-extra.bbclass
@@ -0,0 +1,102 @@
+# This class must be used to extend the xenguest image
+# It provides variables to add init scripts, a dtb, xen files or disk files.
+#
+# The class is extending deploy function so you recipe must inherit deploy and
+# have a do_deploy function (even if it is empty)
+
+# Use standard xenguest-image
+inherit xenguest-image
+
+# Add a DTB file for the guest
+# Only one file should be added, if this is set multiple times or in several
+# recipes, the last recipe setting it will prevail.
+XENGUEST_EXTRA_DTB ??= ""
+
+# Append something to the guest xen configuration
+# All files here will be merged together in the final xen configuration
+# This can contain several files or be used in several recipes
+XENGUEST_EXTRA_XENCONFIG ??= ""
+
+# Add a xenguest init, init-pre or init-post script
+XENGUEST_EXTRA_INIT_PRE ??= ""
+XENGUEST_EXTRA_INIT ??= ""
+XENGUEST_EXTRA_INIT_POST ??= ""
+
+# Add xenguest files, (to be used in extra xen config for example)
+# several files may be added, space separated, the path will be kept on the
+# generated xenguest image (if dir1/file1 is added, it can be used as
+# dir1/file1 file in the xen configuration).
+XENGUEST_EXTRA_FILES ??= ""
+
+# Add xenguest disk files (to be used as disk partition content)
+# several files may be added, space separated, the path will be kept on the
+# generated xenguest image (if dir1/file1 is added, it can be used as
+# dir1/file1 file in the disk content parameters).
+XENGUEST_EXTRA_DISK_FILES ??= ""
+
+do_deploy_append() {
+ if [ -z "${XENGUEST_IMAGE_DEPLOY_DIR}" -o \
+ -z "${XENGUEST_IMAGE_DEPLOY_SUBDIR}" ]; then
+ die "Configuration error: XENGUEST_IMAGE_DEPLOY_DIR or XENGUEST_IMAGE_DEPLOY_SUBDIR is empty"
+ fi
+ rm -rf ${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}
+ mkdir -p ${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}
+
+ if [ -n "${XENGUEST_EXTRA_DTB}" ]; then
+ if [ ! -f ${XENGUEST_EXTRA_DTB} ]; then
+ die "xenguest-image: DTB file ${XENGUEST_EXTRA_DTB} does not exist"
+ fi
+ call_xenguest_mkimage partial --xen-device-tree=${XENGUEST_EXTRA_DTB}
+ fi
+
+ if [ -n "${XENGUEST_EXTRA_XENCONFIG}" ]; then
+ for f in ${XENGUEST_EXTRA_XENCONFIG}; do
+ if [ ! -f $f ]; then
+ die "xenguest-image: Xen config $f does not exist"
+ fi
+ call_xenguest_mkimage partial --xen-append=$f
+ done
+ fi
+
+ if [ -n "${XENGUEST_EXTRA_INIT_PRE}" ]; then
+ if [ ! -f ${XENGUEST_EXTRA_INIT_PRE} ]; then
+ die "xenguest-image: Init script ${XENGUEST_EXTRA_INIT_PRE} does not exist"
+ fi
+ call_xenguest_mkimage partial --init-pre=${XENGUEST_EXTRA_INIT_PRE}
+ fi
+
+ if [ -n "${XENGUEST_EXTRA_INIT}" ]; then
+ if [ ! -f ${XENGUEST_EXTRA_INIT} ]; then
+ die "xenguest-image: Init script ${XENGUEST_EXTRA_INIT} does not exist"
+ fi
+ call_xenguest_mkimage partial --init-script=${XENGUEST_EXTRA_INIT}
+ fi
+
+ if [ -n "${XENGUEST_EXTRA_INIT_POST}" ]; then
+ if [ ! -f ${XENGUEST_EXTRA_INIT_POST} ]; then
+ die "xenguest-image: Init script ${XENGUEST_EXTRA_INIT_POST} does not exist"
+ fi
+ call_xenguest_mkimage partial --init-post=${XENGUEST_EXTRA_INIT_POST}
+ fi
+
+ if [ -n "${XENGUEST_EXTRA_FILES}" ]; then
+ for f in ${XENGUEST_EXTRA_FILES}; do
+ if [ ! -f $f ]; then
+ die "xenguest-image: Xen file $f does not exist"
+ fi
+ call_xenguest_mkimage partial --xen-add-file=$f
+ done
+ fi
+
+ if [ -n "${XENGUEST_EXTRA_DISK_FILES}" ]; then
+ for f in ${XENGUEST_EXTRA_DISK_FILES}; do
+ if [ ! -f $f ]; then
+ die "xenguest-image: Disk file $f does not exist"
+ fi
+ call_xenguest_mkimage partial --disk-add-file=$f
+ done
+ fi
+}
+# Need to have xenguest-image tool
+do_deploy[depends] += "xenguest-base-image:do_deploy"
+
diff --git a/bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image.bbclass b/bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image.bbclass
new file mode 100644
index 00000000..e8880f3f
--- /dev/null
+++ b/bsp/meta-arm/meta-arm-autonomy/classes/xenguest-image.bbclass
@@ -0,0 +1,195 @@
+# This class must be used to create, extend or pack a xenguest image.
+# It is using xenguest-mkimage tool to do operations
+
+DEPENDS += "xenguest-mkimage-native"
+
+#
+# Xenguest image parameters
+# All the following parameters can be modified in local.conf or on recipes
+# inheriting this class
+#
+
+# Guest memory size in MB
+XENGUEST_IMAGE_MEMORY_SIZE ??= "512"
+
+# Guest number of vcpus
+XENGUEST_IMAGE_NUM_VCPUS ??= "1"
+
+# Guest auto boot during init, set to 1 to have guest started during init or
+# to 0 if the guest should not be auto started
+XENGUEST_IMAGE_AUTOBOOT ??= "1"
+
+# Partition containing the root file system
+# Xen will actually add root=${XENGUEST_IMAGE_ROOT} to your guest kernel
+# command line
+# You can let this empty if the root filesystem is specified in an other way
+# and have root= option added to the command line for example or if you don't
+# need a root filesystem mounted for your guest (initrd for example)
+XENGUEST_IMAGE_ROOT ??= "/dev/xvda1"
+
+# Guest kernel command line arguments
+XENGUEST_IMAGE_CMDLINE ??= "earlyprintk=xenboot console=hvc0 rw"
+
+# Extra commands to add to xenguest-image when creating the image
+XENGUEST_IMAGE_EXTRA_CMD ??= ""
+
+# Kernel binary
+# This value is used by the xenguest image type but is declared here to have
+# all variables in the same place
+# If this value is empty no kernel will be added to the image
+XENGUEST_IMAGE_KERNEL ??= "Image"
+
+# Size of the disk to create (if 0 no disk will be created and rootfs will not
+# be included in the xenguest image)
+XENGUEST_IMAGE_DISK_SIZE ??= "${@ '4' if not d.getVar('INITRAMFS_IMAGE') else '0'}"
+
+#
+# XENGUEST_IMAGE_DISK PARTITIONS is used to describe the partitions to setup
+# and their content.
+# It must be set to a space separated list of entries with each entry having
+# the format num:sz:fs:[file] where:
+# - num is a partition number
+# - sz is the partition size in Gigabit
+# - fs is the filesystem to use for the partition
+# - file is optionally pointing to a file to use as content of the partition
+# Please check image_types_xenguest.bbclass for rootfs handling of files
+#
+# Default value creates a partition 1 using the full disk, formated with ext4
+# and containing the root filesystem produced by Yocto
+XENGUEST_IMAGE_DISK_PARTITIONS ??= "1:${XENGUEST_IMAGE_DISK_SIZE}:ext4:rootfs.tar.gz"
+
+# XENGUEST_IMAGE_NETWORK_BRIDGE can be set to 1 to have a network interface
+# on the guest connected to host bridged network. This will provide the guest
+# with a network interface connected directly to the external network
+XENGUEST_IMAGE_NETWORK_BRIDGE ??= "1"
+
+# Sub-directory in wich the guest is created. This is create in deploy as a
+# subdirectory and must be coherent between all components using this class so
+# it must only be modified from local.conf if needed
+XENGUEST_IMAGE_DEPLOY_SUBDIR ?= "xenguest"
+
+# Directory in which the xenguest should be deployed
+# a sub-directory named ${XENGUEST_IMAGE_DEPLOY_SUBDIR} will be created there.
+# This should be set to:
+# - ${DEPLOYDIR} (default) if creating or extending the xenguest for a normal
+# recipe.
+# - something in ${WORKDIR} if you need to clone and manipulate an image
+XENGUEST_IMAGE_DEPLOY_DIR ??= "${DEPLOYDIR}"
+
+#
+# Wrapper to call xenguest-mkimage
+# It is using XENGUEST_IMAGE_DEPLOY_DIR and XENGUEST_IMAGE_DEPLOY_SUBDIR
+# to find the image to operate on
+#
+# Usage: call_xenguest_mkimage [operation] [args]
+call_xenguest_mkimage() {
+ local cmd="${1}"
+ local img="${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}"
+ shift
+
+ echo "xenguest-mkimage $cmd $img $@"
+ xenguest-mkimage $cmd $img $@
+}
+
+#
+# Create an initial xenguest image.
+# This is a task which must be added in a recipe inheriting deploy
+# It is using XENGUEST_IMAGE_MEMORY_SIZE, XENGUEST_IMAGE_NUM_VCPUS,
+# XENGUEST_IMAGE_AUTOBOOT, XENGUEST_IMAGE_ROOT, XENGUEST_IMAGE_EXTRA_CMD,
+# XENGUEST_IMAGE_CMDLINE, XENGUEST_IMAGE_DISK_SIZE and
+# XENGUEST_IMAGE_DISK_PARTITIONS to customize the initial guest
+#
+xenguest_image_create() {
+ if [ -z "${XENGUEST_IMAGE_DEPLOY_DIR}" -o \
+ -z "${XENGUEST_IMAGE_DEPLOY_SUBDIR}" ]; then
+ die "Configuration error: XENGUEST_IMAGE_DEPLOY_DIR or XENGUEST_IMAGE_DEPLOY_SUBDIR is empty"
+ fi
+
+ rm -rf ${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}
+
+ mkdir -p ${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}
+
+ # Create the image
+ call_xenguest_mkimage create --xen-memory=${XENGUEST_IMAGE_MEMORY_SIZE} \
+ --xen-vcpus=${XENGUEST_IMAGE_NUM_VCPUS} \
+ --xen-root=${XENGUEST_IMAGE_ROOT} \
+ ${XENGUEST_IMAGE_EXTRA_CMD}
+
+ # add command line
+ if [ -n "${XENGUEST_IMAGE_CMDLINE}" ]; then
+ call_xenguest_mkimage update --xen-clean-extra
+ for arg in ${XENGUEST_IMAGE_CMDLINE}; do
+ call_xenguest_mkimage update --xen-extra=$arg
+ done
+ fi
+
+ # create disk if needed
+ disksize="${XENGUEST_IMAGE_DISK_SIZE}"
+ if [ -z "$disksize" ]; then
+ disksize="0"
+ fi
+ if [ $disksize -gt 0 ]; then
+ # setup disk size
+ call_xenguest_mkimage update --disk-reset-config --disk-size=$disksize
+
+ diskparts="${XENGUEST_IMAGE_DISK_PARTITIONS}"
+ if [ -n "$diskparts" ]; then
+ for arg in $diskparts; do
+ call_xenguest_mkimage update --disk-add-part=$arg
+ partnum="$(expr $partnum + 1)"
+ done
+ fi
+ fi
+
+ if [ "${XENGUEST_IMAGE_AUTOBOOT}" = "1" ]; then
+ call_xenguest_mkimage update --set-param=GUEST_AUTOBOOT=1
+ else
+ call_xenguest_mkimage update --set-param=GUEST_AUTOBOOT=0
+ fi
+
+ if [ "${XENGUEST_IMAGE_NETWORK_BRIDGE}" = "1" ]; then
+ call_xenguest_mkimage update --set-param=NETWORK_BRIDGE=1
+ else
+ call_xenguest_mkimage update --set-param=NETWORK_BRIDGE=0
+ fi
+}
+
+#
+# Clone the current xenguest from deploy to manipulate it locally
+# This is required if you need to change things before packing an image
+# To set the local directory where to clone you must set
+# XENGUEST_IMAGE_DEPLOY_DIR if you don't want to use do_deploy to modify the
+# image
+#
+xenguest_image_clone() {
+ if [ -z "${XENGUEST_IMAGE_DEPLOY_DIR}" -o \
+ -z "${XENGUEST_IMAGE_DEPLOY_SUBDIR}" ]; then
+ die "Configuration error: XENGUEST_IMAGE_DEPLOY_DIR or XENGUEST_IMAGE_DEPLOY_SUBDIR is empty"
+ fi
+
+ if [ ! -f ${DEPLOY_DIR_IMAGE}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}/guest.cfg ]; then
+ die "xenguest-image: ${DEPLOY_DIR_IMAGE}/${XENGUEST_IMAGE_DEPLOY_SUBDIR} does not contain a valid guest"
+ fi
+
+ rm -rf ${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}
+ mkdir -p ${XENGUEST_IMAGE_DEPLOY_DIR}
+ cp -rf ${DEPLOY_DIR_IMAGE}/${XENGUEST_IMAGE_DEPLOY_SUBDIR} \
+ ${XENGUEST_IMAGE_DEPLOY_DIR}/${XENGUEST_IMAGE_DEPLOY_SUBDIR}
+}
+
+# Helper function to retrieve rootfs file if present in one partition
+# This can return an empty string or rootfs.tar[.COMP]
+def xenguest_image_rootfs_file(d):
+ disksize = d.getVar('XENGUEST_IMAGE_DISK_SIZE')
+ # if disksize is 0, we don't create anything
+ if not disksize or disksize == '0':
+ return ""
+ # Find first partition with file=rootfs.tar*
+ partlist = d.getVar('XENGUEST_IMAGE_DISK_PARTITIONS')
+ if partlist:
+ for partdesc in partlist.split():
+ partelems = partdesc.split(':', 3)
+ if partelems[3]:
+ if partelems[3].startswith('rootfs.tar'):
+ return partelems[3]
+ return ""