Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
packaging: rpms: Add systemd support for openSUSE
Browse files Browse the repository at this point in the history
Recent openSUSE releases have been migrated to systemd so use the
%{suse_version} macro to detect if we are building on openSUSE
so we can include the necessary systemd files and also perform the
needed systemd steps. This also defines the 'suse_version' to 1315
which is what openSUSE Leap 42.x use. This also drops the buggy rhel7
conditional for the sysvinit script and use another 'find' command
instead. The previous condition was wrong since it would also try
to include the sysvinit file on openSUSE and Fedora which do not
define the %rhel macro and as such the 0 < 7 conditional was always
true.
  • Loading branch information
Markos Chandras committed Jun 29, 2017
1 parent cf0d1f4 commit 2211e5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packaging/RPMS/Fedora/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RPM_OS ?= fedora
ifeq "$(RPM_OS)" "suse"
FUNCTION_LIBRARY=
REQUIRES=/sbin/chkconfig /sbin/service
OS_DEFINES=--define '_initrddir /etc/init.d' --define 'dist .suse'
OS_DEFINES=--define '_unitdir /usr/lib/systemd/system' --define 'dist .suse' --define 'suse_version 1315'
SPEC_DEFINES=--define 'group_tag Productivity/Networking/Other'
START_PROG=startproc
else
Expand Down
28 changes: 12 additions & 16 deletions packaging/RPMS/Fedora/rabbitmq-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ URL: http://www.rabbitmq.com/
BuildArch: noarch
BuildRequires: erlang >= %{erlang_minver}, python-simplejson, xmlto, libxslt, gzip, sed, zip, rsync

%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
BuildRequires: systemd
%endif

Requires: erlang >= %{erlang_minver}, logrotate, socat
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%{_arch}-root
Summary: The RabbitMQ server

%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
Requires(pre): systemd
Requires(post): systemd
Requires(preun): systemd
Expand Down Expand Up @@ -64,7 +64,7 @@ mkdir -p %{buildroot}%{_localstatedir}/log/rabbitmq

#Copy all necessary lib files etc.

%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
install -p -D -m 0644 %{S:3} %{buildroot}%{_unitdir}/%{name}.service
%else
install -p -D -m 0755 %{S:1} %{buildroot}%{_initrddir}/rabbitmq-server
Expand All @@ -91,7 +91,7 @@ for script in rabbitmq-server rabbitmq-plugins rabbitmq-diagnostics; do \
%{buildroot}%{_sbindir}/$script; \
done

%if 0%{?fedora} > 14 || 0%{?rhel} >= 7
%if 0%{?fedora} > 14 || 0%{?rhel} >= 7 || 0%{?suse_version}
install -D -p -m 0644 %{SOURCE4} %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf
%endif

Expand All @@ -100,6 +100,7 @@ rm %{_maindir}/LICENSE* %{_maindir}/INSTALL
#Build the list of files
echo '%defattr(-,root,root, -)' >%{_builddir}/%{name}.files
find %{buildroot} -path %{buildroot}%{_sysconfdir} -prune -o '!' -type d -printf "/%%P\n" >>%{_builddir}/%{name}.files
find %{buildroot} -path "*%{_initrddir}*" -type f -printf "/%%P\n" >>%{_builddir}/%{name}.files

%pre

Expand All @@ -122,15 +123,15 @@ fi

%post

%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
# %%systemd_post %%{name}.service
# manual expansion of systemd_post as this doesn't appear to
# expand correctly on debian machines
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset %{name}.service >/dev/null 2>&1 || :
fi
/bin/systemctl daemon-reload
systemctl daemon-reload
%else
/sbin/chkconfig --add %{name}
%endif
Expand All @@ -153,7 +154,7 @@ fi
%preun
if [ $1 = 0 ]; then
#Complete uninstall
%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
systemctl stop rabbitmq-server
%else
/sbin/service rabbitmq-server stop
Expand All @@ -171,7 +172,7 @@ for ext in rel script boot ; do
done

%postun
%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
# %%systemd_postun_with_restart %%{name}.service
# manual expansion of systemd_postun_with_restart as this doesn't appear to
# expand correctly on debian machines
Expand All @@ -185,18 +186,18 @@ if [ $1 -gt 1 ]; then
fi
%endif

%if 0%{?fedora} > 17 || 0%{?rhel} >= 7
%if 0%{?fedora} > 17 || 0%{?rhel} >= 7 || 0%{?suse_version}
# For prior versions older than this, do a conversion
# from sysv to systemd
%triggerun -- %{name} < 3.6.5
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply opensips
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||:
systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||:

# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
systemctl try-restart %{name}.service >/dev/null 2>&1 || :
%endif

%files -f ../%{name}.files
Expand All @@ -207,11 +208,6 @@ fi
%attr(2750, -, rabbitmq) %dir %{_sysconfdir}/rabbitmq



%if 0%{?rhel} < 7
%{_initrddir}/rabbitmq-server
%endif

%{_sysconfdir}/profile.d/rabbitmqctl-autocomplete.sh
%{_datarootdir}/zsh/vendor-functions/_enable_rabbitmqctl_completion

Expand Down

0 comments on commit 2211e5f

Please sign in to comment.