how to build a package from 'this' directory ?

Greg Swift gregswift at
Thu Jun 28 21:20:37 UTC 2012

On Thu, Jun 28, 2012 at 4:20 PM, Fulko Hew <fulko.hew at> wrote:
> This is basically my first attempt at RPM-ifying my apps
> (for internal coprporate distribution)...

great :)

> I'm probably doing this all wrong, but what I want to do is
> create a spec file that allows me to build an RPM based on
> the files in 'this' directory.
> ie.
> # cd /home/me
> # ls
> myapp myapp.rc myapp.spec
> # rpmbuild -bb myapp.spec
> I would expect to have something in the spec file that
> copies the masters from the current directory into
> the build directory (and its sub-directories as required)
> so that the build process can complete.
> Something like this:
> %install
> rm -rf $RPM_BUILD_ROOT
> mkdir -p $RPM_BUILD_ROOT/opt/myapp/
> cp ./myapp $RPM_BUILD_ROOT/opt/myapp/
> cp ./myapp.rc $RPM_BUILD_ROOT/etc/rc.d/init.d/myapp
> ...
> but the first thing that rpmbuild does is cd into the build directory.
> It seems that RPM building is always expecting to
> build from a tarball from an RPM SOURCE directory.

ya, thats pretty much what it wants to do, and is considered a best practice.

> Is there anyway I can do this 'more simply'?
> or... what am I not groking about the whole process?

So The RPM process is basically:

1: Take Source Tarball
2: Take SPEC file
3: Build software and wrap it into a package

For a lot of people that work directly off their own source that first
step can be very annoying, as you are complaining about.  What that
step gives you though is source RPMs (SRPM).  If you find a way to
build a package where your source is a directory (its possible, but
i'd rather not go into it because its horribly ugly... i'll give you
an alternative in a second) then your SRPMs are effectively useless
because it doesn't actually grab the source.

There are a few ways that people approach step 1.

1: A custom script that tars up the current directory and then runs the rpmbuild
2: A Makefile that does the same thing as the last step
3: Other programs like tito (

There is also a lot of good information here:

Personally, I'm a fan of the Makefile.  I'm attaching a sample
Makefile that would do what you are trying to do.

Then your spec would look more like this:

%setup -q -c -n %{name}


mkdir -p $RPM_BUILD_ROOT/opt/myapp/
cp myapp $RPM_BUILD_ROOT/opt/myapp/
cp myapp.rc $RPM_BUILD_ROOT/etc/rc.d/init.d/myapp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 639 bytes
Desc: not available
URL: <>

More information about the Rpm-list mailing list