Blob Blame History Raw
Name:           fsniper
Version:        1.3.1
Release:        20%{?dist}
Summary:        A tool that monitors directories for new files and invokes scripts on them

Group:          Applications/File
License:        GPLv3+
URL:            https://github.com/l3ib/fsniper
Source0:        http://projects.l3ib.org/fsniper/files/fsniper-%{version}.tar.gz
Source1:        fsniper.service
Source2:        fsniper.conf
Source3:        fsniper.sysconfig

# Fix umask permissions - http://bugs.l3ib.org/index.php?do=details&task_id=21
Patch1:         fsniper-umask.patch
Patch2:         0001-Fix-an-error-message.patch
Patch3:         fsniper-wait3.patch

BuildRequires:  file-devel
BuildRequires:  pcre-devel
BuildRequires:  systemd-units

Requires(post):   systemd-units systemd-sysv
Requires(preun):  systemd-units
Requires(postun): systemd-units
Requires(pre):    /usr/sbin/useradd /usr/sbin/groupadd

%define servicename fsniper.service
%define fsdir       %{_localstatedir}/lib/%{name}

%description
fsniper is a tool that monitors a given set of directories for new
files. Then, based on the new file's type or name, it invokes a script to
be run (any executable via the shell) on that file.  Common uses include
making a single drop directory for all things from a webbrowser etc, and
having semi-intelligent scripts figure out what to do with those files. You
write the scripts yourself.


%prep
%setup -q
%patch1 -p1 -b .umask
%patch2 -p1 -b .errmessage
%patch3 -p1 -b .wait3


%build
%configure
make %{?_smp_mflags}


%install
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
mkdir -p $RPM_BUILD_ROOT%{fsdir}

make install DESTDIR=$RPM_BUILD_ROOT

install -pm 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{servicename}
install -pm 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/fsniper.conf
install -pm 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/fsniper
install -pm 0644 doc/doc.txt $RPM_BUILD_ROOT%{docdir}


%files
%{_bindir}/fsniper
%{_unitdir}/%{servicename}
%attr(-,%{name},%{name}) %dir %{fsdir}/
%config(noreplace) %{_sysconfdir}/fsniper.conf
%config(noreplace) %{_sysconfdir}/sysconfig/fsniper
%doc AUTHORS COPYING README
%doc doc/doc.txt doc/keyvalcfg.txt example.conf

%pre
if [ $1 = 1 ]; then
    getent group %{name} >/dev/null || groupadd -r %{name}
    getent passwd %{name} >/dev/null || \
           useradd -r -g %{name} -d %{_localstatedir}/lib/%{name} -s /sbin/nologin \
           -c "%{name} user" %{name}
    exit 0
fi

%post
if [ $1 -eq 1 ] ; then 
    # Initial installation 
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi

%preun
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable %{servicename} > /dev/null 2>&1 || :
    /bin/systemctl stop %{servicename} > /dev/null 2>&1 || :
fi

%postun
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart %{servicename} >/dev/null 2>&1 || :
fi

%triggerun -- fsniper < 1.0-2
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply fsniper
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save fsniper >/dev/null 2>&1 ||:

# If the package is allowed to autostart:
/bin/systemctl --no-reload enable %{servicename} >/dev/null 2>&1 ||:

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

%changelog
* Sun Jul 30 2017 Filipe Rosset <rosset.filipe@gmail.com> - 1.3.1-20
- Rebuilt to fix FTBFS #rhbz 1423584 plus spec cleanup

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.1-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.1-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.1-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue Dec 03 2013 Jakub Hrozek <jhrozek@redhat.com> - 1.3.1-13
- Fix -Wformat-security warning (rhbz #1037073)

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Wed Feb 13 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Fri Feb 10 2012 Petr Pisar <ppisar@redhat.com> - 1.3.1-9
- Rebuild against PCRE 8.30

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Mon Jan 02 2012 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-7
- systemd support
- fix the upstream URL. The source0 URL stays the same until upstream
  releases a new version

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Mon Jan 12 2009 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-3
- apply the correct patch from upstream VCS (Manuel Wolfshant)

* Wed Oct 22 2008 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-2
- issues found during review (#467627):
- add link to upstream bugtracker for patch
- exit with 0 after useradd

* Sun Oct 19 2008 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-1
- Initial packaging