Skip to content

Commit

Permalink
Move lock dir creation to tlog.spec
Browse files Browse the repository at this point in the history
Move lock dir creation to tlog.spec to cater to different RHEL releases.
Make sure lock dir is recreated on systems with systemd, where it
resides on tmpfs by also installing tmpfiles.d configuration.
  • Loading branch information
spbnick committed Feb 3, 2017
1 parent 5b7772d commit 6aae12d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
3 changes: 0 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ ACLOCAL_AMFLAGS = -Im4/autotools
SUBDIRS = m4 include lib src doc man
dist_doc_DATA = README.md
dist_noinst_DATA = tlog.spec

install-data-local:
$(MKDIR_P) $(DESTDIR)@localstatedir@/run/tlog
33 changes: 31 additions & 2 deletions tlog.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Source: https://github.com/Scribery/%{name}/releases/download/v%{version}/%{
BuildRequires: json-c-devel
BuildRequires: curl-devel
BuildRequires: m4
# If it's not RHEL6 and older
%if 0%{?rhel} == 0 || 0%{?rhel} >= 7
BuildRequires: systemd-units
%endif
Requires(post): sed
Requires(postun): sed

Expand Down Expand Up @@ -38,7 +42,7 @@ make %{?_smp_mflags} check
getent group %{name} >/dev/null ||
groupadd -r %{name}
getent passwd %{name} >/dev/null ||
useradd -r -g %{name} -d /var/run/%{name} -s /sbin/nologin \
useradd -r -g %{name} -d %{_localstatedir}/run/%{name} -s /sbin/nologin \
-c "Tlog terminal I/O logger" %{name}

%install
Expand All @@ -48,6 +52,24 @@ rm %{buildroot}/%{_libdir}/*.la
rm %{buildroot}/%{_libdir}/*.so
rm -r %{buildroot}/usr/include/%{name}

# If it's not RHEL6 and older
%if 0%{?rhel} == 0 || 0%{?rhel} >= 7
# Create tmpfiles.d configuration for the lock dir
mkdir -p %{buildroot}%{_tmpfilesdir}
{
echo "# Type Path Mode UID GID Age Argument"
echo "d /run/%{name} 0755 %{name} %{name}"
} > %{buildroot}%{_tmpfilesdir}/%{name}.conf
# Create the lock dir
mkdir -p %{buildroot}/run
install -d -m 0755 %{buildroot}/run/%{name}
# Else, if it's RHEL6 or older
%else
# Create the lock dir
mkdir -p %{buildroot}%{_localstatedir}/run
install -d -m 0755 %{buildroot}%{_localstatedir}/run/%{name}
%endif

%files
%{!?_licensedir:%global license %doc}
%license COPYING
Expand All @@ -58,10 +80,17 @@ rm -r %{buildroot}/usr/include/%{name}
%{_datadir}/%{name}
%{_mandir}/man5/*
%{_mandir}/man8/*
# If it's not RHEL6 and older
%if 0%{?rhel} == 0 || 0%{?rhel} >= 7
%config(noreplace) %{_tmpfilesdir}/%{name}.conf
%dir %attr(-,%{name},%{name}) /run/%{name}
# Else if it's RHEL6 or older
%else
%dir %attr(-,%{name},%{name}) %{_localstatedir}/run/%{name}
%endif
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/%{name}-rec.conf
%config(noreplace) %{_sysconfdir}/%{name}/%{name}-play.conf
%attr(0755,tlog,tlog) %{_localstatedir}/run/tlog

%post
/sbin/ldconfig
Expand Down

0 comments on commit 6aae12d

Please sign in to comment.