Просмотр исходного кода

More changes to get 'rpmbuild' to work

Additional fix for https://github.com/NagiosEnterprises/nrpe/issues/50
John C. Frickson 9 лет назад
Родитель
Сommit
87979d93e1
3 измененных файлов с 34 добавлено и 95 удалено
  1. 12 8
      Makefile.in
  2. 8 62
      nrpe.spec.in
  3. 14 25
      src/Makefile.in

+ 12 - 8
Makefile.in

@@ -9,6 +9,9 @@
 SRC_BASE=./src/
 SRC_INCLUDE=./include/
 
+# Mainly used for rpmbuild
+# DESTDIR=
+
 CC=@CC@
 CFLAGS=@CFLAGS@ @DEFS@
 LDFLAGS=@LDFLAGS@ @LIBS@
@@ -17,12 +20,12 @@ INSTALL=@INSTALL@
 GREP=@GREP@
 EGREP=@EGREP@
 
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-CFGDIR=@pkgsysconfdir@
-BINDIR=@bindir@
-SBINDIR=@sbindir@
-LIBEXECDIR=@libexecdir@
+prefix=$(DESTDIR)@prefix@
+exec_prefix=$(DESTDIR)@exec_prefix@
+CFGDIR=$(DESTDIR)@pkgsysconfdir@
+BINDIR=$(DESTDIR)@bindir@
+SBINDIR=$(DESTDIR)@sbindir@
+LIBEXECDIR=$(DESTDIR)@libexecdir@
 NAGIOS_INSTALL_OPTS=@NAGIOS_INSTALL_OPTS@
 NRPE_INSTALL_OPTS=@NRPE_INSTALL_OPTS@
 OPSYS=@opsys@
@@ -33,11 +36,11 @@ NAGIOS_USER=@nagios_user@
 NAGIOS_GROUP=@nagios_group@
 
 INIT_TYPE=@init_type@
-INIT_DIR=@initdir@
+INIT_DIR=$(DESTDIR)@initdir@
 INIT_OPTS=-o root -g root
 INIT_FILE=@initname@
 INETD_TYPE=@inetd_type@
-INETD_DIR=@inetddir@
+INETD_DIR=$(DESTDIR)@inetddir@
 INETD_FILE=@inetdname@
 SRC_INETD=@src_inetd@
 SRC_INIT=@src_init@
@@ -186,6 +189,7 @@ distclean: clean
 	rm -f startup/newbsd-init startup/openbsd-init startup/openrc-conf
 	rm -f startup/openrc-init startup/rh-upstart-init startup/solaris-init.xml
 	rm -f startup/solaris-inetd.xml startup/tmpfile.conf startup/upstart-init
+	rm -f nrpe.spec uninstall include/common.h
 	rm -f Makefile
 
 devclean: distclean

+ 8 - 62
nrpe.spec.in

@@ -8,7 +8,7 @@
 	%define _make gmake
 %endif
 %if %{islinux}
-	%define _init_dir /etc/init.d
+	%define _init_dir @initdir@
 	%define _exec_prefix %{_prefix}/sbin
 	%define _bindir %{_prefix}/sbin
 	%define _sbindir %{_prefix}/lib/nagios/cgi
@@ -44,7 +44,7 @@ Group: Application/System
 Source0: %{name}-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-buildroot
 Prefix: %{_prefix}
-Prefix: /etc/init.d
+Prefix: @initdir@
 Prefix: /etc/nagios
 %if %{isaix}
 Requires: nagios-plugins
@@ -80,38 +80,6 @@ Nagios-related applications.
 %prep
 %setup -q
 
-
-%pre
-# Create `nagios' group on the system if necessary
-%if %{isaix}
-lsgroup %{nsgrp} > /dev/null 2> /dev/null
-if [ $? -eq 2 ] ; then
-	mkgroup %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
-fi
-%endif
-%if %{islinux}
-getent group %{nsgrp} > /dev/null 2> /dev/null
-if [ $? -ne 0 ] ; then
-	groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
-fi
-%endif
-
-# Create `nrpe' user on the system if necessary
-%if %{isaix}
-lsuser %{nsusr} > /dev/null 2> /dev/null
-if [ $? -eq 2 ] ; then
-	useradd -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
-		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
-fi
-%endif
-%if %{islinux}
-getent passwd %{nsusr} > /dev/null 2> /dev/null
-if [ $? -ne 0 ] ; then
-	useradd -r -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
-		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
-fi
-%endif
-
 %if %{isaix}
 # Check to see if the nrpe service is running and, if so, stop it.
 /usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
@@ -123,20 +91,6 @@ if [ $? -eq 0 ] ; then
 fi
 %endif
 
-%if %{islinux}
-# if LSB standard /etc/init.d does not exist,
-# create it as a symlink to the first match we find
-if [ -d /etc/init.d -o -L /etc/init.d ]; then
-  : # we're done
-elif [ -d /etc/rc.d/init.d ]; then
-  ln -s /etc/rc.d/init.d /etc/init.d
-elif [ -d /usr/local/etc/rc.d ]; then
-  ln -s  /usr/local/etc/rc.d /etc/init.d
-elif [ -d /sbin/init.d ]; then
-  ln -s /sbin/init.d /etc/init.d
-fi
-%endif
-
 %if %{isaix}
 %post
 /usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
@@ -192,18 +146,8 @@ MAKE=%{_make} ./configure \
 %if %{islinux}
 install -d -m 0755 ${RPM_BUILD_ROOT}%{_init_dir}
 %endif
-DESTDIR=${RPM_BUILD_ROOT} %{_make} install install-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 templated configuration files
-#cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}/nrpe.cfg
-#%if %{isaix}
-#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}
+DESTDIR=${RPM_BUILD_ROOT} %{_make} install-groups-users install install-config install-init
+
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -212,20 +156,22 @@ rm -rf $RPM_BUILD_ROOT
 %files
 %if %{islinux}
 %defattr(755,root,root)
-/etc/init.d/nrpe
+@initdir@/@initname@
 %endif
 %{_bindir}/nrpe
 %dir %{_sysconfdir}
 %defattr(600,%{nsusr},%{nsgrp})
 %config(noreplace) %{_sysconfdir}/*.cfg
 %defattr(755,%{nsusr},%{nsgrp})
+@tmpfilesd@
+%{_bindir}/nrpe-uninstall
 %doc Changelog LEGAL README.md README.SSL.md SECURITY.md
 
 %files plugin
 %defattr(755,%{nsusr},%{nsgrp})
 %{_libexecdir}
 %defattr(644,%{nsusr},%{nsgrp})
-%doc Changelog LEGAL README 
+%doc Changelog LEGAL README.md
 
 %changelog
 * Thu Aug 18 2016 John Frickson jfrickson<@>nagios.com

+ 14 - 25
src/Makefile.in

@@ -10,6 +10,9 @@ srcdir=@srcdir@
 SRC_INCLUDE=@srcdir@/../include
 CFG_INCLUDE=../include
 
+# Mainly used for rpmbuild
+# DESTDIR=
+
 CC=@CC@
 CFLAGS=@CFLAGS@ @DEFS@ -I $(CFG_INCLUDE) -I $(SRC_INCLUDE)
 LDFLAGS=@LDFLAGS@ @LIBS@
@@ -19,37 +22,21 @@ OTHERLIBS=@OTHERLIBS@
 
 CP=@CP@
 
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-CFGDIR=@pkgsysconfdir@
-BINDIR=@bindir@
-SBINDIR=@sbindir@
-LIBEXECDIR=@libexecdir@
+prefix=$(DESTDIR)@prefix@
+exec_prefix=$(DESTDIR)@exec_prefix@
+CFGDIR=$(DESTDIR)@pkgsysconfdir@
+BINDIR=$(DESTDIR)@bindir@
+SBINDIR=$(DESTDIR)@sbindir@
+LIBEXECDIR=$(DESTDIR)@libexecdir@
 INSTALL=@INSTALL@
 NAGIOS_INSTALL_OPTS=@NAGIOS_INSTALL_OPTS@
 NRPE_INSTALL_OPTS=@NRPE_INSTALL_OPTS@
 
-PLUGINSDIR=@pluginsdir@
-PIDDIR=@piddir@
-TMPFILESDIR=@tmpfilesd@
+PLUGINSDIR=$(DESTDIR)@pluginsdir@
+PIDDIR=$(DESTDIR)@piddir@
+TMPFILESDIR=$(DESTDIR)@tmpfilesd@
 SRC_TMPFILE=@src_tmpfile@
 
-#AC_SUBST(pkgsysconfdir)
-#AC_SUBST(objsysconfdir)
-#AC_SUBST(sbindir)
-#AC_SUBST(brokersdir)
-#AC_SUBST(cgibindir)
-#AC_SUBST(webdir)
-#AC_SUBST(privatesysconfdir)
-#AC_SUBST(pkglocalstatedir)
-#AC_SUBST(logdir)
-#AC_SUBST(pipedir)
-#AC_SUBST(spooldir)
-#AC_SUBST(tmpfilesd)
-#AC_SUBST(subsyslockdir)
-#AC_SUBST(subsyslockfile)
-
-
 
 # Generated automatically from configure script
 SNPRINTF_O=@SNPRINTF_O@
@@ -79,6 +66,8 @@ install-daemon: install-uninstall
 		$(INSTALL) -m 755 $(NRPE_INSTALL_OPTS) -d $(PIDDIR); \
 	fi
 	@if test "$(TMPFILESDIR)" != "N/A" -a x$(SRC_TMPFILE) != x ; then \
+		echo $(INSTALL) -m 755 -d `dirname $(TMPFILESDIR)`; \
+		$(INSTALL) -m 755 -d `dirname $(TMPFILESDIR)`; \
 		echo $(INSTALL) -m 644 ../startup/$(SRC_TMPFILE) $(TMPFILESDIR); \
 		$(INSTALL) -m 644 ../startup/$(SRC_TMPFILE) $(TMPFILESDIR); \
 	fi