From 71a5090bca049a43e30a7f0cf99141950ef9c5dd Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Mon, 9 Mar 2015 14:14:57 -0600 Subject: [PATCH] ceph.spec.in: fix handling of /var/run/ceph Prior to this commit, we didn't install /var/run/ceph as a normal directory. We used the %ghost directive and created the directory with a "mkdir" command in %post. This was lacking in several ways: 1) Simplicy: there is no need to use %ghost; other packages (eg. mariadb) simply use a normal %dir for their socket directory. 2) RPM does not have control over the permissions of the /var/run/ceph directory. This does not interact well with "rpm -V". Moreover, once Ceph itself gets unprivileged user support, RPM itself won't be able to set the permissions of the directory for a (future) unprivileged UID. 3) On distributions that use systemd as an init system, /var/run is a symlink to /run, which is tmpfs. This means that /var/run/ceph does not persist across reboots on those systems. Remove the %ghost directive; it makes more sense for RPM to simply install this directory like the rest of the %files. Add a "_with_systemd" conditional so we know which distros use systemd as their init system. Add the /etc/tmpfiles.d/ceph.conf file on those distros. See http://www.freedesktop.org/software/systemd/man/tmpfiles.d.html Signed-off-by: Ken Dreyer --- ceph.spec.in | 22 ++++++++++++++++++++-- systemd/ceph.tmpfiles.d | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 systemd/ceph.tmpfiles.d diff --git a/ceph.spec.in b/ceph.spec.in index d28484406b7..e2d3daa4cd4 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -5,6 +5,15 @@ %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif +# Use systemd files on RHEL 7 and above. +# Note: We don't install unit files for the services yet. For now, +# the _with_systemd variable only implies that we'll install +# /etc/tmpfiles.d/ceph.conf in order to set up the socket directory in +# /var/run/ceph. +%if 0%{?rhel} > 7 + %global _with_systemd 1 +%endif + ################################################################################# # common ################################################################################# @@ -37,6 +46,10 @@ Requires: util-linux Requires: hdparm Requires: cryptsetup Requires(post): binutils +# We require this to be present for %%{_tmpfilesdir} +%if 0%{_with_systemd} +Requires: systemd +%endif BuildRequires: gcc-c++ BuildRequires: boost-devel BuildRequires: bzip2-devel @@ -472,6 +485,9 @@ install -D src/init-ceph $RPM_BUILD_ROOT%{_initrddir}/ceph install -D src/init-radosgw.sysv $RPM_BUILD_ROOT%{_initrddir}/ceph-radosgw install -D src/init-rbdmap $RPM_BUILD_ROOT%{_initrddir}/rbdmap install -D src/rbdmap $RPM_BUILD_ROOT%{_sysconfdir}/ceph/rbdmap +%if 0%{_with_systemd} + install -m 0644 -D systemd/ceph.tmpfiles.d $RPM_BUILD_ROOT%{_tmpfilesdir}/%{name}.conf +%endif mkdir -p $RPM_BUILD_ROOT%{_sbindir} ln -sf ../../etc/init.d/ceph %{buildroot}/%{_sbindir}/rcceph ln -sf ../../etc/init.d/ceph-radosgw %{buildroot}/%{_sbindir}/rcceph-radosgw @@ -525,7 +541,6 @@ rm -rf $RPM_BUILD_ROOT %post /sbin/ldconfig /sbin/chkconfig --add ceph -mkdir -p %{_localstatedir}/run/ceph/ %preun %if %{defined suse_version} @@ -570,6 +585,9 @@ fi %{_bindir}/ceph-debugpack %{_bindir}/ceph-coverage %{_initrddir}/ceph +%if 0%{_with_systemd} +%{_tmpfilesdir}/%{name}.conf +%endif %{_sbindir}/ceph-disk %{_sbindir}/ceph-disk-activate %{_sbindir}/ceph-disk-prepare @@ -630,7 +648,7 @@ fi %dir %{_localstatedir}/lib/ceph/mds %dir %{_localstatedir}/lib/ceph/bootstrap-osd %dir %{_localstatedir}/lib/ceph/bootstrap-mds -%ghost %dir %{_localstatedir}/run/ceph/ +%dir %{_localstatedir}/run/ceph/ ################################################################################# %files -n ceph-common diff --git a/systemd/ceph.tmpfiles.d b/systemd/ceph.tmpfiles.d new file mode 100644 index 00000000000..871de3392e8 --- /dev/null +++ b/systemd/ceph.tmpfiles.d @@ -0,0 +1 @@ +d /var/run/ceph 0755 root root -