Search code examples
rpmrpm-spec

One SPEC file to support multiple architectures


I'm modifying a RPM SPEC file to build for a x86_64 architecture. The existing SPEC includes a package applicable to 32-bit only, i.e. Requires: package-x-y-z. How do I remove the package-x-y-z requirement just for the x86_64 architecture, while still requiring the other OS to use it?

I tried using %ifnarch x86_64 before the Requires: package x-y-z line but was unsuccessful.

I could make separate SPEC files, but ideally this one SPEC file would support both architectures for better maintainability.


Solution

  • Do you happen to be using BuildArch as well in your spec-file?

    I have just tested this on a x86_64 build machine with a spec file where

    BuildArch: noarch
    

    and indeed

    %ifnarch x86_64
    Requires: package-x-y-z
    %endif
    

    produced a package that did require package-x-y-z...

    Since my spec file produces a noarch package, I tried changing the logic; and

    %ifnarch noarch
    Requires: package-x-y-z
    %endif
    

    produced a package that did not depend on package-x-y-z.

    Conclusion

    If you use BuildArch, then the macros ifarch and ifnarch will match wrt that architecture and not your real build-machine architecture.