Blob Blame History Raw
%global _hardened_build 1

Name:           fido
Version:        1.0.7
Release:        6%{?dist}
Summary:        Multi-threaded file watch utility
Group:          System Environment/Daemons

License:        GPLv2+ and LGPLv2+
URL:            http://www.joedog.org/%{name}-home/
Source0:        http://www.joedog.org/pub/%{name}/%{name}-%{version}.tar.gz

#Patch0-2: Sent upstream via email 20130206
Patch0:         %{name}-support_destdir_in_doc.patch
Patch1:         %{name}-fix-fsf-address.patch
Patch2:         %{name}-systemd.patch

#fixing some memory leaks
#Sent upstream via email 20130906
Patch3:         %{name}-segfault.patch

#drop supplementary groups of calling user when switching to a non-privileged
#user.
#Sent upstream via email 20130906
Patch4:         %{name}-setgroups.patch

#another overflow showed up because of the hardened build
#Sent upstream via email 20131206
Patch5:         %{name}-overflow.patch

#Upstream whants to keep the static library
Patch6:         %{name}-shared-library.patch

%{?el5:BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)}

Requires: libjoedog
%if 0%{?fedora} || 0%{?rhel} >= 7
BuildRequires:    systemd
%{?systemd_requires}
%else
Requires(post):  /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): initscripts
%endif
BuildRequires:   libtool, libjoedog-devel


%description
A multi-threaded file watch utility. It can monitor files for changes in
content or modification times. If it notices a change, it will kick off a
user-defined script.


%prep
%setup -q

%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6

rm -f *.m4
rm -rf include/joedog/*.h
sed -i -e 's/AC_PROG_SHELL//' configure.in
autoreconf --install --force


%build
%configure
make %{?_smp_mflags}


%install
%if 0%{?el5}
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%else
%make_install
%endif

%if 0%{?fedora} || 0%{?rhel} >= 7
#systemd
install -D -p -m 0644 %{name}.service %{buildroot}%{_unitdir}/%{name}.service
%else
#SysVinit
install -D -p -m 0644 utils/%{name}-redhat-config %{buildroot}%{_sysconfdir}/sysconfig/%{name}
%{?el6:install -D -p -m 0755 utils/%{name}-redhat-start %{buildroot}%{_initddir}/%{name}}
%{?el5:install -D -p -m 0755 utils/%{name}-redhat-start %{buildroot}%{_initrddir}/%{name}}
%endif

#prepare sample configs for doc
for _file in doc/*.conf
do
    ln -f "${_file}" "${_file}.sample"
done

#provide a reasonable minimal config as starting point
sed -e 's/^verbose  = true/verbose = false/' \
  %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf.sample \
  > %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
rm -f %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf.sample


%clean
%{?el5:rm -rf %{buildroot}}


%files
%doc ChangeLog README COPYING
%doc doc/*.sample
%{_sbindir}/%{name}
%{_mandir}/man*/*
%{_sysconfdir}/%{name}/rules
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf

%if 0%{?fedora} || 0%{?rhel} >= 7
#systemd
%{_unitdir}/%{name}.service


%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service
%else
#SysVinit
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}

%{?el6:%{_initddir}/%{name}}
%{?el5:%{_initrddir}/%{name}}

%post
/sbin/chkconfig --add %{name}

%preun
if [ $1 -eq 0 ] ; then
    /sbin/service %{name} stop >/dev/null 2>&1
    /sbin/chkconfig --del %{name}
fi

%postun
if [ "$1" -ge "1" ] ; then
    /sbin/service %{name} condrestart >/dev/null 2>&1 || :
fi
%endif


%changelog
* Wed Jun 26 2013 Roman Mohr <roman@fenkhuber.at> - 1.0.7-6
- Use %%{_initrddir} instead of %%{_initddir} for el5

* Mon Jun 24 2013 Roman Mohr <roman@fenkhuber.at> - 1.0.7-5
- trimmed/rearranged BuildRequires
- nuked explicit Requires: libjoedog
- removed article from Summary

* Mon Jun 24 2013 Roman Mohr <roman@fenkhuber.at> - 1.0.7-4
- Use libjoedog instead of the bundled satic library
- Fixed hardening build
- Added missing Group for EPEL5

* Tue Jun 11 2013 Roman Mohr <roman@fenkhuber.at> - 1.0.7-3
- Refactoring spec to support EPEL builds
- Hunting down some more memory leaks

* Sun Jun 09 2013 Roman Mohr <roman@fenkhuber.at> - 1.0.7-2
- Added systemd unit file
- Fixed some memory leaks
- Fixed a security issue when switching to a non-privileged user

* Mon May 20 2013 Roman Mohr <roman@fenkhuber.at> - 1.0.7-1
- Fixed custom rules in Makefile.in to support DESTDIR
- Fixed incorrect-fsf-address errors