From nobody@FreeBSD.org  Mon Jul 25 16:26:57 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7FF531065673
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 25 Jul 2011 16:26:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 6F4BA8FC1C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 25 Jul 2011 16:26:57 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6PGQvsk041151
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 25 Jul 2011 16:26:57 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p6PGQvaf041150;
	Mon, 25 Jul 2011 16:26:57 GMT
	(envelope-from nobody)
Message-Id: <201107251626.p6PGQvaf041150@red.freebsd.org>
Date: Mon, 25 Jul 2011 16:26:57 GMT
From: Warren Block <wblock@wonkity.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] sysutils/scanbuttond: protect user config files
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: dthiele@gmx.net

>Number:         159183
>Category:       ports
>Synopsis:       [patch] sysutils/scanbuttond: protect user config files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    zi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 25 16:30:24 UTC 2011
>Closed-Date:    Thu Jul 28 22:22:50 UTC 2011
>Last-Modified:  Thu Jul 28 22:22:50 UTC 2011
>Originator:     Warren Block
>Release:        8-stable
>Organization:
>Environment:
FreeBSD lightning 8.2-STABLE FreeBSD 8.2-STABLE #0: Sun Jul 24 21:33:19 MDT 2011     root@lightning:/usr/obj/usr/src/sys/LIGHTNING  i386
>Description:
Reinstalling or upgrading sysutils/scanbuttond will overwrite user-modified config .sh files in /usr/local/etc/scanbuttond/.

This patch changes the port to work like other ports.  If there are user .sh files present, they are left alone.  If not present, sample files are installed.
The patch is based on sysutils/apcupsd, which seemed to be the right way to do it.


>How-To-Repeat:
Modify /usr/local/etc/scanbuttond/buttonpressed.sh initscanner.sh.
Reinstall the port.  Notice the modified files have been replaced with sample files from the port.
>Fix:
Apply patch.

Patch attached with submission follows:

diff -u sysutils/scanbuttond.orig/Makefile sysutils/scanbuttond/Makefile
--- sysutils/scanbuttond.orig/Makefile	2009-08-21 18:35:27.000000000 -0600
+++ sysutils/scanbuttond/Makefile	2011-07-25 10:24:01.000000000 -0600
@@ -7,6 +7,7 @@
 
 PORTNAME=	scanbuttond
 PORTVERSION=	0.2.3
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	SF
 
@@ -30,7 +31,23 @@
 pre-configure:
 	@${FIND} ${WRKSRC} -name Makefile.in | ${XARGS} \
 		${REINPLACE_CMD} -e 's|-ldl||g'
+
+pre-install:
+	@if [ -f ${WRKSRC}/scripts/buttonpressed.sh ]; then \
+		for na in buttonpressed.sh initscanner.sh; do \
+			${MV} ${WRKSRC}/scripts/$$na ${WRKSRC}/scripts/$$na.sample ; \
+		done; \
+		${REINPLACE_CMD} -e 's|\.sh|.sh.sample|g' ${WRKSRC}/scripts/Makefile ; \
+		${MV} ${WRKSRC}/backends/meta.conf ${WRKSRC}/backends/meta.conf.sample ; \
+		${REINPLACE_CMD} -e 's|meta\.conf|meta.conf.sample|g' ${WRKSRC}/backends/Makefile ; \
+	fi
+
 post-install:
+	@for na in buttonpressed.sh initscanner.sh meta.conf; do \
+		if [ ! -f ${ETCDIR}/$$na ]; then \
+			${CP} -p ${ETCDIR}/$$na.sample ${ETCDIR}/$$na; \
+		fi; \
+	done
 	@${CAT} ${PKGMESSAGE}
 
 .include <bsd.port.post.mk>
Common subdirectories: sysutils/scanbuttond.orig/files and sysutils/scanbuttond/files
diff -u sysutils/scanbuttond.orig/pkg-plist sysutils/scanbuttond/pkg-plist
--- sysutils/scanbuttond.orig/pkg-plist	2006-06-06 12:06:49.000000000 -0600
+++ sysutils/scanbuttond/pkg-plist	2011-07-25 10:23:19.000000000 -0600
@@ -1,7 +1,13 @@
 bin/scanbuttond
-etc/scanbuttond/buttonpressed.sh
-etc/scanbuttond/initscanner.sh
-etc/scanbuttond/meta.conf
+@unexec if cmp -s %D/etc/scanbuttond/buttonpressed.sh.sample %D/etc/scanbuttond/buttonpressed.sh; then rm -f %D/etc/scanbuttond/buttonpressed.sh; fi
+etc/scanbuttond/buttonpressed.sh.sample
+@exec if [ ! -f %D/etc/scanbuttond/buttonpressed.sh ] ; then cp -p %D/%F %B/buttonpressed.sh; fi
+@unexec if cmp -s %D/etc/scanbuttond/initscanner.sh.sample %D/etc/scanbuttond/initscanner.sh; then rm -f %D/etc/scanbuttond/initscanner.sh; fi
+etc/scanbuttond/initscanner.sh.sample
+@exec if [ ! -f %D/etc/scanbuttond/initscanner.sh ] ; then cp -p %D/%F %B/initscanner.sh; fi
+@unexec if cmp -s %D/etc/scanbuttond/meta.conf.sample %D/etc/scanbuttond/meta.conf; then rm -f %D/etc/scanbuttond/meta.conf; fi
+etc/scanbuttond/meta.conf.sample
+@exec if [ ! -f %D/etc/scanbuttond/meta.conf ] ; then cp -p %D/%F %B/meta.conf; fi
 lib/libscanbtnd-backend_epson.la
 lib/libscanbtnd-backend_epson.so
 lib/libscanbtnd-backend_epson.so.1


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Mon Jul 25 16:30:46 UTC 2011 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159183 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: dthiele@gmx.net
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/159183: [patch] sysutils/scanbuttond: protect user config files
Date: Mon, 25 Jul 2011 16:30:42 UT

 Maintainer of sysutils/scanbuttond,
 
 Please note that PR ports/159183 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/159183
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Daniel Thiele <dthiele@gmx.net>
To: bug-followup@FreeBSD.org
Cc: Warren Block <wblock@wonkity.com>
Subject: Re: ports/159183: [patch] sysutils/scanbuttond: protect user config
 files
Date: Mon, 25 Jul 2011 23:17:58 +0200

 On 07/25/11 18:30, Edwin Groothuis wrote:
 > Maintainer of sysutils/scanbuttond,
 > 
 > Please note that PR ports/159183 has just been submitted.
 > 
 > If it contains a patch for an upgrade, an enhancement or a bug fix
 > you agree on, reply to this email stating that you approve the patch
 > and a committer will take care of it.
 > 
 > The full text of the PR can be found at:
 >     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/159183
 > 
 
 The patch looks good. I approve it. Thanks!
State-Changed-From-To: feedback->open 
State-Changed-By: linimon 
State-Changed-When: Mon Jul 25 22:40:36 UTC 2011 
State-Changed-Why:  
Maintainer approved. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159183 
Responsible-Changed-From-To: freebsd-ports-bugs->zi 
Responsible-Changed-By: zi 
Responsible-Changed-When: Tue Jul 26 22:33:11 UTC 2011 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159183 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/159183: commit references a PR
Date: Thu, 28 Jul 2011 21:56:30 +0000 (UTC)

 zi          2011-07-28 21:56:21 UTC
 
   FreeBSD ports repository
 
   Modified files:
     sysutils/scanbuttond Makefile pkg-plist 
   Log:
   Do not overwrite user-edited config files in ETCDIR [1]
   Bump PORTREVISION
   Add LICENSE
   
   PR:             ports/159183
   Submitted by:   Warren Block <wblock@wonkity.com> [1]
   Approvd by:     tabthorpe (mentor), maintainer
   
   Revision  Changes    Path
   1.11      +21 -2     ports/sysutils/scanbuttond/Makefile
   1.2       +9 -3      ports/sysutils/scanbuttond/pkg-plist
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: zi 
State-Changed-When: Thu Jul 28 22:22:49 UTC 2011 
State-Changed-Why:  
Committed, with minor changes. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159183 
>Unformatted:
