Re: how to build a package from 'this' directory ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 28, 2012 at 4:20 PM, Fulko Hew <fulko.hew@xxxxxxxxx> 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 (http://rm-rf.ca/tito)

There is also a lot of good information here:

http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/index.html


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}

%build

%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


-greg

Attachment: Makefile
Description: Binary data

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux