Ask Your Question

How to install package sources with dnf?

asked 2017-06-07 02:38:47 -0600

alfC gravatar image

I am using the Boost C++ library, within Fedora I can easily install this library, meaning that I can install the library and the development headers

dnf install boost-devel

Is it also possible to install the sources (that means the actual code, not just the headers) in similar way? (like sudo dnf boost-sources.

I remember in Ubuntu there was a special repository for packages sources, what is the equivalent in Fedora? Are they available at all in some Fedora repository?

edit retag flag offensive close merge delete



Apart from the fact that boost is mainly a template library so you already have the code you can do:dnf --enablerepo=fedora-source install <your-package.src.rpm>

fcomida gravatar imagefcomida ( 2017-06-07 03:09:45 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2017-06-07 05:06:52 -0600

muep gravatar image

updated 2017-06-07 05:14:26 -0600

You can download sources with dnf download --source somepackage

So for boost this would be:

dnf download --source boost

Also passing boost-devel like this should work even if the source package name is just boost, because dnf seems able to resolve it back correctly:

dnf download --source boost-devel

Either of these commands should fetch you an src.rpm file. This is a special kind of archive from which fedora packaging tools can produce the binary rpm files that you would normally download when installing software with dnf. To unpack one of these, you run something like this as your normal user:

rpm -ivh boost-1.60.0-10.fc25.src.rpm

This should produce you files in your ~/rpmbuild/ directory. The upstream source package should be in ~/rpmbuild/SOURCES directory. You can unpack it manually, or you can do that and apply the patches that fedora has (if any) by going to ~/rpmbuild/SPECS/ directory and running this:

rpmbuild -bp boost.spec

If you do not yet have rpmbuild installed, it is in the rpm-build package.

edit flag offensive delete link more


The rpmbuild may complain about missing build dependencies. This can be resolved using:

sudo dnf builddep  boost.spec

The builddep sub-command requires the package python3-dnf-plugins-core to be installed.

villykruse gravatar imagevillykruse ( 2017-06-07 14:09:29 -0600 )edit

Excellent, this worked. Is it possible to have the source in some standard (decided by dnf) place?

alfC gravatar imagealfC ( 2017-06-07 15:23:28 -0600 )edit

answered 2017-06-07 08:15:57 -0600

fcomida gravatar image

boost is a header only library. Mostly.

edit flag offensive delete link more


You said it. Mostly. I need to look at the source of one of the libraries that is not header only.

alfC gravatar imagealfC ( 2017-06-07 15:15:00 -0600 )edit

Yeah the world isn't perfect. @muep already answered how to download the sources. There is no standard place where to install source code in fedora. With rpm -ihv <packagename.src.rpm> you'll find the pristine source compressed tarball plus any patches provided by the fedora packager in $HOME/rpmbuild/SOURCES. You can unpack the sources wherever you want, apply the patches if you like and start studying the code as already explained in the previous answer.

fcomida gravatar imagefcomida ( 2017-06-07 16:04:21 -0600 )edit

Question Tools

1 follower


Asked: 2017-06-07 02:38:47 -0600

Seen: 5,829 times

Last updated: Jun 07 '17