I need to build an RPM for a Java software package on MacOS. I'm using rpmbuild from homebrew, version The toolchain is set up correctly, and I get a valid RPM at the end. There is just one snag: The RPM has a target OS string of "darwin", since it was built there, and attempting to install it on a normal Linux (think CentOS) fails with the message

Transaction check error:
  package myrpm.noarch is intended for a different operating system

and indeed, querying the RPM confirms the reason:

# rpm -qp --qf '%{os}\n' myrpm.noarch.rpm

In order not to change my source tree, I'd like to put the necessary properties in a local .rpmrc file.

How would I need to set it up so that I get a truly platform-independent RPM in the end?

To clarify this: The rpm contains software and paths that work on any system with a Java 8 JRE and a POSIX-like file system. It should at least be installable on darwin/MacOS and the Redhat / CentOS / SuSE universe.


The way to build a noarch RPM is actually to modify the spec file to include this instruction:

BuildArch: noarch

I'm not sure if you can configure the same in a configuration file such as .rpmrc, but in any case doing that would probably be a bad idea since it would prevent your rpmbuild installation from building actually arch-specific packages and, even though you don't need them yourself, it would still be a "broken" (or perhaps incompatible/incomplete) rpmbuild setup at that point.

If you do have access to the spec file (the file named after your package, with a .spec extension), then consider updating it to build noarch packages properly, using the BuildArch: noarch directive, in which case it will also work properly regardless of where it is built, without requiring any modifications to the local rpmbuild configuration.

  • Thanks for the quick reply. Our spec file already has that statement included, and the resulting RPM includes the "noarch" string in its name. But BuildArch and OS are possibly independent -- do you think setting OS there would work and make sense? It's true that the proper place for that sort of configuration is the specfile, but since I'm the only Mac user in our team, I think that keeping that config local to my machine would also be feasible. – jstarek Apr 16 at 12:56
  • Ah indeed, that's about the OS and not arch... My mistake. Not 100% sure how to solve this, I'll take a look later on... – filbranden Apr 16 at 13:01
  • Thanks. From the docs at rikers.org/rpmbook/node103.html#SECTION031131000000000000000, it seems that the --buildarch and --buildos options might be the way to go, but they don't seem to have an equivalent setting available for the .rpmrc file. – jstarek Apr 16 at 13:19
  • @jstarek I think this line in ~/.rpmrc will do what you want: buildostranslate: darwin: Linux. Can you try it and see if it works? If so I can update the answer to reflect that... Thanks! – filbranden Apr 17 at 5:03
  • Sorry, forgot this thread for a while... anyway, the statement you gave, put in ~/.rpmrc, did not change anything for me. The OS is still reported as darwin. – jstarek Aug 19 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.