Installing multiple folders - yocto

I'm relativly new to the whole Yocto Project.
Basically I want to add multiple folders to the image:
do_install() {
install -d ${D}/etc/wpa_supplicant
install -m 0777 wpa_supplicant-wired-eth0.conf ${D}/etc/wpa_supplicant
install -d ${D}/mydata
install -d ${D}/mydata/certs
}
wpa_supplicant needs a conf file in /etc/wpa_supplicant. So I install the folder and copy my custom conf file there.
This works FINE
Simultaneously I want to install a certificate folder under /mydata/certs where I can later upload my certificates for the wpa_supplicant.
But when I do do that Yocto tells me the old install vs shipped error
mywpa-1.0-r0 do_package: QA Issue: mywpa: Files/directories were installed but not shipped in any package:
/mydata
/mydata/certs
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
mywpa: 2 installed and not shipped files. [installed-vs-shipped]
ERROR: mywpa-1.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: mywpa-1.0-r0 do_package: Function failed: do_package
ERROR: Logfile of failure stored in: /home/yocto/yocto/build/tmp/work/cortexa7hf-neon-vfpv4-phytec-linux-gnueabi/mywpa/1.0-r0/temp/log.do_package.31833
ERROR: Task (/home/yocto/yocto/sources/poky/../meta-mydata/meta-mywpa/recipes-mywpa/mywpa/mywpa.bb:do_package) failed with exit code '1'
Previously I just worked I had ONE folder per recipe and just added
FILES_${PN} += "${sysconfdir}/etc"
So my question is basically: How do I install two folders in two different directories? Or is impossible in a single recipe and I have to use two recipes?

The FILES_${PN} += expression can be almost arbitrarily complex, as long as it is static at parse time. So you should be able to just expand it as needed:
FILES_${PN} += " \
${sysconfdir}/etc/wpa_supplicant \
/mydata \
"
If there's any problems with that approach, please update the question then I can look into it.

Related

rpmbuild unable to find the custom installed package

There are plenty of perl packages missing in Centos 8 and Rocky Linux. So, I try to get the rpm spec by cpanspec and build rpm by myself. But, it seems like that rpmbuild could not find the rpm I built.
This is the script for me to build rpm.
cd /root/rpmbuild
cpanspec --packer 'Example <example#example.com>' <Perl-Package-Name>
mkdir SOURCES
cp <Perl-Package-Name>.tar.gz SOURCES
rpmbuild -ba perl-<Package-Name>.spec
Let's say we have two package A and B. A is needed by B.
I try to build both of the packages through the script above. I build A first, switch into /root/rpmbuild/RPMS/noarch and install A.rpm. Then, I try to build package B.
I got
error: Failed build dependencies:
perl(A) is needed by perl-<B>
I try to check the existence of package A.
yum list installed | grep A
and
perldoc -l A
Both of the commands show that A exists.
Did I miss something?
update 2022/06/07
I just gave up and commented the BuildRequires: A in B package. This is not a good approach but it works.

How to install file in include directory yocto

I'm trying install files extracted from tar file, but non of my files are installing under usr/include directory on target board, but I see my files under temp/work/aarch64/recipedir/image/usr/include/mydir/ and include/myfile.h. While building I haven't got any errors.
do_install() {
install -d ${D}${includedir}
mkdir -p ${D}${includedir}/mydir
install -m 0644 ${S}/include/myfile.h ${D}${includedir}
install -m 0644 ${S}/include/mydir/*.h ${D}${includedir}/mydir/
}
FILES_${PN} += "${includedir}/mydir
Everything in ${includedir} is put into ${PN}-dev by default.
c.f.: https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/bitbake.conf#n316
You have to remember that a file can only be in one package. To determine in which package a file is going to make it, it's pretty simple. Starting from leftmost package in PACKAGES, the first package to have the file matching any path in FILES_<pkg> will have the file.
By default, ${PN}-dev appears before ${PN} in PACKAGES.
c.f.: http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/bitbake.conf#n294
You can check which package has your file without "reverse-engineering" the whole thing by running oe-pkgdata-util find-path '/usr/include/mydir'.
If you really want this header file in your system (why?), you can either add ${PN}-dev to your image or hack things (remove the -dev package from PACKAGES or move ${PN} before ${PN}-dev, if you only have one file in ${includedir}, etc.).

Bitbake QA requires deletion of {bindir}

I have a relatively simple receipt file (stripped version of the ntp) with no installation of the {bindir}. However, unless I explicitly remove the {bindir} in the do_install_append I get a QA error saying:
ERROR: ntp-4.2.8p9-r0 do_package: QA Issue: ntp: Files/directories were installed but not shipped in any package:
/usr/bin
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
ntp: 1 installed and not shipped files. [installed-vs-shipped]
ERROR: ntp-4.2.8p9-r0 do_package: Fatal QA errors found, failing task.
Why is the removal needed in this recipe? Is there some other recipe that is installing {bindir}?
There is some default do_install provided by https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/base.bbclass. If you only want to install what you want. Please overwrite do_install () instead of do_install_append (). Otherwise you need to add all files FILES_${PN}.

CMake install directory permission

I have built a project using cmake (LLVM project) and tried to install it by issuing the following command:
$ cmake3 --build . --target install
If I run it using root then there is no problem and the files will be installed under the directory /usr/local/.
My problem is when I want to install the project using normal user.
I get the following error:
CMake Error at cmake_install.cmake:36 (file):
file INSTALL cannot set permissions on "/usr/local/include/llvm"
I have changed the permission of directory /usr/local/ to 777 recursively, and their ownership to root:wheel and I added my normal user to group wheel. But I still cannot install the files into the /usr/local/ directory.
The main issue is about building project in Eclipse which fails at "Build Install" command.
chmod 777 -R / is a very scary command. I've destroyed a system once by doing that.
The philosophy I use for this is:
If I need to deploy something through my IDE to debug or test before packaging, I deploy it locally within my home directory.
I only install stuff to my system (outside of home) if it has been packaged first (*.deb, *.rpm, *.tar.gz) so that I can remove it without problems.
For me, I do this with:
cmake $src
cmake --build . --target install -- DESTDIR=stage
This will configure my project, make it, then install it locally in a folder called ./stage which resides in my build directory. I can then run my executable from ./stage/usr/bin. Note that this only works if make is your generator.
Once I've tested it and I'm happy, I package it and deploy to my system or upload to a repository:
cpack
sudo dpkg -i <package>.deb
We should use USE_SOURCE_PERMISSIONS in our install function.
Example:
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Release/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" USE_SOURCE_PERMISSIONS)

pip -r not working as expected in virtualenv

I have a really strange issue with the behavior of pip in a virtualenv.
I have set
export PIP_REQUIRE_VIRTUALENV=true
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
export VIRTUALENV_DISTRIBUTE=true
Now, when I'm in my virtualenv and want to install my dependencies:
pip install -r requirements/_base.txt
(for testing purposes, requirements/_base.txt only contains:)
Django==1.5
Anyway, when I try to install it, I only get:
Downloading/unpacking Django==1.5 (from -r requirements/_base.txt (line 1))
Running setup.py egg_info for package Django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
And after that, Django is not installed.
Here comes the strange part: When I install Django manually with
pip install Django==1.5
it's working perfectly (though the same two warnings appear):
Downloading/unpacking Django==1.5
Running setup.py egg_info for package Django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: Django
Running setup.py install for Django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
changing mode of /usr/local/share/python/django-admin.py to 755
Successfully installed Django
Cleaning up...
I faced a similar problem and realized that removing the version requirement solved the problem. Don't know why though...
I figured out why this was happening to me, which may also solve the problem for others who see this page. For me, the problem was that I had a requirement that can not install automatically via pip. The pip freeze exported the package name and version but, for whatever reason, pip cannot install that package directly in a requirements install. I have to instead install it manually from a zip file.
The problem you might be experiencing, then, is that you have a requirement which cannot be installed by pip's requirements installer. Check your output log for red text, errors, that sort of thing.
I figured this out using this post:
pip fails to install packages from requirements.txt