Determine programming laguage(s) used to build from srpm

My curiosity leads me to wanting to know more more about rust and how applications that use rust are distributed in fedora. It would be handy to be able to query the package or repository and discover what programming language(s) an application is written in.

There are lots of great resources that will help you learn rust.

rust apps packaged in Fedora typically use the rust2rpm tools.
That tool makes it easy to go from the rust cargo project to a source rpm.

To directly answer your question; you would need to get the source code of an rpm to figure out what languages it uses. I know of no meatdata that records the languages.

Downloading the srpm, extracting the spec file and so on is a bit more network bandwidth than I’d like (ie: to check every installed package).

Here is a script that gets a lot of the way there

#!/usr/bin/bash
set -x

OS=f41

SRPM=$(dnf rq --latest-limit=1 --qf='%{source_name}\n' $1)
curl https://src.fedoraproject.org/rpms/${SRPM}/raw/${OS}/f/${SRPM}.spec | grep '^BuildRequires:'

and an example usage

./buildrequires cosmic-session
+ OS=f41
++ dnf rq --latest-limit=1 '--qf=%{source_name}\n' cosmic-session
Updating and loading repositories:
Repositories loaded.
+ SRPM=cosmic-session
+ curl https://src.fedoraproject.org/rpms/cosmic-session/raw/f41/f/cosmic-session.spec
+ grep '^BuildRequires:'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4560  100  4560    0     0  22036      0 --:--:-- --:--:-- --:--:-- 22135
BuildRequires:  cargo-rpm-macros >= 26
BuildRequires:  rustc
BuildRequires:  lld
BuildRequires:  cargo
BuildRequires:  just
BuildRequires:  desktop-file-utils
BuildRequires:  systemd-rpm-macros

from which I can deduce it is a rust application

Try this:

$ sudo dnf install fedora-repos-rawhide
$ dnf repoquery --repo=rawhide-source --requires cosmic-session
Updating and loading repositories:
Repositories loaded.
cargo
cargo-rpm-macros >= 26
desktop-file-utils
just
lld
rustc
systemd-rpm-macros
2 Likes

Good point — discovering if it is a rust application is easier than the general problem.

@jjames,

Nice.

It also works against installed version (f41 in this case)

dnf repoquery --repo=*-source --requires cosmic-session

And other compilers are shown for applications written with other tools/languages

dnf repoquery --repo=*-source --requires bash
dnf repoquery --repo=*-source --requires systemd

@mattdm,

What is still missing in the general problem?

It’s easy to look specifically for rustc. To take that same approach to the general problem, you need a list of which build or runtime dependencies represent each language. (And to maintain that list in the future.)

1 Like