-### Configs instalation ###
-# Example config in sources: src/collectd.conf
-install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.conf
-install %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/ascent.conf
-install %{SOURCE11} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/apache.conf
-install %{SOURCE12} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/dns.conf
-install %{SOURCE13} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/hddtemp.conf
-install %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/ipmi.conf
-install %{SOURCE15} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/mysql.conf
-install %{SOURCE16} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/nginx.conf
-install %{SOURCE17} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/notify_desktop.conf
-install %{SOURCE18} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/notify_email.conf
-install %{SOURCE19} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/nut.conf
-install %{SOURCE20} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/ping.conf
-install %{SOURCE21} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/postgresql.conf
-install %{SOURCE22} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/powerdns.conf
-install %{SOURCE23} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/rrdtool.conf
-install %{SOURCE24} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/sensors.conf
-install %{SOURCE25} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/snmp.conf
-install %{SOURCE26} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/uuid.conf
-install %{SOURCE27} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/xmms.conf
-install %{SOURCE28} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/tcpconns.conf
-install %{SOURCE29} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/teamspeak2.conf
-install %{SOURCE30} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/thermal.conf
-install %{SOURCE31} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/unixsock.conf
-install %{SOURCE32} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/users.conf
-install %{SOURCE33} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/vmem.conf
-install %{SOURCE34} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/vserver.conf
-install %{SOURCE35} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/wireless.conf
-install %{SOURCE36} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/apcups.conf
-install %{SOURCE37} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/battery.conf
-install %{SOURCE38} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/cpufreq.conf
-install %{SOURCE39} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/cpu.conf
-install %{SOURCE40} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/csv.conf
-install %{SOURCE41} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/df.conf
-install %{SOURCE42} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/disk.conf
-install %{SOURCE43} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/email.conf
-install %{SOURCE44} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/entropy.conf
-install %{SOURCE45} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/exec.conf
-install %{SOURCE46} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/filecount.conf
-install %{SOURCE47} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/interface.conf
-install %{SOURCE48} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/iptables.conf
-install %{SOURCE49} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/irq.conf
-install %{SOURCE50} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/irq.conf
-install %{SOURCE51} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/load.conf
-install %{SOURCE52} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/logfile.conf
-install %{SOURCE53} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/mbmon.conf
-install %{SOURCE54} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/memcached.conf
-install %{SOURCE55} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/memory.conf
-install %{SOURCE56} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/multimeter.conf
-install %{SOURCE57} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/netlink.conf
-install %{SOURCE58} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/network.conf
-install %{SOURCE59} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/nfs.conf
-install %{SOURCE60} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/ntpd.conf
-install %{SOURCE61} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/processes.conf
-install %{SOURCE62} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/serial.conf
-install %{SOURCE63} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/swap.conf
-install %{SOURCE64} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/syslog.conf
-install %{SOURCE65} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/tail.conf
+%package tail
+Summary: tail-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka tail dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description tail
+The tail-plugin can be used to "tail" logfiles, i.e. follow them as
+tail -F does. Each line is given to one or more "matches" which test
+if the line is relevant for any statistics using a regular expression.
+
+%package tcpconns
+Summary: tcpconns-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka tcpconns dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description tcpconns
+The tcpconns-plugin counts the number of TCP connections to or from a
+specified port. Typically the connectioins where you specify the local
+port are incoming connections while the connections where you specify
+the remote port are outgoing connections.
+
+%package teamspeak2
+Summary: teamspeak2-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka teamspeak2 dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description teamspeak2
+The teamspeak2 plugin connects to the query port of a teamspeak2
+server and polls interesting global and virtual server data. The
+plugin can query only one physical server but unlimited virtual
+servers.
+
+%package ted
+Summary: ted-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka ted dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description ted
+The TED-plugin reads power consumption measurements from “The Energy
+Detective” (TED).
+
+%package thermal
+Summary: thermal-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka thermal dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description thermal
+The thermal plugin reads ACPI thermal zone information from the sysfs or
+procfs file system, i. e. mostly system temperature information.
+
+%package unixsock
+Summary: unixsock-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka unixsock dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description unixsock
+The unixsock plugin opens an UNIX-socket over which one can interact
+with the daemon. This can be used to use the values collected by
+collectd in other applications, such as monitoring, or submit
+externally collected values to collectd.
+
+%package uptime
+Summary: uptime-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka uptime dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description uptime
+The uptime-plugin can collect the server's uptime.
+
+%package users
+Summary: users-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka users dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description users
+Number of users currently logged in.
+
+%package uuid
+Summary: uuid-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka uuid dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description uuid
+This plugin, if loaded, causes the Hostname to be taken from the
+machine's UUID. The UUID is a universally unique designation for the
+machine, usually taken from the machine's BIOS. This is most useful if
+the machine is running in a virtual environment such as Xen, in which
+case the UUID is preserved across shutdowns and migration.
+
+%package vmem
+Summary: vmem-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka vmem dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description vmem
+The vmem plugin collects information about the usage of virtual
+memory. Since the statistics provided by the Linux kernel are very
+detailed, they are collected very detailed.
+
+%package vserver
+Summary: vserver-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka vserver dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description vserver
+Collects information about the virtual servers running on a system,
+using Linux-Vserver.
+
+%package write_http
+Summary: write_http-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka write_http dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description write_http
+The Write HTTP plugin sends the values collected by collectd to a
+web-server using HTTP POST requests. The data is formatted as PUTVAL
+commands.
+
+%package wireless
+Summary: wireless-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka wireless dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description wireless
+The Wireless plugin collects signal quality, signal power and
+signal-to-noise ratio for wireless LAN cards.
+
+%package xmms
+Summary: xmms-plugin for collectd
+Summary(pl_PL.UTF-8): Wtyczka xmms dla collectd
+Group: Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description xmms
+The XMMS plugin is a plugin for the XMMS music player. It graphs the
+bit-rate and sampling rate as you play songs. Not really useful, just
+something that got written because we can.
+
+%package -n perl-Collectd
+Summary: Perl files from Collectd package
+Group: Daemons
+
+%description -n perl-Collectd
+Perl files from Collectd package
+
+%prep
+%setup -q
+%patch0 -p1
+%patch1 -p1
+
+%build
+%{__libtoolize}
+%{__aclocal}
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+
+%configure \
+ --with-libstatgrab=/usr \
+ --with-lm-sensors=/usr \
+ --with-libmysql=/usr \
+ --%{?with_dns:en}%{!?with_dns:dis}able-dns \
+ --%{?with_ipmi:en}%{!?with_ipmi:dis}able-ipmi \
+ --%{?with_iptables:en}%{!?with_iptables:dis}able-iptables \
+ --%{?with_multimeter:en}%{!?with_multimeter:dis}able-multimeter \
+ --%{?with_mysql:en}%{!?with_mysql:dis}able-mysql \
+ --%{?with_netlink:en}%{!?with_netlink:dis}able-netlink \
+ --%{?with_notify:en}%{!?with_notify:dis}able-notify_desktop \
+ --%{?with_libesmtp:en}%{!?with_libesmtp:dis}able-notify_email \
+ --%{?with_ups:en}%{!?with_ups:dis}able-nut \
+ --%{?with_ping:en}%{!?with_ping:dis}able-ping \
+ --%{?with_pgsql:en}%{!?with_pgsql:dis}able-postgresql \
+ --%{?with_rrd:en}%{!?with_rrd:dis}able-rrdtool \
+ --%{?with_sensors:en}%{!?with_sensors:dis}able-sensors \
+ --%{?with_snmp:en}%{!?with_snmp:dis}able-snmp \
+ --%{?with_xmms:en}%{!?with_xmms:dis}able-xmms \
+ %{!?with_curl:--disable-{apache,ascent,bind,curl,nginx}} \
+ %{!?with_xml:--disable-{ascent,bind,libvirt}} \
+ --disable-ipvs \
+ --disable-libvirt \
+ --disable-perl
+
+
+%{__make} LDFLAGS="%{rpmldflags} -lstatgrab" \
+ BUILD_WITH_OPENIPMI_CFLAGS="-I/usr/include" \
+ BUILD_WITH_OPENIPMI_LIBS="-L%{_libdir} -lOpenIPMIutils -lOpenIPMIpthread"
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_var}/{log/,lib/%{name}},/etc/{rc.d/init.d/,collectd.d}} \
+ $RPM_BUILD_ROOT{%{_appdir}/cgi-bin,%{_webappdir},%{_pkglibdir},%{perl_vendorlib}/}
+
+%{__make} install \
+ DESTDIR=$RPM_BUILD_ROOT
+
+touch $RPM_BUILD_ROOT%{_var}/log/collectd.log
+install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+
+# Web frontend:
+install contrib/collection.conf $RPM_BUILD_ROOT%{_webappdir}
+install contrib/collection.cgi $RPM_BUILD_ROOT%{_appdir}/cgi-bin
+install %{SOURCE3} $RPM_BUILD_ROOT%{_webappdir}/apache.conf
+install %{SOURCE3} $RPM_BUILD_ROOT%{_webappdir}/httpd.conf
+install %{SOURCE4} $RPM_BUILD_ROOT%{_webappdir}/lighttpd.conf
+
+cp -R contrib/collection3 $RPM_BUILD_ROOT%{_appdir}
+
+### Configs instalation ###
+for i in `egrep "^(#|)LoadPlugin" src/collectd.conf |awk '{print $NF}' ` ; do
+ egrep "LoadPlugin $i$" src/collectd.conf | %{__sed} -e "s/^#//" > $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/$i.conf
+ grep -v LoadPlugin src/collectd.conf |%{__sed} -e '/./{H;$!d;}' -e "x;/ $i>/!d;" >> $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/$i.conf
+done
+
+# Example config in sources: src/collectd.conf
+install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.conf
+
+# Overwrite only files which we want to change:
+install %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/df.conf
+install %{SOURCE11} $RPM_BUILD_ROOT%{_sysconfdir}/collectd.d/rrdtool.conf
+
+mv $RPM_BUILD_ROOT%{_datadir}/perl5/Collectd* $RPM_BUILD_ROOT%{perl_vendorlib}/