Shipping *.so and binaries while building RPM package


I have created a python application in which I would like to ship .so and some binary files in the final RPM package. After long reading I found a way to add binaries/ image and other data files in Now, when I build an RPM with python bdist_rpm command, it complains about architecture dependency:

    Arch dependent binaries in noarch package
error: command 'rpmbuild' failed with exit status 1

After googling I found that we can add:

#%define _binaries_in_noarch_packages_terminate_build 0

or removing the line BuildArch: noarch in the packagename.spec file to overcome the rpmbuild failure. However, every time I add or remove line from build/bdist.linux-i686/rpm/SPECS/packagename.spec the command python bdist_rpm always overwrites the .spe file.

Is there a way to avoid Arch dependent binaries and ship *.so and other binary files in rpm?

Asked By: sundar_ima



.so files are always arch dependent as far as I know.

In your case to avoid having to edit the specs-file all the time you can add --force-arch=<your_arch> to our bdist_rpm


python bdist_rpm --force-arch=x86_64
Answered By: frans

The behavior of bdist_rpm is defined by a bunch of settings in:

  • /usr/lib/rpm/macros
  • /etc/rpm/macros
  • $HOME/.rpmmacros

I’m willing to bet that only /usr/lib/rpm/macros exists on your system. This is normal.

So, in order to prevent the “Arch dependent binaries in noarch package” error you would create /etc/rpm/macros or ~/.rpmmacros and add the following:

%_unpackaged_files_terminate_build      0
%_binaries_in_noarch_packages_terminate_build   0

Do not modify /usr/lib/rpm/macros because that file will be overwritten by the system whenever the rpm-build package is upgraded, downgraded, or re-installed.

If you want to override the behavior for everyone on the system put the settings in /etc/rpm/macros. If you want override the behavior for a particular user then add the settings to $HOME/.rpmmacros.

.rpmmacros trumps /etc/rpm/macros which trumps /usr/lib/rpm/macros.

Note: it’s useful to examine /usr/lib/rpm/macros to see what settings are available and for syntax examples.

As a side note, %_unpackaged_files_terminate_build 0 setting prevents the error: Installed (but unpackaged) file(s) found: error.

Answered By: shrewmouse

If you encounter this matter in a .spec file when you try to build a new .rpm package.

Change the BuildArch from noarch to x86_64 (or whatever you have on the building system)

[root@devel-mga7][~/build/yate-ota]# grep Arch yate-ota.spec
BuildArch:      x86_64
Answered By: YateBTS
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.