Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Some of these things you might already know, but I'm trying to write an answer that would benefit all readers.

You should install source packages as a non-root user. In order to do this, you need to install the package rpmdevtools. To build a source tree from an rpm package you also need rpm-build.

Download the source package:

dnf download --source gcc

If you have not already done so, create a directory hierarchy for rpm development:

rpmdev-setuptree

This will create a directory tree under ~/rpmbuild although it is not strictly necessary - the required directories are created one by one by other commands.

Then you can install the source package:

rpm -ivh gcc-5.3.1-6.fc23.src.rpm

At this point you probably don't have the necessary dependencies installed and without them the following steps won't work. So at this point as a root user or sudo install the missing dependencies:

sudo dnf builddep gcc

Check out the spec file name in ~/rpmbuild/SPECS and then unpack sources and apply patches:

rpmbuild -bp ~/rpmbuild/SPECS/gcc.spec

Take a look at various options of the rpmbuild command with rpmbuild --help or man rpmbuild

Also check out the available documentation: rpm -qd rpm-build and rpm -qd rpmdevtools

Of course you can do all this a the root user, but it is not recommended.