Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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 '11 at 21:52
    
@Caleb Done! (3 more to go...) –  Vitor Jul 18 '11 at 22:03

2 Answers 2

up vote 3 down vote accepted

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).


Edit:

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

share|improve this answer
1  
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 '11 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 Jul 18 '11 at 22:03

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.