-Summary: Smokeping is a traffic grapher that uses rrdtool
-Summary(pl): Smokeping jest narzêdziem do tworzenia wykresów aktywno¶ci sieci
+%include /usr/lib/rpm/macros.perl
+Summary: Smokeping - a latency grapher that uses rrdtool
+Summary(pl.UTF-8): Smokeping - narzędzie do tworzenia wykresów opóźnień sieci
Name: smokeping
-Version: 1.30
-Release: 0.1
-Vendor: Tobias Oetiker
-License: GPL
-Group: Applications/Internet
-###### Unknown group!
-Source0: http://people.ee.ethz.ch/~oetiker/webtools/smokeping/pub/%{name}-%{version}.tar.gz
-# Source0-md5: b7e909fb4d851995edc05afffb1a1e4b
+Version: 2.6.11
+Release: 0.3
+License: GPL v2+
+Group: Networking/Utilities
+Source0: http://oss.oetiker.ch/smokeping/pub/%{name}-%{version}.tar.gz
+# Source0-md5: 702392f5f3599f7eb1cc47eb2d192cb9
Source1: %{name}.init
-Source2: %{name}.conf
-URL: http://people.ee.ethz.ch/~oetiker/webtools/smokeping
-BuildRequires: perl-base
-Requires: fping
-Requires: perl-base
-Requires: rrdtool
-Requires: webserver
+Source2: %{name}-apache.conf
+Source3: %{name}-config
+Source4: %{name}-lighttpd.conf
+Source5: %{name}.tmpfiles
+Source6: %{name}-httpd.conf
+Patch0: fix-paths.patch
+Patch1: high_precision_sleep_timer.patch
+URL: http://oss.oetiker.ch/smokeping/
+BuildRequires: perl-Config-Grammar
+BuildRequires: perl-rrdtool
+BuildRequires: perl-tools-pod
+BuildRequires: rpm-perlprov >= 4.1-13
+BuildRequires: rpmbuild(macros) >= 1.268
+BuildRequires: sed >= 4.0
+Requires(post): sed >= 4.0
+Requires(post,preun): /sbin/chkconfig
+Requires(postun): /usr/sbin/groupdel
+Requires(postun): /usr/sbin/userdel
+Requires(pre): /bin/id
+Requires(pre): /usr/bin/getgid
+Requires(pre): /usr/lib/rpm/user_group.sh
+Requires(pre): /usr/sbin/groupadd
+Requires(pre): /usr/sbin/useradd
+Requires(pre): /usr/sbin/usermod
+Requires(triggerpostun): findutils
+Requires: perl-Config-Grammar
+Requires: rc-scripts >= 0.4.1.23
+Requires: rrdtool >= 1.2
+Suggests: bind-utils
+Suggests: curl
+Suggests: echoping
+Suggests: fping
+Suggests: openssh-clients
+Suggests: traceroute
+Provides: group(%{name})
+Provides: user(%{name})
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define _wwwrootdir /home/services/httpd
+%define _noautoprovfiles %{_datadir}/%{name}
+%define _noautoreq_perl BER CGI::Session::Driver CGI::Session::Driver::DBI CGI::Session::ErrorHandler Config::Grammar Digest::HMAC Digest::HMAC_MD5 JSON JSON::Converter JSON::Parser Smokeping Smokeping::ciscoRttMonMIB Smokeping::Colorspace Smokeping::Config Smokeping::Examples Smokeping::Graphs Smokeping::Master Smokeping::matchers::Avgratio Smokeping::matchers::base Smokeping::probes::base Smokeping::probes::basefork Smokeping::probes::basevars Smokeping::probes::EchoPing Smokeping::probes::EchoPingHttp Smokeping::probes::EchoPingPlugin Smokeping::probes::FPing Smokeping::probes::passwordchecker Smokeping::RRDhelpers Smokeping::RRDtools Smokeping::Slave Smokeping::sorters::base SNMP_Session SNMP_util
+
+# How to obtain _noautoreq:
+# 1. comment out _noauto* macros
+# 2. repackage smokeping
+# 3. select Provides from repackage output
+# 4. xclip -o | sed 's/ perl/\nperl/g' | awk '{print $1}' | sort -u > perlprov
+# 5. select Requires from repackage output
+# 6. xclip -o | sed 's/ perl/\nperl/g' | awk '{print $1}' | sort -u > perlreq
+# 7. cat perlprov perlprov perlreq | awk '{print $1}' | sort | uniq -c | grep '^ 2 ' | awk '{print $2}' | tr '\n' ' '
+
+%define _sysconfdir /etc/%{name}
+%define _webapps /etc/webapps
+%define _webapp %{name}
+%define _wwwconfdir %{_webapps}/%{_webapp}
+%define _cgi_bindir %{_prefix}/share/%{name}
%description
SmokePing is a ICMP latency logging and graphing system. It consists
of a daemon process which organizes the latency measurements and a CGI
which presents the graphs with interesting smoke-like effects.
-%description -l pl
-Smokeping jest narzêdziem do tworzenia wykresów aktywno¶ci sieci.
-U¿ywaj±c pakietów ICMP zapisuje czas odpowiedzi poszczególnych hostów
-i wy¶wietla je w postaci czytelnego wykresu.
+%description -l pl.UTF-8
+Smokeping jest narzędziem do tworzenia wykresów aktywności sieci.
+Używając pakietów ICMP zapisuje czas odpowiedzi poszczególnych hostów
+i wyświetla je w postaci czytelnego wykresu.
+
+%package cgi
+Summary: CGI webinterface for smokeping
+Summary(pl.UTF-8): Interfejs WWW (CGI) do smokepinga
+Group: Applications/WWW
+Requires: %{name} = %{version}-%{release}
+Requires: webapps
+Requires: webserver(access)
+Requires: webserver(alias)
+Requires: webserver(cgi)
+Conflicts: apache-base < 2.4.0-1
+
+%description cgi
+CGI webinterface for smokeping.
+
+%description cgi -l pl.UTF-8
+Interfejs WWW (CGI) do smokepinga.
%prep
%setup -q
+%patch0 -p1
+%patch1 -p1
+
+#sed -i -e 's,^Net::.*$,,' PERL_MODULES
+
+sed -i -e 's#@prefix@/etc/\(.*\).dist#/etc/smokeping/\1#' etc/config.dist.in
+sed -i -e 's#@prefix@/etc/#/etc/smokeping/#' etc/config.dist.in
+
%build
+%configure \
+ --enable-pkgonly
%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-install -D etc/basepage.html.dist $RPM_BUILD_ROOT/%{_sysconfdir}/%name/basepage.html
-install -D etc/config.dist $RPM_BUILD_ROOT/%{_sysconfdir}/%name/config
-install -D etc/config-echoping.dist $RPM_BUILD_ROOT/%{_sysconfdir}/%name/config-echoping
-install -D etc/smokemail.dist $RPM_BUILD_ROOT/%{_sysconfdir}/%name/smokemail
-install -D -m 755 bin/smokeping.dist $RPM_BUILD_ROOT/%{_bindir}/smokeping
-install -d $RPM_BUILD_ROOT/%{_libdir}/smokeping
-cp -r lib/* $RPM_BUILD_ROOT/%{_libdir}/smokeping/
-install -d $RPM_BUILD_ROOT/%{_wwwrootdir}/%{name}/{rrd,img}
-install -D -m755 htdocs/%{name}.cgi.dist $RPM_BUILD_ROOT/%{_wwwrootdir}/cgi-bin/%{name}
-install -D -m 755 %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/%name
-install -D %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d/%{name}.conf
-install -d $RPM_BUILD_ROOT/%{_mandir}/man1/
-cp doc/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1/
+install -d $RPM_BUILD_ROOT{/etc/rc.d/init.d,%{_sysconfdir},%{_wwwconfdir}} \
+ $RPM_BUILD_ROOT{%{_datadir}/%{name},%{_sharedstatedir}/%{name}/{img,rrd},%{_cgi_bindir}} \
+ $RPM_BUILD_ROOT{%{_mandir}/man{1,3,5,7},/var/run/%{name}} \
+ $RPM_BUILD_ROOT%{systemdtmpfilesdir}
+
+%{__make} install DESTDIR=$RPM_BUILD_ROOT
+
+# start of fixing paths
+for f in basepage.html smokemail smokeping_secrets tmail; do
+ mv $RPM_BUILD_ROOT/etc/smokeping/{$f.dist,$f}
+done
+
+rm -rf $RPM_BUILD_ROOT/etc/smokeping/examples
+
+mv $RPM_BUILD_ROOT%{_prefix}/lib/{*.pm,Smokeping} $RPM_BUILD_ROOT%{_datadir}/%{name}
+
+mv $RPM_BUILD_ROOT{%{_prefix}/htdocs/cropper,%{_cgi_bindir}}
+mv $RPM_BUILD_ROOT%{_bindir}/smokeping_cgi $RPM_BUILD_ROOT%{_cgi_bindir}/smokeping.cgi
+
+mv $RPM_BUILD_ROOT%{_mandir}/man1/{smokeping_cgi.1,smokeping.cgi.1}
+# end of fixing paths
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_wwwconfdir}/apache.conf
+cp -p %{SOURCE6} $RPM_BUILD_ROOT%{_wwwconfdir}/httpd.conf
+cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_wwwconfdir}/lighttpd.conf
+cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/config
+cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/%{name}.conf
+
%clean
rm -rf $RPM_BUILD_ROOT
+%pre
+%groupadd -g 207 %{name}
+%useradd -u 207 -d /var/lib/%{name} -g %{name} -s /bin/false -c "Smokeping User" %{name}
+%addusertogroup smokeping adm
+
%post
-/sbin/chkconfig --add smokeping
+/sbin/chkconfig --add %{name}
%preun
-if [ $1 = 0 ]; then
- /sbin/chkconfig --del smokeping
+if [ "$1" = 0 ]; then
+ %service %{name} stop
+ /sbin/chkconfig --del %{name}
+fi
+
+%postun
+if [ "$1" = 0 ]; then
+ %userremove %{name}
+ %groupremove %{name}
+fi
+
+%triggerin cgi -- apache1 < 1.3.37-3, apache1-base
+%webapp_register apache %{_webapp}
+
+%triggerun cgi -- apache1 < 1.3.37-3, apache1-base
+%webapp_unregister apache %{_webapp}
+
+%triggerin cgi -- apache-base
+%webapp_register httpd %{_webapp}
+
+%triggerun cgi -- apache-base
+%webapp_unregister httpd %{_webapp}
+
+%triggerin cgi -- lighttpd
+%webapp_register lighttpd %{_webapp}
+
+%triggerun cgi -- lighttpd
+%webapp_unregister lighttpd %{_webapp}
+
+%triggerpostun -- %{name} < 2.0.5-0.3
+# we put trigger on main package, because we can't trigger in new package
+# this will create .rpmnew files when one installs -cgi package. but that's more than okay
+if [ -f /etc/httpd/httpd.conf/99_%{name}.conf.rpmsave ]; then
+ install -d %{_wwwconfdir}
+ mv -f /etc/httpd/httpd.conf/99_%{name}.conf.rpmsave %{_wwwconfdir}/httpd.conf
fi
+%service -q httpd reload
+
+%banner -e %{name} << EOF
+The CGI program is available as %{name}-cgi package.
+EOF
+
+%triggerpostun -- %{name} < 2.4.2-3
+find /var/lib/smokeping/rrd -type f -user root -group root -name \*.rrd -mtime -7 -exec chown smokeping \{\} \;
+find /var/lib/smokeping/rrd -type d -user root -group root -exec chown smokeping \{\} \;
+
%files
%defattr(644,root,root,755)
-%doc CHANGES CONTRIBUTORS COPYRIGHT TODO README doc/*.txt doc/*.html
-%attr(755,root,root) %{_bindir}/*
-%{_libdir}/*/*
-%{_mandir}/*/*
-%config %{_sysconfdir}/%name/config
-%config %{_sysconfdir}/%name/config-echoping
-%config %{_sysconfdir}/%name/smokemail
-%config %{_sysconfdir}/%name/basepage.html
-%config %{_sysconfdir}/httpd/conf.d/%{name}.conf
-%attr(755,root,root) %{_sysconfdir}/init.d/%name
-%dir %{_wwwrootdir}/%{name}/rrd
-%dir %{_wwwrootdir}/%{name}/img
-%{_wwwrootdir}/cgi-bin/%{name}
+%doc CHANGES CONTRIBUTORS COPYRIGHT README TODO doc/*.txt doc/examples
+%attr(755,root,root) %{_bindir}/smokeinfo
+%attr(755,root,root) %{_bindir}/smokeping
+%attr(755,root,root) %{_bindir}/tSmoke
+%{_datadir}/smokeping
+%exclude %{_cgi_bindir}/cropper
+%exclude %{_datadir}/smokeping/smokeping.*cgi
+%{_mandir}/man1/smokeping.1*
+%{_mandir}/man1/smokeping.cgi.1*
+%{_mandir}/man1/tSmoke.1*
+%{_mandir}/man3/*.3*
+%{_mandir}/man5/*.5*
+%{_mandir}/man7/*.7*
+%dir %{_sysconfdir}
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/basepage.html
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/config
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/config.dist
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/smokemail
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/smokeping_secrets
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/tmail
+%attr(754,root,root) /etc/rc.d/init.d/smokeping
+%dir %{_sharedstatedir}/%{name}
+%dir %attr(775,root,smokeping) %{_sharedstatedir}/%{name}/rrd
+%dir %attr(775,root,http) %{_sharedstatedir}/%{name}/img
+%dir %attr(770,root,smokeping) /var/run/%{name}
+%{systemdtmpfilesdir}/%{name}.conf
+
+%files cgi
+%defattr(644,root,root,755)
+%dir %attr(750,root,http) %{_wwwconfdir}
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_wwwconfdir}/apache.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_wwwconfdir}/httpd.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_wwwconfdir}/lighttpd.conf
+%{_cgi_bindir}/cropper
+%attr(755,root,root) %{_cgi_bindir}/smokeping.cgi