Blog |Follow Nick on Mastodon| About
 

I've got a few posts in my wordpress drafts that are based around rebuilding RPMS, I figure that before I finish them it makes sense to write a Getting Started Guide.

The first thing is based around the "Unix Golden Rule": Only use root when you have to.

To rebuild rpms you need a certain directory structure, it is located in /usr/src/redhat, but since it is owned by root you're gonna need on in your $HOME. The following does the job:

    $cd \$HOME  
    $cp -a /usr/src/redhat/ rpmbuild  
    $echo '%\_topdir %(echo $HOME)/rpmbuild' >> .rpmmacros

Next: you need a Source RPM, these are usually found with any other RPM, except they end .src.rpm rather than .i386.rpm or similar. Start with something simple like wget; (Sometimes building rpms requires dependancies) now this import, install as your normal user NOT root.

    $ rpm -ivh wget-1.9.1-17.src.rpm  
    1:wget ########################################### [100%]  
    $

This will put all of the source in wget-1.9.1-17.src.rpm into your $HOME/rpmbuild directory, specifically you'lll find the actual sources in $HOME/rpmbuild/SOURCES and a SPEC file in $HOME/rpmbuild/SPEC. The Sources are all the files you need; so the source.tar.gz that you'd usually run the "holy trinity" (configure, make, make install ) against, and any patches. The SPEC file is what turns the sources & patches into the RPM, so if you want to change the RPM in anyway, like change the changelog (i.e. packaged by [NICK] ) you edit the spec file.

So to turn the src.rpm into an installable file you run.

    $ cd \$HOME/rpmbuild/SPECS  
    $ rpmbuild -ba wget.spec

and in $HOME/rpmbuild/*arch*/ will be wget-1.9.1-17.arch.rpm (in my case arch is i386; oh and sometimes you get a debug rpm, which gives you some developemnt stuff you might need), and now you have an exact copy of the wget RPM built by Redhat but this one was built by your fair hands ;)

So to Install as root or using sudo

    rpm -ivh wget-1.9.1-17.i386.rpm

& you're done ! So now if you find a src.rpm but not one to install, now you can build your own.

Here are some useful References :

Better Living Through RPM, Part 1
Better Livig Though RPM, Part 2
How to Sign Custom RPM Pakages with GPG
How to create rpmbuild directory

 

 
Nick Bettison ©