spec file for rpms

Phil Meyer pmeyer at themeyerfarm.com
Mon Sep 22 17:50:54 UTC 2008

David Hláèik wrote:
> Hi guys,
> i am new at this.
> I want to make a rpm from a program source. It does not contain rpm 
> spec file by default so i need to create one.
> Is there any way to make creation of spec files easier? some tools etc 
> ... ?
> Thanks in advance!
> David

Both vim and emacs will create a basic spec for you by simply editing a 
non existant spec file.

$ vim new.spec

will create a basic spec file if new.spec does not exist in the current 

However, creating good spec files is a bit of a black art, I am afraid 
to say.

You will need to install:


and run:


That creates your rpmbuild directory tree.

 From there, you will find the field is broad, and the sky is the limit. :)

There are tools to watch 'make install' to discover what happens and 
duplicate it for a %files section for a spec file, but using those tools 
is a separate art form in itself.

I have found that most apps using 'configure' (automake) tools will have 
fairly easy to read install: sections in the generated Makefile. 

The rpm spec file: %files section allows for directories, making it easier.

So basically, make a generic .spec file, copy the source tarball to 
~/rpmbuild/SOURCES, try: rpmbuild -ba my.spec, and watch for errors, 
like the naming of the tar ball has to match the versioning specified in 
the spec file.  Also the directory that the tar ball is extracted into 
should match the version.

That is the simplest form.

You will want some references:


Look for the section called: Creating the spec file

One last piece of advice:
Always run rpmbuild as your user, and NOT root.  If your .spec file 
needs root to do something, you are doing it wrong. :)

Good Luck!

More information about the users mailing list