How to produce platform-specific and platform-independent RPM subpackages from one .spec?

dma_k picture dma_k · Jan 9, 2015 · Viewed 7.8k times · Source

I have dunno.spec file with the following structure:

Name:                   dunno
Version:                 1.0
...
BuildArch:              x86_64

%description
...
%package common
Summary:                Shared files
BuildArch:              noarch

I suppose that after I run rpmbuild -ba dunno.spec I should get two binary packages:

  • dunno-1.0.x86_64.rpm
  • dunno-common-1.0.noarch.rpm

however I get:

  • dunno-1.0.x86_64.rpm
  • dunno-common-1.0.x86_64.rpm

If I remove the line BuildArch: x86_64 from the spec, then I get

  • dunno-1.0.noarch.rpm
  • dunno-common-1.0.noarch.rpm

How to fix that?

RPM v4.4.2.3.

Answer

Jeff Johnson picture Jeff Johnson · Jan 9, 2015

Split the build into 2 packages, one x86_64, the other noarch.

You can do 2 builds from a single spec using %ifarch logic (but its usually easier/cleaner to use 2 spec files even if annoying).

It also hurts nothing to include platform-independent content in an x86_64 sub-package instead of a noarch sub-package.