Adding (buried) features from Yocto layers that are present in your build - yocto

I'm a neophyte with Yocto, though I have been able to glean enough from tutorials to create an image that meets some of the requirements for my current project. I'm able to create my own layer and recipe so I can generate it with bitbake, e.g. bitbake mycustomimage.
I'm working with a beaglebone and the tutorials I've followed state you need the following layers:
meta-arm
meta-ti
poky (of course)
Just following the beagelbone tutorials will allow you to create a variety of prepackaged images from default recipes. However, tutorials and Yocto documentation do not explain how to access features and applications contained in the existing layers but are not utilized by the default recipes. I'm aware that you can use the IMAGE_FEATURE and EXTRA_IMAGE_FEATURE variables to add some (prepackaged) support.
I've come up with a way to add features from other layers by copying them into my custom layer directory structure and adding them to my customimage.bb file. This technique feels hacky and potentially error prone, also it duplicates files and directories found in other layers. My question is:
How are you supposed to add features from existing layers added to your project? For example I'll be needing PRU support for my beaglebone project, I know where those features are in the meta-ti layer (found in the recipes-bsp/ directory). How can I access that support and those features without a stupid hack? There must be a way.
Here's an example. I needed xorg-minimal-fonts installed, the recipe is contained in the poky/meta/recipes-graphics directory. I copied the contents into my custom layer which looks something like this:
mycustomimage
├── conf
│   └── layer.conf
└── recipes-core
├── images
│   └── core-image-mycustomimage.bb
└── xorg-font
├── encodings
│   └── nocompiler.patch
├── encodings_1.0.5.bb
├── font-alias-1.0.3
│   └── nocompiler.patch
├── font-alias_1.0.3.bb
├── font-util_1.3.2.bb
├── xorg-font-common.inc
├── xorg-minimal-fonts
│   └── misc
│   ├── 6x13B-ISO8859-10.pcf.gz
...(a bunch of zipped fonts)
│   ├── cursor.pcf.gz
│   └── fonts.dir
└── xorg-minimal-fonts.bb
My custom layer .bb file looks like this:
IMAGE_FEATURES_append = " x11-base ssh-server-dropbear hwcodecs"
IMAGE_FEATURES_remove = "allow-empty-password"
IMAGE_FEATURES_remove = "empty-root-password"
require recipes-core/xorg-font/xorg-minimal-fonts.bb
IMAGE_INSTALL = "\
packagegroup-core-boot \
packagegroup-core-full-cmdline \
${CORE_IMAGE_EXTRA_INSTALL} \
xorg-minimal-fonts \
"
inherit core-image extrausers
I know this is not how you're supposed do this, but it did work.

If you have a custom layer with a custom image, you can add any recipe that is in other layer.
If you copied xorg-font folder for that reason, it means that you need to copy all folders also of what you set in IMAGE_INSTALL.
You do not need to require the xorg-minimal-fonts recipe in the image recipe.
Also, IMAGE_INSTALL = .. will override the IMAGE_INSTALL of core-image class, so here is your custom image after some fixes:
# Inherit core-image because it already has:
#
# CORE_IMAGE_BASE_INSTALL = '\
# packagegroup-core-boot \
# packagegroup-base-extended \
# \
# ${CORE_IMAGE_EXTRA_INSTALL} \
# '
# ...
# IMAGE_INSTALL ?= "${CORE_IMAGE_BASE_INSTALL}"
inherit core-image extrausers
# Activate features
#
# Activate x11-base only if x11 is in DISTRO_FEATURES
IMAGE_FEATURES_append = " ${#bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11-base', '', d)}"
IMAGE_FEATURES_append = " ssh-server-dropbear hwcodecs"
IMAGE_FEATURES_remove = "allow-empty-password"
IMAGE_FEATURES_remove = "empty-root-password"
# Add custom recipes
IMAGE_INSTALL_append = " xorg-minimal-fonts"

Related

Yocto Error : Could not inherit file classes/qt6-cmake.bbclass

I'm currently trying to 'boot 2 qt'
I add layers, at "bblayers.conf"
like this.
/yocto/kirkstone/meta-boot2qt/meta-boot2qt \
and also set machine at "local.conf"
when I try to bitbake, the error occurs like this
Input : bitbake b2qt-embedded-qt6-image
Output: ERROR: ParseError at /home/seame-fablab/yocto/kirkstone/meta-boot2qt/meta-boot2qt/recipes-qt/boot2qt-addons/qdb_git.bb:36: Could not inherit file classes/qt6-cmake.bbclass
ERROR: Parsing halted due to errors, see error messages above
how to solve the errors
I believe its likely you are simply missing the layer where qt6-cmake.bbclass belongs to.
Its hard to say if you missed cloning it, or just adding it to your bblayers.conf since you didnt really specify how you actually cloned the repos, but the README for meta-boot2qt suggests you use repo for such task, which should've taken care of that for you.
For example, using
mkdir ~/mybuilddir
cd ~/mybuilddir/
repo init -u git://code.qt.io/yocto/boot2qt-manifest -m 6.5.xml
repo sync
would get you a structure like this:
$ tree -L 2
.
├── setup-environment.sh -> sources/meta-boot2qt/scripts/setup-environment.sh
└── sources
├── meta-boot2qt
├── meta-freescale
├── meta-freescale-3rdparty
├── meta-intel
├── meta-mingw
├── meta-openembedded
├── meta-qt6
├── meta-raspberrypi
├── meta-tegra
├── meta-toradex-bsp-common
├── meta-toradex-nxp
├── poky
└── templates -> meta-boot2qt/meta-boot2qt-distro/conf/templates/default
And the class you are missing is located at:
./sources/meta-qt6/classes/qt6-cmake.bbclass
Now, if you for some reason dont want to use repo and would like to manually clone the required layers, you are also welcome to do that, you just need to clone meta-qt6:
git clone https://code.qt.io/cgit/yocto/meta-qt6.git/
and add it to your bblayers.conf
bitbake-layers add-layer <path-to-meta-qt6-layer-you-just-cloned>

Pytest set default path/directory/fodler as project directory (solve FileNotFoundError)

I have the next tree:
root_project/
├── app
│   ├── default_photo_profile.jpg
│   ├── config.py
│   ├── __main__.py # My app are python package, I'm runnig it via "python -m"
│   └── ...
├── tests
│   ├── test_unit.py # import config.py inside
│   ├── functional # import config.py inside
│   ├── pytest.ini
│   └── ...
...
Currently default_photo_profile causing error because tests doesn't have this file.
Reading file in config.py:
DEFAULT_PHOTO_FILE_PATH = Path('default_photo.jpg')
with open(file=DEFAULT_PHOTO_FILE_PATH, mode='rb') as file_obj:
DEFAULT_PHOTO_BYTES = file_obj.read()
How I can solve this?
I tried:
Patch access to default_photo.jpg with fixture - not helped, error during import stage, not executiion.
set flag to pytest comamnd line: --rootdir app - not helped (don't know why).
try/except for reading the file in app.config.py - may help but it's not my intention, I really want raise error if file not found
Put default_photo.jpg inside EVERY test directory - will help bit dirty.
Patch os.path like suggested in https://stackoverflow.com/a/43003192/11277611 - dirty
Include tests into package (move __main__.py into root_project - not sure that it's a good idea (have not enough experience to decide).
Set absolut path to default_photo.jpg - will fail on the production server.
Probably adoptable solutions (What I want):
Set root dir to root_project.app somehow inside pytest.ini to immitate regular execution.
Set root dir to root_project.tests somehow to place file in root of tests and access from any of tests folder.
Try to use following code in config.py:
DEFAULT_PHOTO_FILE_PATH = Path(__file__).parent / 'default_photo.jpg'
with open(file=DEFAULT_PHOTO_FILE_PATH, mode='rb') as file_obj:
DEFAULT_PHOTO_BYTES = file_obj.read()
Is it what you are trying to achieve?

Using Dist::Zilla dist.ini how can I have files that I only use for testing?

In a Dist::Zilla-based distribution I would like to have some files that are only used for testing, but do not get installed. These are mockup libs that aren't needed for runtime.
How do I do that?
CPAN distributions never install the t and xt directories. You can put your tests and your mock libs into t.
As an example, take my module MooseX::LocalAttribute. In the dist, there is a t/, a t/lib and an xt/.
If you install this using cpanm -l into a local lib dir, you will see there are no tests installed. This happens automatically. It's just how CPAN works.
$ cpanm -l mylib MooseX::LocalAttribute
--> Working on MooseX::LocalAttribute
Fetching http://www.cpan.org/authors/id/S/SI/SIMBABQUE/MooseX-LocalAttribute-0.05.tar.gz ... OK
Configuring MooseX-LocalAttribute-0.05 ... OK
Building and testing MooseX-LocalAttribute-0.05 ... OK
Successfully installed MooseX-LocalAttribute-0.05
1 distribution installed
$ tree mylib
mylib
├── lib
│   └── perl5
│   ├── MooseX
│   │   └── LocalAttribute.pm
│   └── x86_64-linux
│   ├── auto
│   │   └── MooseX
│   │   └── LocalAttribute
│   └── perllocal.pod
└── man
└── man3
└── MooseX::LocalAttribute.3
9 directories, 3 files
Note that as long as stuff is in t/lib (or anywhere under t/, really), you do not have to hide the package names from the PAUSE indexer. It's smart enough to not find it.
I misunderstood the question. This answer is for the following question:
How do I exclude files from a Dist::Zilla based distribution so they don't get shipped at all?
You are probably using either the GatherDir or Git::GatherDir plugin to build your bundle. Both of them have an option exclude_filename that you can set in your dist.ini to not include a file in a bundle.
A common pattern is to exclude auto-generated files such as LICENSE or META.json, and then add them later with another plugin. But you don't have to do that, you can just exclude files completely.
A good example is the URI distribution. On metacpan, it does not include any text files in the bundle. But if you look at the repository on github, you can see there are various .txt files such as rfc2396.txt. The dist.ini contains the following lines.
[Git::GatherDir]
exclude_filename = LICENSE
exclude_filename = README.md
exclude_filename = draft-duerst-iri-bis.txt
exclude_filename = rfc2396.txt
exclude_filename = rfc3986.txt
exclude_filename = rfc3987.txt
As mentioned before, the LICENSE and README.md files will still appear in the final bundle, because they get added later via #Git::VersionManager.

How to provide the U-Boot default environment from a file in Yocto?

I want to avoid setting the default environment in CONFIG_EXTRA_ENV_SETTINGS, therefore I've set CONFIG_DEFAULT_ENV_FILE="uEnv.txt" and created that text file but bitbake doesn't find it:
make[1]: *** No rule to make target 'uEnv.txt', needed by 'include/generated/defaultenv_autogenerated.h'. Stop.
This is what the tree and the files look like:
└── u-boot
├── files
│   ├── ma1.cfg
│   └── uEnv.txt
└── u-boot-xlnx_%.bbappend
ma1.cfg:
CONFIG_USE_DEFAULT_ENV_FILE=y
CONFIG_DEFAULT_ENV_FILE="uEnv.txt"
u-boot-xlnx_%.bbappend:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI_append_tmc = " \
file://ma1.cfg \
file://uEnv.txt \
"
PACKAGE_BEFORE_PN += "${PN}-env"
RPROVIDES_${PN}-env += "u-boot-default-env"
I don't know where to put the uEnv.txt so it will be found. I already (blindly) tried to specify some different paths like CONFIG_DEFAULT_ENV_FILE="../uEnv.txt" but to no avail. I suspect that I need to put it somewhere in a do_configure_append() but I don't know where.
Searching for CONFIG_DEFAULT_ENV_FILE only yields results which state that it can be used to create the environment from a file[1], but unfortunately not how. Or, more precisely: How to use it with bitbake.
So I hope someone can help me here: What do I need to do so bitbake places the text file where make is going to find it?
[1] https://lists.denx.de/pipermail/u-boot/2018-March/323347.html
You need to pass your uEnv.txt file to the build directory to be found by Make.
You can do this in your bbappend file like:
do_configure_append() {
cp ${WORKDIR}/uEnv.txt ${S}
}

inheritance-diagrams in sphinx for matlab

I am documenting a matlab code that I have with sphinx. I am using the package sphinxcontrib-matlabdomain.
My directory tree is as follows:
me:~/.../doc$ tree ../
../
├── doc
│   ├── conf.py
│   ├── make.bat
│   ├── Makefile
│   ├── index.rst
│   ├── BaseClass.rst
│   └── DerivedClass.rst
├── LICENSE.md
├── README.md
└── src
├── BaseClass.m
└── DerivedClass.m
The problem comes when I want to show inheritance diagrams. I have added the necessary things in my config.py file:
matlab_src_dir = os.path.abspath('..')
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.graphviz',
'sphinx.ext.viewcode',
'sphinxcontrib.matlab',
]
primary_domain = 'mat'
And I have the following in the index.rst file
Welcome to BGK's documentation!
===============================
I am trying to have a diagram here...
.. inheritance-diagram:: BaseClass DerivedClass
:parts:2
.. graphviz::
digraph {
"From here" -> "To" -> "Somewhere";
"From here" -> "To" -> "Somewhere else";
}
And in the output the directive inheritance-diagram is ignored, obtaining directly the next diagram that I am using to test that I can plot diagrams.
Is there any incompatibility to plot inheritance diagrams with sphinx for matlab classes? Is there any way to go around the problem? Thanks!
Sphinx does not support this. The built-in sphinx.ext.inheritance_diagram extension is for the Python domain only. It does not work for Matlab. If it did, I'm sure it would say so in the Sphinx documentation (and a glance at the source code in sphinx/ext/inheritance_diagram.py confirms that it is only for Python).
The only way inheritance diagrams for Matlab could work is if some other extension provided the functionality. The sphinxcontrib-matlabdomain extension that you use does not.