Subject: bin/20200: Let etcupdate skip files with strictly local modifications (patch)
To: None <gnats-bugs@gnats.netbsd.org>
From: Christopher Richards <richards+netbsd@CS.Princeton.EDU>
List: netbsd-bugs
Date: 02/04/2003 05:05:27
>Number:         20200
>Category:       bin
>Synopsis:       Let etcupdate skip files with strictly local modifications (patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 04 02:06:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Christopher Richards
>Release:        NetBSD 1.6_STABLE
>Organization:
 
>Environment:
	
	
System: NetBSD zembla.Princeton.EDU 1.6_STABLE NetBSD 1.6_STABLE (ZEMBLA) #46: Thu Jan 30 01:03:21 EST 2003 richards@zembla.Princeton.EDU:/home/richards/z/src/kern i386
Architecture: i386
Machine: i386
>Description:
	This patch adds an "-l" option to let etcupdate skip over files
	whose modifications are strictly local.  ("No, 1000 times no,
	I do NOT want the default, crippled rc.conf.")  The "-l" flag
	makes its determination using the RCS IDs distributed with
	the system files, so files lacking these IDs are never skipped
	as a result of using this flag.
	
>How-To-Repeat:
	
>Fix:
	
	Patch is relative to 1.6_STABLE but should apply to -current.

Index: usr.sbin/etcupdate/etcupdate
===================================================================
RCS file: /cvsroot/src/usr.sbin/etcupdate/etcupdate,v
retrieving revision 1.3.2.5
diff -u -b -r1.3.2.5 etcupdate
--- usr.sbin/etcupdate/etcupdate	2003/01/27 06:44:39	1.3.2.5
+++ usr.sbin/etcupdate/etcupdate	2003/02/04 09:59:59
@@ -60,6 +60,7 @@
 CONTINUE=
 BINARY=
 AUTOMATIC=
+LOCALSKIP=
 
 # Settings for post-installation procedures
 NEED_MTREE=
@@ -81,6 +82,8 @@
   -w width     Screen width                    (default: 80)
 
   -a           Automatically update unmodified files
+  -l           Automatically skip files with strictly local changes
+               (this option has no effect on files lacking RCS Ids)
   -h           This help text
   -v           Be more verbose
 
@@ -173,6 +176,18 @@
 		fi
 	fi
 
+	if [ "${LOCALSKIP}" = "YES" ] ; then
+		ID1=`ident -q "${TEMPROOT}${1}" | sed -n 2p`
+		ID1="${ID1:-0}"
+		ID2=`ident -q "${1}" | sed -n 2p`
+		ID2="${ID2:-1}"
+		if [ "${ID1}" = "${ID2}" ] ; then
+			verbose "===> ${1} (ok:RCS)"
+			rm -f "${TEMPROOT}${1}"
+			return
+		fi
+	fi
+
 	clear
 	if [ ! -f "${1}" ]; then
 		verbose "===> ${1} (missing)"
@@ -300,7 +315,7 @@
 [ -r ${USERRC} ] && . ${USERRC}
 
 # Read command line arguments
-ARGV=`getopt ab:hp:s:t:vw: $*`
+ARGV=`getopt ab:hlp:s:t:vw: $*`
 [ $? != 0 ] && usage
 set -- ${ARGV}
 for i; do
@@ -316,6 +331,10 @@
 		;;
 	-h)
 		usage
+		;;
+	-l)
+		LOCALSKIP=YES
+		shift
 		;;
 	-p)
 		PAGER="${2}"
Index: usr.sbin/etcupdate/etcupdate.8
===================================================================
RCS file: /cvsroot/src/usr.sbin/etcupdate/etcupdate.8,v
retrieving revision 1.1.2.1
diff -u -b -r1.1.2.1 etcupdate.8
--- usr.sbin/etcupdate/etcupdate.8	2003/01/27 06:44:52	1.1.2.1
+++ usr.sbin/etcupdate/etcupdate.8	2003/02/04 10:00:00
@@ -46,6 +46,7 @@
 .Op Fl a
 .Op Fl b Ar srcdir
 .Op Fl h
+.Op Fl l
 .Op Fl p Ar pager
 .Op Fl s Ar srcdir
 .Op Fl t Ar temproot
@@ -114,6 +115,18 @@
 .Pa /etc/etcupdate
 and use these checksums to determine if there have been any
 local modifications.
+.Pp
+Inversely, if given the
+.Fl l
+flag,
+.Nm
+will automatically skip files which have been modified strictly
+locally.
+(As an exception, files distributed without RCS IDs will not be
+skipped, since the logic for this flag requires their presence.)
+This flag may be used together with the
+.Fl a
+flag described above.
 .Sh ENVIRONMENT
 .Bl -tag -width TEMPROOT
 .It Ev TEMPROOT
>Release-Note:
>Audit-Trail:
>Unformatted: