diff options
Diffstat (limited to 'bsp/meta-arm/meta-arm-autonomy/recipes-core')
3 files changed, 154 insertions, 0 deletions
diff --git a/bsp/meta-arm/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb b/bsp/meta-arm/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb new file mode 100644 index 00000000..5b20fa09 --- /dev/null +++ b/bsp/meta-arm/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb @@ -0,0 +1,120 @@ +# Recipe to create a minimal Arm Autonomy stack host image + +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 +# image for performance reasons. It doesn't include all kernel modules to +# reduce the image size. If the kernel-modules packages are needed they can +# be appended to IMAGE_INSTALL in a bbappend. +IMAGE_INSTALL += " \ + packagegroup-core-boot \ + packagegroup-core-ssh-openssh \ + qemu-xen \ + xenguest-manager \ + xenguest-network-bridge \ + " + +# Build xen binary +EXTRA_IMAGEDEPENDS += "xen" + +# Build xen-devicetree to produce a xen ready devicetree +EXTRA_IMAGEDEPENDS += "xen-devicetree" + +python __anonymous() { + if bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', False, True, d): + raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'arm-autonomy-host'") + + 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' + if not bb.utils.copyfile(path, guestdir + '/' + dstname): + bb.fatal("Fail to copy Guest file " + path) +} + +IMAGE_PREPROCESS_COMMAND += "add_extern_guests; " + diff --git a/bsp/meta-arm/meta-arm-autonomy/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/bsp/meta-arm/meta-arm-autonomy/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend new file mode 100644 index 00000000..1d97e50c --- /dev/null +++ b/bsp/meta-arm/meta-arm-autonomy/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -0,0 +1,18 @@ +# Add support for interface configuration via interfaces.d directory. This +# feature can be used by other packages to add network interface +# configuration by adding network network interface configuration file under +# interfaces.d directory. + +do_install_append() { + # Add scan of interfaces.d to interfaces file + cp -f ${WORKDIR}/interfaces ${WORKDIR}/interfaces.subdir + echo "source-directory ${sysconfdir}/network/interfaces.d/" \ + >> ${WORKDIR}/interfaces.subdir + + # Create interfaces.d script in case nobody is adding a script + # so that there is no error about non existing directory + install -d -m 755 ${D}${sysconfdir}/network/interfaces.d + + # Install our file instead of the original one + install -m 644 interfaces.subdir ${D}${sysconfdir}/network/interfaces +} diff --git a/bsp/meta-arm/meta-arm-autonomy/recipes-core/sysvinit/sysvinit-inittab_2.%.bbappend b/bsp/meta-arm/meta-arm-autonomy/recipes-core/sysvinit/sysvinit-inittab_2.%.bbappend new file mode 100644 index 00000000..7b0c6472 --- /dev/null +++ b/bsp/meta-arm/meta-arm-autonomy/recipes-core/sysvinit/sysvinit-inittab_2.%.bbappend @@ -0,0 +1,16 @@ +# if arm-autonomy-guest is activated, we are running as a xen guest so we must +# have a console on hvc0 +# This is normally done in meta-virtualization if xen is activated but here +# we don't have xen activated. +# + +SYSVINIT_ADDHVC0 = "${@bb.utils.contains('DISTRO_FEATURES', \ + 'arm-autonomy-guest', 'true', 'false', d)}" + +do_install_append() { + if ${SYSVINIT_ADDHVC0}; then + echo "" >> ${D}${sysconfdir}/inittab + echo "X0:12345:respawn:/sbin/getty 115200 hvc0" >> \ + ${D}${sysconfdir}/inittab + fi +} |