howto find which recipe provides a RPM (or DEB or IPK) package? - yocto

(in this question I talk RPM but the same issue concerns DEB and IPK I suppose)
How can I find which recipe provides a given RPM package? Is there a tool for that?
With grep and looking at the source code of the recipes, I can find out, but it is tedious.
Moreover the package name in yocto is not always the same as the RPM package name. Is there a tool for showing the relationship?
Examples:
which recipe provides the RPM package libgmp10? (and what is the PACKAGE name in yocto)
same question for the RPM package libmount1?

If those packages are already built, you can use the oe-pkgdata-util tool to find which recipe that provides a certain package. It's agnostic to which package format you're using, so it works for rpm/deb/ipk.
In the example below I want to find out which recipe that provides the package called libmount1, and the command shows that the recipe name is util-linux
$ oe-pkgdata-util lookup-recipe libmount1
util-linux
And to find the recipe-space package name:
$ oe-pkgdata-util lookup-pkg -r libmount1
util-linux-libmount

Related

Obtain the version of a setup.cfg package

When using setup.py in a Python project, we can simply run
$ python3 setup.py --version
And this will give us the version field that is set in the setup.py file. This saves us using sed or something alike to read the version when we need to do so in a script.
I was wondering, is there an equivalent way in a setup.cfg project?
When you have only a setup.cfg, and no setup.py file, you can do this:
$ cat setup.cfg
[metadata]
name = mypkg
version = "0.1.2.3" # or `file: VERSION.txt` or `attr: mypkg.__version__` etc
$ python3 -c 'import setuptools; setuptools.setup()' --version
"0.1.2.3"
If the build backend is setuptools, then this approach will also work for a source tree with a pyproject.toml file.
Allow me to deviate from your actual question to offer what I thing is a better solution.
If you have to get the package version while developing (from an outside script) then you should split such information from your setup.cfg/setup.py.
You want setup.cfg (i.e, setuptools) to get that information from a file, for instance. Then, you can have the version just by reading the corresponding file.
Check the docs for details: https://setuptools.pypa.io/en/latest/userguide/declarative_config.html. Notice the #meta-1 anchor/note in that page.
Basically, you'll use attr or file attributes (in your setup.cfg metadata section) to get the version from another place:
version = file: VERSION.txt

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.

is there any dependency manager for Racket?

Like npm for node, we use package.json to solve dependencies.
I tried raco pkg, it seems to be just a way to dev/pub packages instead of solving external dependencies.
As I described above, info.rkt in Racket acts like package.json in JavaScript, and raco pkg install will read the dependencies specified in info.rkt and recursively install these dependencies.
For instance, here's the Pollen project's info.rkt. You can see that it specifies txexpr which is another package as a dependency. Therefore, when you raco pkg install pollen, it will ask you if you want to install txexpr too. You can also invoke raco pkg install --auto pollen which will install dependencies automatically without asking any question.
Note that these packages are registered with https://pkg.racket-lang.org/ which is an equivalent of https://www.npmjs.com/ in JS.
You can read the documentation of info.rkt regarding package dependencies here.

CentOS 7 - how to install dependency using wget in an RPM spec file

I'm trying to write a spec RPM file to build an RPM package.
Here is in essence my spec file:
[...]
Requires: nodejs java-1.8.0-openjdk java-1.8.0-openjdk-devel log4j
%define _rpmdir ../
%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%define _unpackaged_files_terminate_build 0
%pre
[Some script]
%post
[Some script]
%preun
[Some script]
%postun
[Some script]
%install
[...]
%files
[...]
I've managed to install the package dependencies with the preamble Requires expect one that doesn't exist as a yum package (tomcat8). I found on the internet that the way to install it on centOS is:
wget https://harbottle.gitlab.io/harbottle-main/7/x86_64/00853071-tomcat8/tomcat8-8.5.37-2.el7.harbottle.x86_64.rpm
rpm -ivh tomcat8-8.5.37-2.el7.harbottle.x86_64.rpm
But where should I put it in the spec file? I tried to put it in the %pre script, but there is a lock on rpm that prevent its use. I tried to put it in the %install part, but it didn't seem right. Can you please help me to fix this problem? Is there a way to still put it in the Requires preamble?
Thanks!
this is not the way you should manage those dependencies. You should search for a way to make this rpm available in you repositories. I see multiple options:
add the harbottle repository:yum-config-manager --add-repo https://harbottle.gitlab.io/harbottle-main/7/x86_64/. Now your yum will be able to find the tomcat8 rpm by itself
If you want to make sure the package remains available; better copy the tomcat8.rpm inside your own repository besides your other rpms.

Python3-glob and Python3-shutil Missing in Bitbake

Using openembedded-core Morty branch:
For whatever reason, python 2 has these package but when attempting to run:
bitbake python3-glob
and
bitbake python3-shutil
These packages are not available. When installing just python3 as part of a project they are missing as well.
However, another "standard package" (not sure if this is an accurate statement but this comes included in python3 on debian) subprocess can be installed by adding python3-subprocess as a dependency.
Is glob and shutil part of some larger python3 standard packages recipe?
Found it:
the openembedded-core Python3 recipe comes with a file called python-3.5-manifest. This file outlines different sub-recipes of python3.
glob and shutil are available by building python3-shell.
It appears for these to show up in an image they must be added to IMAGE_INSTALL in your image recipe.