[Pkg-nagios-changes] [pkg-nagios] r1070 - nagios-plugins/trunk/debian

Sean Finney seanius at alioth.debian.org
Wed Dec 6 18:35:02 CET 2006


Author: seanius
Date: 2006-12-06 18:35:02 +0100 (Wed, 06 Dec 2006)
New Revision: 1070

Modified:
   nagios-plugins/trunk/debian/functions
   nagios-plugins/trunk/debian/rules
Log:
a little more work for sarge transitioning

Modified: nagios-plugins/trunk/debian/functions
===================================================================
--- nagios-plugins/trunk/debian/functions	2006-12-06 10:40:03 UTC (rev 1069)
+++ nagios-plugins/trunk/debian/functions	2006-12-06 17:35:02 UTC (rev 1070)
@@ -1,26 +1,31 @@
 # functions for use by nagios plugins maintainer scripts
 
-# called as "register_cfgs $2" from postinst
+npconfdir=/etc/nagios-plugins/config
+npdpkgdir=/usr/share/nagios-plugins/dpkg
+
+# determine whether the file is the default file shipped in sarge
+# (called as is_pristine_sarge_file foo.cfg)
+is_pristine_sarge_file(){
+	sargemd5=`grep "${npconfdir}/$1" ${npdpkgdir}/sarge.md5sums | cut -d' ' -f1`
+	curmd5=`md5sum "${npconfdir}/$1" | cut -d' ' -f1`
+	if [ "$curmd5" = "$sargemd5" ]; then return 0; else return 1; fi
+}
+
+# we now register all n-p config files via ucf.  this means
+# we have to do a little bit of hand-holding for sarge migrations...
+# (called as "register_cfgs $2" from postinst)
 register_cfgs(){
 	local newinst
 	if [ -z "$1" ]; then
-		newinst="yes"
-		tmpfile=`mktemp -t nagios-plugins.XXXXXX`
-		if [ ! -f "$tmpfile" ]; then 
-			echo "error creating tempfile >&2"
-			exit 1
-		fi
+		( 
+			cd $templdir
+			for f in *cfg; do
+				dest=${npconfdir}/$f
+				if is_pristine_sarge_file $f; then
+					cp $f $dest
+				fi
+				ucf $f $dest
+			done 
+		);
 	fi
-	( 
-		cd $templdir
-		for f in *cfg; do
-			dest=/etc/nagios-plugins/config/$f
-			if [ "$newinst" = "yes" ] && [ -f $dest ]; then
-				cat $dest > $tmpfile
-				ucf $tmpfile $dest
-			fi
-			ucf $f /etc/nagios-plugins/config/$f 
-		done 
-	);
-	if [ "$newinst" = "yes" ]; then rm -f $tmpfile; fi
 }

Modified: nagios-plugins/trunk/debian/rules
===================================================================
--- nagios-plugins/trunk/debian/rules	2006-12-06 10:40:03 UTC (rev 1069)
+++ nagios-plugins/trunk/debian/rules	2006-12-06 17:35:02 UTC (rev 1070)
@@ -17,10 +17,11 @@
 
 CFLAGS = -Wall -g
 
+DEBIANDIR=$(CURDIR)/debian
 NP_LIBEXEC:=/usr/lib/nagios/plugins
-NP_BASIC_DIR:=$(CURDIR)/debian/nagios-plugins-basic
+NP_BASIC_DIR:=$(DEBIANDIR)/nagios-plugins-basic
 NP_BASIC_TEMPLATES:=$(NP_BASIC_DIR)/usr/share/nagios-plugins/templates-basic
-NP_STD_DIR:=$(CURDIR)/debian/nagios-plugins-standard
+NP_STD_DIR:=$(DEBIANDIR)/nagios-plugins-standard
 NP_STD_TEMPLATES:=$(NP_STD_DIR)/usr/share/nagios-plugins/templates-standard
 
 std_plugins:=check_breeze check_ifoperstatus check_hpjd check_ifstatus \
@@ -118,7 +119,7 @@
 	-rm -f platform.h auto-include.h
 	find -type d -name build -print0 | xargs -0 -r rm -rf \;
 	find \( -name config.sub -o -name config.guess \) -print0 | xargs -0 -r rm -f \;
-	-rm -f debian/nagios-plugins-basic.postrm debian/nagios-plugins-standard.postrm
+	-rm -f $(DEBIANDIR)/nagios-plugins-basic.postrm $(DEBIANDIR)/nagios-plugins-standard.postrm
 	dh_clean 
 
 install: build
@@ -137,21 +138,21 @@
 	# now do the same for their configs, copying them into seperate
 	# "template" directories outside of /usr/share/doc for ucf to use.
 	for c in ${basic_plugin_cfgs}; do \
-		cp $(CURDIR)/debian/pluginconfig/$${c}.cfg ${NP_BASIC_TEMPLATES}; \
+		cp $(DEBIANDIR)/pluginconfig/$${c}.cfg ${NP_BASIC_TEMPLATES}; \
 	done
 	for c in ${std_plugin_cfgs}; do \
-		cp $(CURDIR)/debian/pluginconfig/$${c}.cfg ${NP_STD_TEMPLATES}; \
+		cp $(DEBIANDIR)/pluginconfig/$${c}.cfg ${NP_STD_TEMPLATES}; \
 	done
 	# dynamically create the postrm scripts using a template, so that we
 	# don't have to define the same list of plugin configs over and over.
 	sed -e 's/@BASIC_PLUGINS@/${basic_plugin_cfgs}/' \
-		< debian/nagios-plugins-basic.postrm.in \
-		> debian/nagios-plugins-basic.postrm
+		< $(DEBIANDIR)/nagios-plugins-basic.postrm.in \
+		> $(DEBIANDIR)/nagios-plugins-basic.postrm
 	sed -e 's/@STD_PLUGINS@/${std_plugin_cfgs}/' \
-		< debian/nagios-plugins-standard.postrm.in \
-		> debian/nagios-plugins-standard.postrm
+		< $(DEBIANDIR)/nagios-plugins-standard.postrm.in \
+		> $(DEBIANDIR)/nagios-plugins-standard.postrm
 	# copy our dpkg-sourced functions into place
-	install -m 644 -D $(CURDIR)/debian/functions \
+	install -m 644 -D $(DEBIANDIR)/functions $(DEBIANDIR)/sarge.md5sums \
 		${NP_BASIC_DIR}/usr/share/nagios-plugins/dpkg/functions
 
 




More information about the Pkg-nagios-changes mailing list