Multiple packages out of a single build?

Nils Philippsen nils at
Wed Nov 9 13:50:30 UTC 2011

On Wed, 2011-11-09 at 10:40 +0100, Marco wrote:
> Let me clarify what I mean. I have a makefile that has some targets to
> create rpm packages. They are all the same; the only part that differs
> is that the files are installed to different target directories, so
> the target rpm-foo has a %install section where it installs to
> ${RPM_BUILD_ROOT}/usr/local/foo, the target rpm-bar has a %install
> section where it installs to ${RPM_BUILD_ROOT}/usr/local/bar, etc.
> Other than that, everything else is the same (including the expensive
> %build part where the source is compiled).
> Now I was wondering if there was a way to execute the %build only
> once, but still generate multiple packages (each one with its own
> target directory) without needing to repeat the whole process for each
> one (like eg having multiple %install - I don't even know if that is
> possible, but looking for ideas).

You could add a subpackage for each of these, e.g. a specfile like this
would produce packages mypkg-foo and mypkg-bar:

Name: mypkg
%package foo
%description foo
%package bar
%description bar
# build both foo and bar
# install both foo and bar
%files foo
%dir /usr/local/foo
%files bar
%dir /usr/local/bar

Nils Philippsen      "Those who would give up Essential Liberty to purchase 
Red Hat               a little Temporary Safety, deserve neither Liberty
nils at       nor Safety."  --  Benjamin Franklin, 1759
PGP fingerprint:      C4A8 9474 5C4C ADE3 2B8F  656D 47D8 9B65 6951 3011

More information about the Rpm-list mailing list