SPEC Files Red Hat/Fedora/SUSE equivalents

As it happens, the SPEC files between Fedora/RedHat and SUSE Linux are system dependent. This is due to different macros being loaded. This article will cover some of these difference so they can be used to make system independent SPEC files.

%_fillupdir %fillup_and_insserv %fillup_only

SUSE

SUSE Definition

%if 0%{?suse_version}
Requires(post): %fillup_prerep
%endif

%install
%if 0%{?rhel}
install -D -m 644 file.config %{buildroot}%{_sysconfdir}/sysconfig/file.config
%else
install -D -m 644 file.config %{buildroot}%{_fillupdir}/sysconfig.%{name}
%endif

%post
%if 0%{?suse_version}
%fillup_only
%endif 

%files
%if 0%{?rhel}
%{_sysconfdir}/sysconfig/file.config
%else
%{_fillupdir}/sysconfig.%{name}
%endif

 

%service_add_pre %systemd_post %service_add_post %systemd_preun %service_del_preun %systemd_postun %service_del_postun

%pre
%if 0%{?suse_version}
%service_add_pre %{name}.service
%endif

%post
%if 0%{?rhel}
%systemd_post %{name}.service
%else
%service_add_post %{name}.service
%endif

%preun
%if 0%{?rhel}
%systemd_preun %{name}.service
%else
%service_del_preun %{name}.service
%endif

%postun
%if 0%{?rhel}
%systemd_postun %{name}.service
%else
%service_del_postun %{name}.service
%endif