I would like to modify a Fedora 15 package (gnome-shell-extensions-alternative-status-menu). It's a small modification (reverting this commit). Using yumdownloader I'm able to download a SRPM (gnome-shell-extensions-3.0.2-1.g63dd27cgit.fc15.src.rpm).

After this, how do I unpack it and then rebuild it?

  • You should change your recent edit to either be comments on @mdpc's answer or add an answer of your own with the steps that helped you solve the problem. Keep answer data out of the question itself please.
    – Caleb
    Jul 18, 2011 at 21:52
  • @Caleb Done! (3 more to go...)
    – Vitor Py
    Jul 18, 2011 at 22:03

2 Answers 2


What I do, as the ROOT user:

  1. Install the SRPM as you would any other package (rpm --install [source-rpm-filename])

  2. Examine /root/rpmbuild/SPECS directory and find the specs file that matches your package

  3. rpmbuild -bb /root/rpmbuild/SPECS/[found-filename]

The resulting binary packages are then located in the /root/rpmbuild/RPMS/ directory which are ready to be installed via the standard rpm --install command.

NOTE: This just builds what is in the standard binary package. I am posting this answering the specific question, not how to go about making changes to the source and generating new packages.

To do the modifications, you could either provide patches as input and changing the SPECS file....or you could replace the standard *.tar.bz2 located in /root/rpmbuild/SOURCES with your own with the change and then do the build as described above.

Beware you might have to change the SPECS package to make it work (usually by pulling out the patching, and changing some filenames that is programmed by the SPECS file).


It seems building rpms as root is a bad practice (source). It works fine as a non-root user.

Step by step instructions to add a patch (from here):

  1. Copy your patch to rpmbuild/SOURCES.
  2. Edit the rpmbuild/SPECS/package.spec and add a Patch0: mypatch.patch right after the Source0: ... line.
  3. After the %setup ... line add a %patch0 -p1 line

Now it will build normally, ie. with: rpmbuild -ba SPECS/package.spec

  • 2
    You should clarify that only the install is done as root, not the rpmbuild. Building rpm files should never be done as root.
    – Caleb
    Jul 18, 2011 at 21:51
  • @Caleb I installed as non root the packages. rpm puts it in ~/rpmbuild hierarchy. Also I did as you suggested on the question and put the extra steps here.
    – Vitor Py
    Jul 18, 2011 at 22:03
  • Just a couple notes: sudo dnf install rpmdevtools is needed for rpmbuild command. And the %patch0 -p1 line should be omitted if the spec file uses a %autosetup line instead of a %setup one (as %autosetup applies the patch automatically).
    – Nelson
    Mar 3, 2019 at 5:25
  • Also, to install the new rpm over the original one (in case the original is already installed on the system), do sudo rpm -ivh --force your.rpm
    – Nelson
    Mar 3, 2019 at 5:58
  • rpm-ivh over an existing binary package is a terrible idea. Dec 15, 2022 at 15:30

OpenSSL Package Rebuild CentOS 6.4 is a detailed example of an SRPM package rebuild.

The above example uses Mock - the Jedi Light Saber of package builders.

Mock was created to reliably populate a chroot, then rebuild a package in that chroot.

For more, see http://fedoraproject.org/wiki/Projects/Mock

In the example mock is used 3 times - once to "unpack" the package, then to rebuild the .src.rpm, and finally to create the .rpm.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .