Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/etcupdate Add a new -a flag (automatically update f...



details:   https://anonhg.NetBSD.org/src/rev/540f768a0e06
branches:  trunk
changeset: 542251:540f768a0e06
user:      martti <martti%NetBSD.org@localhost>
date:      Fri Jan 24 13:06:06 2003 +0000

description:
Add a new -a flag (automatically update files which have not been
locally modified). Patch provided by Sverre Froyen in a private mail,
slightly modified by me.

diffstat:

 usr.sbin/etcupdate/etcupdate   |  34 ++++++++++++++++++++++++++++++++--
 usr.sbin/etcupdate/etcupdate.8 |  23 +++++++++++++++++++++--
 2 files changed, 53 insertions(+), 4 deletions(-)

diffs (149 lines):

diff -r f15ebd337402 -r 540f768a0e06 usr.sbin/etcupdate/etcupdate
--- a/usr.sbin/etcupdate/etcupdate      Fri Jan 24 12:06:21 2003 +0000
+++ b/usr.sbin/etcupdate/etcupdate      Fri Jan 24 13:06:06 2003 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: etcupdate,v 1.8 2002/12/27 19:47:43 jmmv Exp $
+# $NetBSD: etcupdate,v 1.9 2003/01/24 13:06:06 martti Exp $
 #
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -59,6 +59,7 @@
 VERBOSE=
 CONTINUE=
 BINARY=
+AUTOMATIC=
 
 # Settings for post-installation procedures
 NEED_MTREE=
@@ -79,6 +80,7 @@
   -t temproot  Where to store temporary files  (default: /tmp/temproot)
   -w width     Screen width                    (default: 80)
 
+  -a           Automatically update unmodified files
   -h           This help text
   -v           Be more verbose
 
@@ -141,15 +143,36 @@
        esac
 }
 
+install_checksum() {
+       # $1 = target file
+
+       [ "${AUTOMATIC}" != "YES" ] && return
+
+       D=`dirname "${1}"`
+       mkdir -p "/etc/etcupdate/${D}"
+       md5 "${1}" > "/etc/etcupdate/${1}"
+}
+
 diff_and_merge_file() {
        # $1 = target file
 
        if cmp -s "${TEMPROOT}${1}" "${1}"; then
                verbose "===> ${1} (ok)"
                rm -f "${TEMPROOT}${1}"
+               install_checksum "${1}"
                return
        fi
 
+       if [ "${AUTOMATIC}" = "YES" -a -f "/etc/etcupdate/${1}"  ] ; then
+               SUM1=`sum "${1}"`
+               SUM2=`cat "/etc/etcupdate/${1}"`
+               if [ "${SUM1}" = "${SUM2}" ] ; then
+                       install_file "${1}"
+                       install_checksum "${1}"
+                       return
+               fi
+       fi
+
        clear
        if [ ! -f "${1}" ]; then
                verbose "===> ${1} (missing)"
@@ -223,6 +246,9 @@
                        ;;
                [iI])
                        install_file "${1}"
+                       if [ -z "${ALREADY_MERGED}" ]; then
+                               install_checksum "${1}"
+                       fi
                        STAY_HERE=NO
                        ;;
                [mM])
@@ -274,11 +300,15 @@
 [ -r ${USERRC} ] && . ${USERRC}
 
 # Read command line arguments
-ARGV=`getopt b:hp:s:t:vw: $*`
+ARGV=`getopt ab:hp:s:t:vw: $*`
 [ $? != 0 ] && usage
 set -- ${ARGV}
 for i; do
        case "${i}" in
+       -a)
+               AUTOMATIC=YES
+               shift
+               ;;
        -b)
                BINARY=YES
                SRCDIR="${2}"
diff -r f15ebd337402 -r 540f768a0e06 usr.sbin/etcupdate/etcupdate.8
--- a/usr.sbin/etcupdate/etcupdate.8    Fri Jan 24 12:06:21 2003 +0000
+++ b/usr.sbin/etcupdate/etcupdate.8    Fri Jan 24 13:06:06 2003 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: etcupdate.8,v 1.1 2002/03/22 10:10:57 martti Exp $
+.\"    $NetBSD: etcupdate.8,v 1.2 2003/01/24 13:06:06 martti Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -34,7 +34,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 22, 2002
+.Dd January 24, 2003
 .Dt ETCUPDATE 8
 .Os
 .Sh NAME
@@ -43,6 +43,7 @@
 .Pa /etc
 .Sh SYNOPSIS
 .Nm
+.Op Fl a
 .Op Fl b Ar srcdir
 .Op Fl h
 .Op Fl p Ar pager
@@ -102,6 +103,17 @@
 from the
 .Xr aliases 5
 file.
+.Pp
+.Nm
+can automatically update files which have not been modified locally.
+The
+.Fl a
+flag instructs
+.Nm
+to store MD5 checksums in
+.Pa /etc/etcupdate
+and use these checksums to determine if there has been any
+local modifications.
 .Sh ENVIRONMENT
 .Bl -tag -width TEMPROOT
 .It Ev TEMPROOT
@@ -181,6 +193,13 @@
 .Dl tar xpzf /some/where/etc.tgz
 .Dl etcupdate -b /tmp/temproot
 .Pp
+You have modified only few files in the
+.Pa /etc
+directory so you would like install most of the updates without being asked.
+To automatically update the unmodified configuration files:
+.Pp
+.Dl etcupdate -a
+.Pp
 To get a better idea what's going on, use the
 .Fl v
 flag:



Home | Main Index | Thread Index | Old Index