[ndoutils/el5: 7/8] Update to 1.5.2, rework spec file.

Simone Caronni slaanesh at fedoraproject.org
Mon Feb 24 15:18:38 UTC 2014


commit 13a07434e7d451a201a550ddd737ec30cc6e80bc
Author: Simone Caronni <negativo17 at gmail.com>
Date:   Mon Feb 24 16:18:05 2014 +0100

    Update to 1.5.2, rework spec file.

 .gitignore                  |    1 +
 README.Fedora               |   43 +++++-----
 ndo2db.initd => ndo2db.init |    0
 ndo2db.service              |   13 +++
 ndoutils.spec               |  186 +++++++++++++++++++++++++++----------------
 sources                     |    2 +-
 6 files changed, 153 insertions(+), 92 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index ddf79db..743797a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 ndoutils-1.4b8.tar.gz
+/ndoutils-1.5.2.tar.gz
diff --git a/README.Fedora b/README.Fedora
index 93db7c9..7e8e483 100644
--- a/README.Fedora
+++ b/README.Fedora
@@ -1,18 +1,17 @@
-Having installed ndoutils you must install ndoutils-mysql. 
-Currently this is only database supported by ndoutils more
-alternatives will be added later as ndoutils supports them.
+After having installed ndoutils, you must install ndoutils-mysql. Currently
+MySQL is the only database supported by ndoutils; more alternatives will be
+added later as ndoutils supports them.
 
-The alternatives mechanism is used to choose the version
-of ndo2db that you want.
+The alternatives mechanism is used to choose the version of ndo2db backend that
+you want.
 
-# alternatives --display ndo2db
-ndo2db - status is auto.
- link currently points to /usr/sbin/ndo2db.mysql
-/usr/sbin/ndo2db.mysql - priority 40
-Current `best' version is /usr/sbin/ndo2db.mysql.
+    # alternatives --display ndo2db
+    ndo2db - status is auto.
+     link currently points to /usr/sbin/ndo2db.mysql
+    /usr/sbin/ndo2db.mysql - priority 40
+    Current `best' version is /usr/sbin/ndo2db.mysql.
 
-To configure ndoutils for use with Nagios and mysql please follow the following
-when running with Fedora.
+To configure ndoutils for use with Nagios and MySQL please follow the following:
 
 1) Start a shell to MySQL and create and grant access to a database.
 
@@ -25,19 +24,21 @@ mysql> quit
 $ cd /usr/share/doc/ndoutils-mysql-*/db
 $ perl ./installdb -u ndouser -p ndopassword -h localhost -d nagios
 
-3) To your /etc/nagios/nagios.cfg file make the following configuration.
+3) Edit your /etc/nagios/nagios.cfg file adding the following line (adjust the
+path with the correct 32/64 bit path, of course).
 
 broker_module=/usr/lib/nagios/brokers/ndomod.so config_file=/etc/nagios/ndomod.cfg
 
-(lib64 for 64bit of course.)
-
-4) Start ndo2db
-/sbin/service ndo2db start
-/sbin/chkconfig ndo2db on
-
-4) Restart Nagios
-/sbin/service nagios restart
+4) Start ndo2db and restart Nagios:
 
+On RHEL:
 
+chkconfig ndo2db on
+service ndo2db start
+service nagios restart
 
+On Fedora:
 
+systemctl enable ndo2db
+systemctl start ndo2b
+systemctl restart nagios
diff --git a/ndo2db.initd b/ndo2db.init
similarity index 100%
rename from ndo2db.initd
rename to ndo2db.init
diff --git a/ndo2db.service b/ndo2db.service
new file mode 100644
index 0000000..503aa6c
--- /dev/null
+++ b/ndo2db.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Stores data from Nagios in a database
+Documentation=http://www.nagios.org/documentation
+
+[Service]
+Type=simple
+User=nagios
+Group=nagios
+#PIDFile=/var/run/ndoutils/ndo2db.pid
+ExecStart=/usr/sbin/ndo2db -c /etc/nagios/ndo2db.cfg
+
+[Install]
+WantedBy=nagios.service
diff --git a/ndoutils.spec b/ndoutils.spec
index c6b149d..e2a814d 100644
--- a/ndoutils.spec
+++ b/ndoutils.spec
@@ -1,142 +1,187 @@
-
-%global betaversion b9
-%{?betaversion: %global dotbetaversion .%{betaversion}}
-
 Name:           ndoutils
-Version:        1.4
+Version:        1.5.2
 
-Release:        0.7%{?dotbetaversion}%{?dist}
+Release:        0%{?dist}
 Summary:        Stores all configuration and event data from Nagios in a database
-
 Group:          Applications/System
 License:        GPLv2
 URL:            http://www.nagios.org/download/addons/
-Source0:        http://downloads.sourceforge.net/nagios/ndoutils-%{version}%{?betaversion}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+Source0:        http://downloads.sourceforge.net/nagios/ndoutils-%{version}.tar.gz
 Source1:        README.Fedora
 Source2:        ndo2db.cfg 
 Source3:        ndomod.cfg
-Source4:        ndo2db.initd
+Source4:        ndo2db.service
+Source5:        ndo2db.init
 Patch0:         ndo-shared-so.patch
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  mysql-devel
-# On RHEL4 and 5 we build for nagios 2 rather than a default 3 or more.
-%if 0%{?el4}%{?el5}
+
+# Nagios is required also for user and group
+%if 0%{?rhel} == 5
 Requires:       nagios < 3
 %else
 Requires:       nagios >= 3
 %endif
 
+%if 0%{?fedora} || 0%{?rhel} >= 7
+Requires(post):     systemd
+Requires(preun):    systemd
+Requires(postun):   systemd
+%endif
 
-Requires(post): chkconfig
-Requires(preun): chkconfig, initscripts
+%if 0%{?rhel} == 5 || 0%{?rhel} == 6
+Requires(post):     /sbin/chkconfig
+Requires(preun):    /sbin/chkconfig
+Requires(preun):    /sbin/service
+Requires(postun):   /sbin/service
+%endif
 
-%package mysql
-Summary: Contains the ndoutils ndo2db for mysql
-Group: Applications/System
-Requires:ndoutils = %{version}-%{release}
+%description
+The NDOUtils add on is designed to store all configuration and event data from
+Nagios in a database. Storing information from Nagios in a database will allow
+for quicker retrieval and processing of that data.
 
-%description mysql
-Contains an ndo2db for writing ndoutils data from 
-nagios to MySQL.
+%package        mysql
+Summary:        Contains the NDOUtils ndo2db for MySQL
+Group:          Applications/System
+Requires:       ndoutils = %{version}-%{release}
+
+%description    mysql
+Contains an ndo2db for writing ndoutils data from Nagios to MySQL.
 
-%description
-The NDOUTILS addon is designed to store all configuration and event data 
-from Nagios in a database. Storing information from Nagios in a database will 
-allow for quicker retrieval and processing of that data and will help
-serve as a foundation for the development of a new PHP-based web 
-interface in Nagios 3.0.
 
 %prep
-%setup -q -n %{name}-%{version}%{?betaversion}
+%setup -q
 %patch0 -p1
 
 # Remove executable bits from the example scripts in 
 # the documentation.
-%{__chmod} 644 db/installdb db/prepsql db/upgradedb
+chmod 644 db/installdb db/prepsql db/upgradedb
 
 
 %build
 %configure 
-%{__make} %{?_smp_mflags}
-%if 0%{?el4}%{?el5}
-%{__cp} src/ndo2db-2x src/ndo2db.mysql
+make %{?_smp_mflags}
+%if 0%{?rhel} == 5
+cp -p src/ndo2db-2x src/ndo2db.mysql
 %else
-%{__cp} src/ndo2db-3x src/ndo2db.mysql
+cp -p src/ndo2db-3x src/ndo2db.mysql
 %endif
 
 %install
-# Upstream does not provide an install target.
-# http://tracker.nagios.org/view.php?id=21
-rm -rf $RPM_BUILD_ROOT
-
-%{__install} -m 644 %{SOURCE1} README.Fedora
-%{__install} -m 755 -D src/ndo2db.mysql $RPM_BUILD_ROOT/%{_sbindir}/ndo2db.mysql
+rm -rf %{buildroot}
+install -p -m 644 %{SOURCE1} README.Fedora
 
-%if 0%{?el4}%{?el5}
-%{__install} -m 755 -D src/ndomod-2x.so $RPM_BUILD_ROOT/%{_libdir}/nagios/brokers/ndomod.so
+# Perform a manual install, we rely on main Nagios package (user, group, etc.)
+%if 0%{?rhel} == 5
+install -p -m 755 -D src/ndomod-2x.so %{buildroot}%{_libdir}/nagios/brokers/ndomod.so
 %else
-%{__install} -m 755 -D src/ndomod-3x.so $RPM_BUILD_ROOT/%{_libdir}/nagios/brokers/ndomod.so
+install -p -m 755 -D src/ndomod-3x.so %{buildroot}%{_libdir}/nagios/brokers/ndomod.so
 %endif
 
-%{__install} -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/nagios/ndo2db.cfg
-%{__install} -m 644 -D %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/nagios/ndomod.cfg
-%{__install} -m 755 -D %{SOURCE4} $RPM_BUILD_ROOT/%{_initrddir}/ndo2db
-%{__mkdir} -p $RPM_BUILD_ROOT/%{_var}/log/ndoutils
-%{__mkdir} -p $RPM_BUILD_ROOT/%{_var}/run/ndoutils
-%{__mkdir} -p $RPM_BUILD_ROOT/%{_var}/cache/ndoutils
+install -p -m 755 -D src/ndo2db.mysql %{buildroot}%{_sbindir}/ndo2db.mysql
+install -p -m 644 -D %{SOURCE2} %{buildroot}%{_sysconfdir}/nagios/ndo2db.cfg
+install -p -m 644 -D %{SOURCE3} %{buildroot}%{_sysconfdir}/nagios/ndomod.cfg
+mkdir -p %{buildroot}%{_localstatedir}/log/ndoutils
+mkdir -p %{buildroot}%{_localstatedir}/run/ndoutils
+mkdir -p %{buildroot}%{_localstatedir}/cache/ndoutils
+
+# Remove some spurious permissions from docs
+find docs/html -name "*.*" -exec chmod 644 {} \;
+
+%if 0%{?fedora} || 0%{?rhel} >= 7
+
+# Systemd unit files
+mkdir -p %{buildroot}%{_unitdir}
+install -p -m 644 -D %{SOURCE4} %{buildroot}%{_unitdir}/ndo2db.service
+
+%else
+
+# Initscripts
+mkdir -p %{buildroot}%{_initrddir}
+install -p -m 755 -D %{SOURCE5} %{buildroot}%{_initrddir}/ndo2db
+
+%endif
 
 %clean
-%{__rm} -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
 %files
 %defattr(-,root,root,-)
-
-%{_libdir}/nagios/brokers/ndomod.so
-%{_initrddir}/ndo2db
-
+%doc README.Fedora docs/html README REQUIREMENTS TODO UPGRADING
 %config(noreplace) %{_sysconfdir}/nagios/ndo2db.cfg
 %config(noreplace) %{_sysconfdir}/nagios/ndomod.cfg
-
-%dir %attr(-,nagios,root) /var/run/ndoutils
-%dir %attr(-,nagios,root) /var/log/ndoutils
-%dir %attr(-,nagios,root) /var/cache/ndoutils
-
-%doc README.Fedora docs README REQUIREMENTS TODO UPGRADING
+%{_libdir}/nagios/brokers/ndomod.so
+%if 0%{?fedora} || 0%{?rhel} >= 7
+%{_unitdir}/ndo2db.service
+%else
+%{_initrddir}/ndo2db
+%endif
+%dir %attr(-,nagios,root) %{_localstatedir}/run/ndoutils
+%dir %attr(-,nagios,root) %{_localstatedir}/log/ndoutils
+%dir %attr(-,nagios,root) %{_localstatedir}/cache/ndoutils
 
 %files mysql
 %defattr(-,root,root,-)
 %{_sbindir}/ndo2db.mysql
 %doc db
 
+%if 0%{?fedora} || 0%{?rhel} >= 7
+
+%post
+%systemd_post ndo2db.service
+
+%preun
+%systemd_preun ndo2db.service
+
+%postun
+%systemd_postun_with_restart ndo2db.service
+
+%endif
+
+%if 0%{?rhel} == 6
+
+%post
+/sbin/chkconfig --add ndo2db
+
 %preun
-if [ $1 = 0 ]; then
-    /sbin/service ndo2db stop > /dev/null 2>&1 || :
-    /sbin/chkconfig --del ndo2db || :
+if [ "$1" = 0 ]; then
+        /sbin/service ndo2db stop >/dev/null 2>&1 || :
+        /sbin/chkconfig --del ndo2db
 fi
 
-%preun mysql
-if [ $1 = 0 ]; then
-  /usr/sbin/alternatives --remove ndo2db /usr/sbin/ndo2db.mysql
+%postun
+if [ "$1" -ge "1" ]; then
+        /sbin/service ndo2db condrestart >/dev/null 2>&1 || :
 fi
 
-%post
-/sbin/chkconfig --add ndo2db || :
+%endif
 
 %post mysql
 /usr/sbin/alternatives --install /usr/sbin/ndo2db ndo2db /usr/sbin/ndo2db.mysql 40
 
 %changelog
+* Mon Feb 24 2014 Simone Caronni <negativo17 at gmail.com> - 1.5.2-1
+- Updated to 1.5.2.
+- Updated SPEC file for current packaging guidelines.
+- Use only generated docs for binary package.
+
 * Wed Nov 11 2009 Steve Traylen <tmraz at redhat.com> - 1.4-0.7.b9
 - New upstream version. 1.4b9
+
 * Fri Aug 21 2009 Tomas Mraz <tmraz at redhat.com> - 1.4-0.7.b8
 - rebuilt with new openssl
+
 * Tue Jul 21 2009 Steve Traylen <steve.traylen at cern.ch> - 1.4-0.6.b8
 - A requires nagios = 2 will not work.
+
 * Tue Jul 21 2009 Steve Traylen <steve.traylen at cern.ch> - 1.4-0.5.b8
 - Updated to nodutils 1.4b8.
 - mysql lib path no longer needs to be set explicitly.
 - Use dist tags to install for nagios2 on el4 and el5.
+
 * Mon Jul 20 2009 Steve Traylen <steve.traylen at cern.ch> - 1.4-0.4.b7
 - Patch ndomod.o to be ndomod.so since it is a shared object.
 - Move ndomod.so from /usr/lib to /usr/lib/nagios/brokers
@@ -144,18 +189,19 @@ fi
 - Change SourceURL to fedora package guideline for sourceforge.
 - Completly removed postgres support. The documents clearly state
   it is not supported.
+
 * Sun Jun 14 2009 Steve Traylen <steve at traylen.net> - 1.4-0.3.b7
 - Move ndo2db.cfg and ndomod.cfg to /etc/nagios as per install
   guide.
 - Remove executable bits from documentation examples.
+
 * Thu Jun 11 2009 Steve Traylen <steve at traylen.net> - 1.4-0.2.b7
 - Split package to create postgres and mysql binary in different
   sub packages.
+
 * Wed Jun 10 2009 Steve Traylen <steve at traylen.net> - 1.4-0.1.b7
 - Add full URL location to Source0:
 - Use special Version/Release tag since a beta. i.e 1.4-0.1.b7
+
 * Sat Apr 25 2009 Steve Traylen <steve at traylen.net> 
 - First Build
-
-
-
diff --git a/sources b/sources
index a65ca29..ef07f40 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-659b759a5eb54b84eb44a29f26b603bc  ndoutils-1.4b9.tar.gz
+61460320d0deb8109e7e45e2b717ce1f  ndoutils-1.5.2.tar.gz


More information about the scm-commits mailing list