Linux – How to create an RPM for Suse

linuxrpmslessles10

I need to install version 1.4 of Subversion on a Suse 10.1 (64 bit) box. I can't change either of these two versions and there isn't an RPM for this distro. After looking around I assume that I'll have to create an RPM myself. Is there a better way than this? If not does anyone have any tips on the process?

I don't need a step-by-step tutorial, just a basic outline of the process.

Best Answer

Rebuilding an existing src.rpm is probably the easiest. I would definitely not go the way of configure, make, make install because (a) that doesn't scale, (b) doesn't provide for easy removal / upgrading of the package and (c) is not atomic.

Building an RPM is not so hard. There used to be a pretty good beginners tutorial at Linux.com, before they destroyed the site. You can try this one, but it's a lot of text, not easy to digest. Still, it's better than nothing.

I'll give you a few pointers, out of the back of my head:

  1. setup an .rpmmacros file in ~
  2. create ~/rpmbuild/{RPMS,SRPMS,SPECS,BUILD,BUILDROOT,SOURCES}
  3. drop the source tarball in ~/rpmbuild/SOURCES
  4. drop the the spec file(s) in ~/rpmbuild/SPECS
  5. run rpmbuild -bp YOURSPEC in ~/rpmbuild/SPECS (runs prepare phase)
  6. run rpmbuild -bc YOURSPEC in ~/rpmbuild/SPECS (above and runs compile phase)
  7. run rpmbuild -bb YOURSPEC in ~/rpmbuild/SPECS (above and builds actual package)

If everything worked out, your RPM will have appeared in ~/rpmbuild/RPMS/${arch}.

I tend to use 5, 6 and 7 separately when creating new RPM's, because I like to inspect the ouput in detail. You might want to go for 7 immediately if you have a vendor provided specfile.

I usually have something like this in my .rpmmacros.

%_topdir /home/YOURNAME/rpmbuild
%packager YOUR NAME <YOUR@EMA.IL>
%_tmppath /tmp

As for the syntax of the specfile: it is not that hard. There exists a very detailed, be it very old, reference work called 'Maximum RPM'. Everything you want to know is in there.