Spec files for building Fedora and EPEL

I am building a project in COPR for EPEL and Fedora 35+/-.
Due to some differences in package names between EPEL and Fedora, I have two different spec files (cantera.spec for Fedora and cantera-epel.spec at cantera/rpm at copr · mefuller/cantera · GitHub).

Can anyone advise as to how (if it’s possible) to merge these files together?

Thanks

2 Likes

You can use if statements with special helper variables defined only on RHEL/Fedora. So for example with your package and gcc-fortran (Fedora) and gcc-gfortran (RHEL) build dependencies you can use something like:

%if 0%{?fedora}
BuildRequires:  gcc-fortran
%endif

%if 0%{?rhel}
BuildRequires:  gcc-gfortran
%endif

See for example this spec file of mine where I use these variables to define different dependencies for Fedora, Mageia, OpenMandriva and OpenSUSE.

3 Likes

Thank you very much!

1 Like