]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.spec.in: fix handling of /var/run/ceph 3916/head
authorKen Dreyer <kdreyer@redhat.com>
Mon, 9 Mar 2015 20:14:57 +0000 (14:14 -0600)
committerKen Dreyer <kdreyer@redhat.com>
Tue, 17 Mar 2015 18:28:28 +0000 (12:28 -0600)
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 <kdreyer@redhat.com>
ceph.spec.in
systemd/ceph.tmpfiles.d [new file with mode: 0644]

index d28484406b7566bb9113fa0e00eee8666fedc961..e2d3daa4cd4d814fe68d7ac4b1ef16abfd960e0e 100644 (file)
@@ -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 (file)
index 0000000..871de33
--- /dev/null
@@ -0,0 +1 @@
+d /var/run/ceph 0755 root root -