Bug 67251

Summary: Upgrade of sysutils/apcupsd stomps on pre-exisiting config file
Product: Ports & Packages Reporter: Rob <robbyrnes>
Component: Individual Port(s)Assignee: Edwin Groothuis <edwin>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Rob 2004-05-27 13:20:15 UTC
This system has apcupsd-3.10.11 installed from ports and a custom config was
+made and placed in /usr/local/etc/apcupsd/apcupsd.conf.  When this port was
+upgraded via the portupgrade tool, the upgrade deleted the custom apcupsd.conf
+and installed the generic config distributed with the application

How-To-Repeat:         portupgrade apcupsd
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2004-05-27 13:26:28 UTC
State Changed
From-To: open->feedback




Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2004-05-27 13:26:28 UTC
Responsible Changed
From-To: freebsd-ports-bugs->edwin

I've played with it in the last couple of days. Let me have a good look at.
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2004-05-30 11:07:44 UTC
Lars,

Please approve attached patch for
http://www.freebsd.org/cgi/query-pr.cgi?pr=67251

Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/sysutils/apcupsd/Makefile,v
retrieving revision 1.30
diff -u -r1.30 Makefile
--- Makefile	11 May 2004 17:02:45 -0000	1.30
+++ Makefile	30 May 2004 10:05:57 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	apcupsd
 PORTVERSION=	3.10.13
-#PORTREVISION=	1
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	${PORTNAME}
@@ -34,13 +34,13 @@
 .include <bsd.port.pre.mk>
 
 # We need this below
-CONF_FILES=apcupsd.conf
+CONF_FILES=apcupsd.conf-sample
 
 .if defined(WITH_CGI)
 CONFIGURE_ARGS+=--enable-cgi --with-cgi-bin=${PREFIX}/etc/apcupsd/cgi
 LIB_DEPENDS+=	gd.4:${PORTSDIR}/graphics/gd
 PLIST_SUB+=	CGI=""
-CONF_FILES+=	multimon.conf hosts.conf
+CONF_FILES+=	multimon.conf-sample hosts.conf-sample
 .else
 PLIST_SUB+=	CGI="@comment "
 .endif
@@ -89,17 +89,6 @@
 	${REINPLACE_CMD} -e "s|%PREFIX%|${PREFIX}|g" ${WRKSRC}/doc/apcupsd.man
 
 post-install:
-	# Check if the install presaves the configuration files
-	for na in ${CONF_FILES}; do \
-		if [ -f ${PREFIX}/etc/apcupsd/$$na.new ]; then \
-			${ECHO_CMD} "etc/apcupsd/$$na.new" >> ${TMPPLIST}; \
-			if cmp -s ${PREFIX}/etc/apcupsd/$$na.new ${PREFIX}/etc/apcupsd/$$na; then \
-				${ECHO_CMD} "etc/apcupsd/$$na" >> ${TMPPLIST}; \
-			fi \
-		else \
-			${ECHO_CMD} "etc/apcupsd/$$na" >> ${TMPPLIST}; \
-		fi; \
-	done
 	# If the files presaved are identical with the new one, include then in
 	# the package list. So the port could be removed without problems
 	for na in apccontrol commfailure mainsback mastertimeout \
@@ -110,7 +99,6 @@
 			fi \
 		fi; \
 	done
-	${ECHO_CMD} "@dirrm etc/apcupsd" >> ${TMPPLIST}
 	${ECHO_CMD} "@unexec if [ -d %D/etc/apcupsd ]; then echo \"If you are permanently removing this port, you should do a ``rm -rf ${PREFIX}/etc/apcupsd`` to remove config files left.\" | fmt ; fi" >> ${TMPPLIST}
 	# Install sample startup script
 	${INSTALL_SCRIPT} ${FILESDIR}/${STARTUP_SCRIPT} ${PREFIX}/etc/rc.d/${STARTUP_SCRIPT}
Index: pkg-plist
===================================================================
RCS file: /home/pcvs/ports/sysutils/apcupsd/pkg-plist,v
retrieving revision 1.11
diff -u -r1.11 pkg-plist
--- pkg-plist	11 May 2004 17:02:45 -0000	1.11
+++ pkg-plist	30 May 2004 10:05:57 -0000
@@ -13,10 +13,14 @@
 etc/apcupsd/masterconnect
 etc/apcupsd/mastertimeout
 etc/apcupsd/onbattery
+etc/apcupsd/apcupsd.conf-sample
 %%CGI%%etc/apcupsd/cgi/apcupsd.css
 %%CGI%%etc/apcupsd/cgi/multimon.cgi
 %%CGI%%etc/apcupsd/cgi/upsfstats.cgi
 %%CGI%%etc/apcupsd/cgi/upsimage.cgi
 %%CGI%%etc/apcupsd/cgi/upsstats.cgi
+%%CGI%%etc/apcupsd/hosts.conf-sample
+%%CGI%%etc/apcupsd/multimon.conf-sample
 etc/rc.d/%%STARTUP_SCRIPT%%
 %%CGI%%@dirrm etc/apcupsd/cgi
+@unexec rmdir %D/etc/apcupsd 2>/dev/null || /usr/bin/true
Index: files/patch-platforms::etc::Makefile.in
===================================================================
RCS file: files/patch-platforms::etc::Makefile.in
diff -N files/patch-platforms::etc::Makefile.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-platforms::etc::Makefile.in	30 May 2004 10:05:57 -0000
@@ -0,0 +1,16 @@
+--- platforms/etc/Makefile.in.orig	Sun May 30 16:54:43 2004
++++ platforms/etc/Makefile.in	Sun May 30 16:55:48 2004
+@@ -20,12 +20,7 @@
+ install:
+ 	@echo "Installing apcupsd.conf..."; \
+ 	srcconf=$(topdir)/platforms/etc/apcupsd.conf; \
+-	if test -f $(DESTDIR)$(sysconfdir)/apcupsd.conf; then \
+-	  dstconf=apcupsd.conf.new; \
+-	  echo " Found old apcupsd.conf, installing new file as $$dstconf"; \
+-	else \
+-	  dstconf=apcupsd.conf; \
+-	fi; \
++	dstconf=apcupsd.conf-sample; \
+ 	$(INSTALL_DATA) $$srcconf $(DESTDIR)$(sysconfdir)/$$dstconf; \
+ 	for src in changeme commfailure commok masterconnect \
+ 		mastertimeout mainsback onbattery; do \
Index: files/patch-src::cgi::Makefile.in
===================================================================
RCS file: files/patch-src::cgi::Makefile.in
diff -N files/patch-src::cgi::Makefile.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-src::cgi::Makefile.in	30 May 2004 10:05:57 -0000
@@ -0,0 +1,36 @@
+--- src/cgi/Makefile.in.orig	Sun May 30 16:57:05 2004
++++ src/cgi/Makefile.in	Sun May 30 16:57:47 2004
+@@ -60,29 +60,15 @@
+ 	$(INSTALL_DATA) apcupsd.css $(DESTDIR)$(cgibin)
+ 
+ 	# don't overwrite any existing config file
+-	@if test ! -f $(DESTDIR)$(sysconfdir)/hosts.conf; then \
+-	   (echo "Installing hosts.conf..." && \
++	(echo "Installing hosts.conf..." && \
+ 	      $(INSTALL_DATA) \
+ 		 $(topdir)/platforms/etc/hosts.conf \
+-		 $(DESTDIR)$(sysconfdir)/hosts.conf); \
+-	else \
+-	    (echo "Installing hosts.conf as $(DESTDIR)$(sysconfdir)/hosts.conf.new" && \
+-	       $(INSTALL_DATA) \
+-		  $(topdir)/platforms/etc/hosts.conf \
+-		  $(DESTDIR)$(sysconfdir)/hosts.conf.new); \
+-	fi
++		 $(DESTDIR)$(sysconfdir)/hosts.conf-sample); \
+ 	# don't overwrite any existing config file
+-	@if test ! -f $(DESTDIR)$(sysconfdir)/multimon.conf; then \
+-	   (echo "Installing multimon.conf..." && \
+-	       $(INSTALL_DATA) \
+-		  $(topdir)/platforms/etc/multimon.conf \
+-		  $(DESTDIR)$(sysconfdir)/multimon.conf ); \
+-	else \
+-	   (echo "Installing multimon.conf as $(DESTDIR)$(sysconfdir)/multimon.conf.new" && \
++	(echo "Installing multimon.conf..." && \
+ 	       $(INSTALL_DATA) \
+ 		  $(topdir)/platforms/etc/multimon.conf \
+-		  $(DESTDIR)$(sysconfdir)/multimon.conf.new); \
+-	fi
++		  $(DESTDIR)$(sysconfdir)/multimon.conf-sample ); \
+ 
+ uninstall:
+ 	@echo "Uninstalling cgi program support..."
Comment 4 lkoeller freebsd_committer freebsd_triage 2004-10-14 20:28:59 UTC
State Changed
From-To: feedback->closed

o) Port update with fix just commited.