Wandering Thoughts archives

2006-03-24

Setting up to build RPMs

There's three ways to build RPMs: the silly way, the easy way, and the better way.

The silly way starts with /bin/su root, which should be enough of a warning sign. You really don't want to be building and installing packages as root unless you don't have a choice, and you do.

The easy way is:

$ cat >$HOME/.rpmmacros
%_topdir /some/where
^D
$ cd /some/where
$ mkdir BUILD RPMS SOURCES SPECS

Then you can build as a normal user out of your /some/where hierarchy. I tend to use something like /u/cks/sys/RPM, but where you put it is up to you. (I always use absolute paths and I suspect that RPM requires them, so you can't use $HOME or ~/.. or the like.)

The problem with the easy way is that you wind up with an awful jumble in the SOURCES and SPECS subdirectories, because all of your sources and patches wind up in SOURCES, and all of your RPM spec files wind up in SPECS. This also makes it all but impossible to work with two versions of an RPM at the same time, since their specfiles usually stage a duel to the death.

The better way isn't original to me; I got it from Red Hat's Mike A. Harris. Put the following in your $HOME/.rpmmacros instead of the easy version:

%_topdir /some/where
%_sourcedir %{_topdir}/SOURCES/%{name}-%{version}

%_specdir %{_sourcedir}

This puts all of the bits of a given version of an RPM, say liferea-1.0.7, in SOURCES/liferea-1.0.7, instead of spread out across two flat directories. Which is much easy to work with and keep track of. (Trust me; I did it the 'easy' way for a while until I got totally fed up and found Mike Harris's version.)

(Ob-attr-darnit: here on rpm.org. Note that some of the information linked there is a bit out of date; for example, you no longer need a .rpmrc to have your .rpmmacros acted on.)

linux/RPMBuild written at 02:20:03; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.