Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 setup.py. Now, when I build an RPM with python setup.py 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 setup.py 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?

like image 523
sundar_ima Avatar asked Jan 22 '14 16:01

sundar_ima


People also ask

How do you create a binary RPM from a source RPM?

Rebuild the SRPM in One Step The quickest way to rebuild the SRPM is to use the rpmbuild --rebuild ... command. This command will unpack the SRPM file into the specfile and the source files, and then it will build the RPM from the instructions on the specfile.

What are sources in RPM build directory?

The RPMS directory is where the newly created binary package files are written. The SOURCES directory contains the original sources, patches, and icon files. The SPECS directory contains the spec files for each package to be built.

What does an RPM contain?

What is an RPM? An RPM package is simply a file containing other files and information about them needed by the system. Specifically, an RPM package consists of the cpio archive, which contains the files, and the RPM header, which contains metadata about the package.


2 Answers

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.

like image 85
shrewmouse Avatar answered Oct 04 '22 03:10

shrewmouse


.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 setup.py bdist_rpm

e.g.

python setup.py bdist_rpm --force-arch=x86_64
like image 41
frans Avatar answered Oct 04 '22 03:10

frans