On Thu, 02 Aug 2012 12:41:49 -0600
Dmitry Makovey <dmitry(a)athabascau.ca> wrote:
I'm working on bringing pgpool-II packages
(postgresql-pgpool-II-3.1.2-1) from Fedora over to RHEL6. I've
already "hacked" Fedora version to play nice with RHEL (removing
systemd references and supplanting systemd unit with init script). I
have also conditionalized it to build either one depending on whether
systemd is to be used or not using the
%if %{systemd_enabled}
...
%else
...
%endif
blocks. However I can't quite figure out an optimal way of
determining which platform package is being compiled for (in other
words: how to set up systemd_enabled macro automatically rather than
rely on manual setup). I'm sure people on this list came across this
problem more than once, and I would like to know what's the standard
way of resolving it. What I'm trying to achieve is to get one SPEC
for both Fedora and RHEL. Am I attacking this problem the wrong way?
I don't think there's a standard for this, but an approach I've used
with success is to test for the existence of the /run/lock directory:
# If directory /run/lock exists, do a systemd-based build; otherwise,a sysvinit-based
build
%global use_systemd %([ -d /run/lock ] && echo 1 || echo 0)
Cheers, Paul.