[CentOS] rpm spec file

Tue Jan 29 16:43:10 UTC 2008
nate <centos at linuxpowered.net>

Centos wrote:
> Hello
>
> any one has spec file for cgicc and pyperl.
> or any good and quick document that shows how to create spec file.
>
> I don't want to compile it on our servers.

I build a ton of custom rpms, and I use alien to create spec files
and rpms. It's not perfect but it's pretty easy to use, seems like
a lot easier than to try to build one from scratch for each package.

This is what I do, assuming the program installs all of it's files
to /usr

1) download source package to /tmp or something
2) run: find /usr >/tmp/usr-before-mypackage.log
3) compile/install source package
4) run: find /usr >/tmp/usr-after-mypackage.log
5) run :for i in `diff -u /tmp/usr-before-mypackage.log
/tmp/usr-after-mypackage.log | grep ^+ | grep /usr/ | sed s'/+//'g`; do [ -d
$i ] || echo $i ;done >/tmp/new.txt
6) run: cd /
7) run: tar czvf /tmp/mypackage-(version).tgz -T /tmp/new.txt
8) copy tgz to system that has alien(I use ubuntu, as it's a debian package,
at one point some red hat-based distros had it, not sure if it still does,
also want the fakeroot package too)
9) run: fakeroot alien -g -r mypackage-(version).tgz
10) edit resulting spec file to your desire(not required, but I like to set
version info, descriptions etc)
11) run fakeroot rpmbuild -bb (spec file name)
  (if x86_64 add --target x86_64)
  (if not binary, optionally --target noarch)
12) install rpm on destination system
13) permissions on installed files may be incorrect for whatever
reason(never been able to figure that out), I use CFEngine which fixes this
for me, though
you can always fix them by hand afterwards or add a %post section to the
spec file to handle it at installation.

I build about 45 packages with this method for each of the distros/versions
I have to support, on about 85 servers, works quite well.

nate