How to install file in include directory yocto - 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.).

Related

What changes needed in .spec file to rename installing software?

I am trying to rebuild nano rpm package on CentOS 8 so after installing it I will be able to run nano using command newnano.
After some googling I came to the conclusion that I need to change .spec file and build package using command rpmbuild -ba nano.spec.
Here is what I've already tried:
Changing name in the beginning of .spec file, so it looked like that:
Summary: A small text editor Name: newnano ...
But when I tried to build package there was error: Bad exit status from '/var/tmp/rpm-tmp.DSP7dc (%prep) As I understand after unzip tar archive its tried to cd newnano-2.9.8 but there is no such directory.
Adding alias in %install section:
%install cd build %make install rm -f %{buildroot}%{_infodir}/dir
alias newnano="nano" ...
Building and installation was successful but alias was not created.
Using %package. I insert after %description and before %prep in original .spec this:
%package -n newnano Summary: test %description -n newnano test
Also I add -n newnano to %files section. Building and installation was successful but new command was not added.
So how I have to change .spec file to achieve my goal?
There is a very simpe way to do it via rpmrebuild and .rpm nano package.
rpmrebuild -enp nano.rpm
In .spec file (it will open after previous comand) you should do these:
replace Name: nano with Name: newnano (optional, but recommended)
add mv /usr/bin/nano /usr/bin/newnano before the first exit 0 line. This section you can find before %changelog
Look carefully and remember the path of rebuilded .rpm that you will see after you close vim
Install rebuilded .rpm via rpm -i command
(Optional: maybe you will need to reboot)
You'll have to do a few things:
Get the current specfile (looks like you did that)
Change the name of the RPM (looks good)
Change the name of the GNU package (hint: look in configure.ac)
Add another patch to the RPM that modifies the final executables (hint: look in src/Makefile.am - you want to rename nano and remove the rnano symlink)
Rebuild
Instead of messing with src/Makefile.am, you can probably rename things in the %install stanza of the specfile, but I don't know enough about nano to tell you if it will be still identifying itself properly, etc.
Have fun!

Installing multiple folders

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.

Unable to copy docs to /usr/share/doc ${docdir} yocto

I am working with yocto, i want to copy some documents into rootfs.
when i copy them they are present inside
packages-split/Ex-doc/usr/share/doc/versions/Ex.txt
Now i want to copy from here into rootfs, below are the changes i have made inside recipe
do_install() {
install -m 0755 -d ${D}${docdir}/versions
install -m 0755 ${S}/Ex.txt ${D}${docdir}/versions
}
FILES_${PN}-doc += "${docdir}/versions"
But i am not able to see /usr/share/doc dir inside rootfs. Please point me where i am doing wrong.
Thank You
Did you add the package FILES_${PN}-doc to the list of packages installed in the image?

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)

Installing library on dev server without touching anything

I want to install wkhtmltopdf library inside /home/dev directory, and I can't touch anything else outside of this directory, because it's not my server.
The file has .deb extension, I have run in /home/dev:
$ wget "http://file-to-install.com/"
$ dpkg -x my_file.deb
So the file exists. Now I want to run:
$ dpkg -i my_file.deb
Which will install it, but my question is - does this install the library only inside this dev folder, without touching anything else?
You should refer to How to extract RPM or DEB packages, which is linked to from the FAQ on the downloads page:
ar p wkhtmltox.deb data.tar.xz | tar zx