I think the spec files have fallen into neglect, and some kind of spring cleaning is necessary. I am not the one to do it, I don't have enough time. I've merely fixed the specs while keeping them close to the original version, which is probably not ideal. The spec files should be overhauled closer to the RPM guidelines.
First off, take a look at the attached files. These are the fixed specs. Just remove the .txt extension, put the tarball in the SOURCES directory in your RPM build area, and do a "rpmbuild -ba specfilename.spec" and it will build the packages for you.
Now let's discuss each spec file. I'll do a diff -u on each spec file and discuss the output.
Nagios Core 4.0.0
Firstly, compilation during the package build fails outright on RH5 with the default gcc-4.1.2 compiler. You need to install the gcc44 package (yum install gcc44), then do "export CC=gcc44", then try again "rpmbuild -ba nagios.spec". I've chosen to use gcc44 for all Nagios-related packages, not only for Core, just to keep things consistent, even though the other packages may build without it.
The issue has been filed here:
http://tracker.nagios.org/view.php?id=488
Let's discuss the diff:
Code: Select all
[root@oracle5 specs]# diff -u orig/nagios.spec fixed/nagios.spec
--- orig/nagios.spec 2013-09-20 12:01:20.000000000 -0700
+++ fixed/nagios.spec 2013-10-23 11:37:20.000000000 -0700
@@ -65,7 +65,7 @@
This package contains all the files from the contrib directory
%prep
-%setup
+%setup -n %{name}
# /usr/local/nagios is hardcoded in many places
%{__perl} -pi.orig -e 's|/usr/local/nagios/var/rw|%{_localstatedir}/nagios/rw|g;' contrib/eventhandlers/submit_check_result
Bug report filed here:
http://tracker.nagios.org/view.php?id=487
Code: Select all
@@ -153,10 +153,10 @@
%{__cp} -afpv contrib/eventhandlers/* %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/
%{__mv} contrib/README contrib/README.contrib
-CGI=`/bin/find contrib/ -name '*.cgi' -type f |sed s/'contrib\/'//g`
+CGI=`find contrib/ -name '*.cgi' -type f |sed s/'contrib\/'//g`
CGI=`for i in $CGI; do echo -n "$i|"; done |sed s/\|$//`
-/bin/find %{buildroot}/%{_libdir}/nagios/cgi -type f -print | sed s!'%{buildroot}'!!g | egrep -ve "($CGI)" > cgi.files
-/bin/find %{buildroot}/%{_libdir}/nagios/cgi -type f -print | sed s!'%{buildroot}'!!g | egrep "($CGI)" > contrib.files
+find %{buildroot}/%{_libdir}/nagios/cgi -type f -print | sed s!'%{buildroot}'!!g | egrep -ve "($CGI)" > cgi.files
+find %{buildroot}/%{_libdir}/nagios/cgi -type f -print | sed s!'%{buildroot}'!!g | egrep "($CGI)" > contrib.files
Bug report filed here:
http://tracker.nagios.org/view.php?id=489
Code: Select all
@@ -206,7 +206,7 @@
%attr(0755,root,root) %config %{_initrddir}/nagios
%attr(0755,root,root) %{_bindir}/nagios
%attr(0755,root,root) %{_bindir}/nagiostats
-%attr(0644,root,root) %{_libdir}/nagios/plugins/
+%attr(0755,root,root) %{_libdir}/nagios/plugins/
%attr(0755,root,root) %{_datadir}/nagios/
%attr(0755,nagios,nagios) %dir %{_sysconfdir}/nagios/
%attr(0644,nagios,nagios) %config(noreplace) %{_sysconfdir}/nagios/*.cfg
Nagios Plugins 1.5
You need to build this package as root, even though this is contrary to standard practice, otherwise some plugins would not install correctly.
Here's the diff:
Code: Select all
[root@oracle5 specs]# diff -u orig/nagios-plugins.spec fixed/nagios-plugins.spec
--- orig/nagios-plugins.spec 2013-10-02 08:26:48.000000000 -0700
+++ fixed/nagios-plugins.spec 2013-10-23 11:37:27.000000000 -0700
@@ -7,12 +7,12 @@
%define _prefix /opt/nagios
# %define _defaultdocdir %{_datadir}/doc
%else
- %define _libexecdir %{_exec_prefix}/lib/nagios/plugins
+ %define _libexecnagios "%{_libdir}/nagios/plugins"
%endif
-%define _sysconfdir /etc/nagios
+%define _sysconfnagios "%{_sysconfdir}/nagios"
%define npusr nagios
-%define nphome /opt/nagios
+%define nphome %{_localstatedir}/log/nagios
%define npgrp nagios
Name: nagios-plugins
Also, while the Core package correctly uses the %{_libdir} macro to choose the location for the plugins directory, which ends up in /usr/lib64/nagios/plugins on a 64 bit system (and /usr/lib/nagios/plugins on a 32 bit system), the Plugins spec hardcodes that path to */lib/nagios/plugins no matter what. Nothing will work if you build the Core and the Plugins packages from tarballs on 64 bit Linux, because the plugin locations will be different. The packages will be incompatible.
I've changed the definition of the plugins directory to match the Core tarball, and be consistent with the architecture of the OS where you're building it.
Code: Select all
@@ -30,8 +30,8 @@
%if %{isaix}
Prefix: %{_prefix}
-%else
-Prefix: %{_prefix}/lib/nagios/plugins
+#%else
+#Prefix: %{_prefix}/lib/nagios/plugins
%endif
Packager: Karl DeBisschop <kdebisschop@users.sourceforge.net>
Vendor: Nagios Plugin Development Group
Code: Select all
@@ -117,8 +117,8 @@
%{?isaix: MAKE=gmake} ./configure \
--prefix=%{_prefix} \
--exec-prefix=%{_exec_prefix} \
---libexecdir=%{_libexecdir} \
---sysconfdir=%{_sysconfdir} \
+--libexecdir="%{_libdir}/nagios/plugins" \
+--sysconfdir=%{_sysconfnagios} \
--datadir=%{_datadir} \
--with-cgiurl=/nagios/cgi-bin
ls -1 %{npdir}/plugins > %{npdir}/ls-plugins-before
Code: Select all
@@ -155,7 +155,7 @@
%if %{islinux}
getent passwd %{npusr} > /dev/null 2> /dev/null
if [ $? -ne 0 ] ; then
- useradd -r -d %{nshome} -c "%{npusr}" -g %{npgrp} %{npusr} || \
+ useradd -r -d %{nphome} -c "%{npusr}" -g %{npgrp} %{npusr} || \
%nnmmsg Unexpected error adding user "%{npusr}". Aborting install process.
fi
%endif
Code: Select all
@@ -163,30 +163,32 @@
%install
rm -rf $RPM_BUILD_ROOT
make AM_INSTALL_PROGRAM_FLAGS="" DESTDIR=${RPM_BUILD_ROOT} install
-build-aux/install-sh -c -d ${RPM_BUILD_ROOT}%{_sysconfdir}
-build-aux/install-sh -c -m 664 command.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}
+build-aux/install-sh -c -d ${RPM_BUILD_ROOT}%{_sysconfnagios}
+#build-aux/install-sh -c -m 664 command.cfg ${RPM_BUILD_ROOT}%{_sysconfnagios}
+build-aux/install-sh -c -m 664 plugins/libnpcommon.a ${RPM_BUILD_ROOT}%{_libexecnagios}
%find_lang %{name}
echo "%defattr(755,%{npusr},%{npgrp})" >> %{name}.lang
-comm -13 %{npdir}/ls-plugins-before %{npdir}/ls-plugins-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
+comm -13 %{npdir}/ls-plugins-before %{npdir}/ls-plugins-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecnagios} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
echo "%defattr(755,root,root)" >> %{name}.lang
-comm -13 %{npdir}/ls-plugins-root-before %{npdir}/ls-plugins-root-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
+comm -13 %{npdir}/ls-plugins-root-before %{npdir}/ls-plugins-root-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecnagios} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
echo "%defattr(755,%{npusr},%{npgrp})" >> %{name}.lang
-comm -13 %{npdir}/ls-plugins-scripts-before %{npdir}/ls-plugins-scripts-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
-echo "%{_libexecdir}/utils.pm" >> %{name}.lang
-echo "%{_libexecdir}/utils.sh" >> %{name}.lang
+comm -13 %{npdir}/ls-plugins-scripts-before %{npdir}/ls-plugins-scripts-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecnagios} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
+echo "%{_libexecnagios}/utils.pm" >> %{name}.lang
+echo "%{_libexecnagios}/utils.sh" >> %{name}.lang
%clean
rm -rf $RPM_BUILD_ROOT
%files -f %{name}.lang
-%config(missingok,noreplace) %{_sysconfdir}/command.cfg
+#%config(missingok,noreplace) %{_sysconfnagios}/command.cfg
%doc CODING COPYING FAQ INSTALL LEGAL README REQUIREMENTS SUPPORT THANKS
-%doc ChangeLog command.cfg
+%doc ChangeLog
%if ! %{isaix}
%{_datadir}/locale/de/LC_MESSAGES/nagios-plugins.mo
%{_datadir}/locale/fr/LC_MESSAGES/nagios-plugins.mo
%endif
+%{_libdir}/nagios/plugins/check_ldaps
%changelog
* Mon May 23 2005 Sean Finney <seanius@seanius.net> - cvs head
I think command.cfg was not even built, IIRC.
check_ldaps is installed, but it's not taken into the RPM for some reason, and the final stage of package building breaks. I don't have time to investigate why. Just add it here and it works. This is not a clean fix, sorry.
NRPE 2.15
This one also has to be built as root, otherwise changing the ownership on check_nrpe fails.
Here's the diff:
Code: Select all
[root@oracle5 specs]# diff -u orig/nrpe.spec fixed/nrpe.spec
--- orig/nrpe.spec 2013-09-06 08:27:13.000000000 -0700
+++ fixed/nrpe.spec 2013-10-23 11:37:33.000000000 -0700
@@ -9,16 +9,14 @@
%endif
%if %{islinux}
%define _init_dir /etc/init.d
- %define _exec_prefix %{_prefix}/sbin
- %define _bindir %{_prefix}/sbin
- %define _sbindir %{_prefix}/lib/nagios/cgi
- %define _libexecdir %{_prefix}/lib/nagios/plugins
- %define _datadir %{_prefix}/share/nagios
- %define _localstatedir /var/log/nagios
- %define nshome /var/log/nagios
+ %define _bindir_nrpe %{_prefix}/sbin
+ %define _sbindir_nrpe %{_libdir}/nagios/cgi
+ %define _libexecdir_nrpe %{_libdir}/nagios/plugins
+ %define _datadir_nrpe %{_datadir}/nagios
+ %define nshome %{_localstatedir}/log/nagios
%define _make make
%endif
-%define _sysconfdir /etc/nagios
+%define _sysconfdir_nrpe %{_sysconfdir}/nagios
%define name nrpe
%define version 2.15
And again, the same issue with the compatibility with Core w.r.t. the location of the plugins directory. This package, again, was incorrectly hardcoding it to */lib/nagios/plugins, unlike Core. Fixed that to make these packages play nicely together.
Code: Select all
@@ -141,7 +139,7 @@
%post
/usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
if [ $? -eq 1 ] ; then
- /usr/bin/mkssys -p %{_bindir}/nrpe -s nrpe -u 0 -a "-c %{_sysconfdir}/nrpe.cfg -d -s" -Q -R -S -n 15 -f 9
+ /usr/bin/mkssys -p %{_bindir_nrpe}/nrpe -s nrpe -u 0 -a "-c %{_sysconfdir_nrpe}/nrpe.cfg -d -s" -Q -R -S -n 15 -f 9
fi
/usr/bin/startsrc -s nrpe
%endif
Code: Select all
@@ -177,13 +175,11 @@
--with-nrpe-user=%{nsusr} \
--with-nrpe-group=%{nsgrp} \
--prefix=%{_prefix} \
- --exec-prefix=%{_exec_prefix} \
- --bindir=%{_bindir} \
- --sbindir=%{_sbindir} \
- --libexecdir=%{_libexecdir} \
- --datadir=%{_datadir} \
- --sysconfdir=%{_sysconfdir} \
- --localstatedir=%{_localstatedir} \
+ --bindir=%{_bindir_nrpe} \
+ --sbindir=%{_sbindir_nrpe} \
+ --libexecdir=%{_libexecdir_nrpe} \
+ --datadir=%{_datadir_nrpe} \
+ --sysconfdir=%{_sysconfdir_nrpe} \
--enable-command-args
%{_make} all
Code: Select all
@@ -193,17 +189,17 @@
install -d -m 0755 ${RPM_BUILD_ROOT}%{_init_dir}
%endif
DESTDIR=${RPM_BUILD_ROOT} %{_make} install install-daemon-config
-#install -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir}
-#install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
-#install -d -m 0755 ${RPM_BUILD_ROOT}%{_libexecdir}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir_nrpe}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir_nrpe}
+#install -d -m 0755 ${RPM_BUILD_ROOT}%{_libexecdir_nrpe}
# install templated configuration files
-#cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}/nrpe.cfg
+cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}%{_sysconfdir_nrpe}/nrpe.cfg
#%if %{isaix}
-#cp init-script ${RPM_BUILD_ROOT}%{_init_dir}/nrpe
+cp init-script ${RPM_BUILD_ROOT}%{_init_dir}/nrpe
#%endif
-#cp src/nrpe ${RPM_BUILD_ROOT}%{_bindir}
-#cp src/check_nrpe ${RPM_BUILD_ROOT}%{_libexecdir}
+#cp src/nrpe ${RPM_BUILD_ROOT}%{_bindir_nrpe}
+#cp src/check_nrpe ${RPM_BUILD_ROOT}%{_libexecdir_nrpe}
%clean
rm -rf $RPM_BUILD_ROOT
Not sure why the init script was not being copied to /etc/init.d. It's needed there for the NRPE service. I've enabled the copy. Same for the .cfg file.
Code: Select all
@@ -214,16 +210,16 @@
%defattr(755,root,root)
/etc/init.d/nrpe
%endif
-%{_bindir}/nrpe
-%dir %{_sysconfdir}
+%{_bindir_nrpe}/nrpe
+%dir %{_sysconfdir_nrpe}
%defattr(600,%{nsusr},%{nsgrp})
-%config(noreplace) %{_sysconfdir}/*.cfg
+%config(noreplace) %{_sysconfdir_nrpe}/*.cfg
%defattr(755,%{nsusr},%{nsgrp})
%doc Changelog LEGAL README
%files plugin
%defattr(755,%{nsusr},%{nsgrp})
-%{_libexecdir}
+%{_libexecdir_nrpe}
%defattr(644,%{nsusr},%{nsgrp})
%doc Changelog LEGAL README