Source-Changes-HG archive

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

[src/netbsd-1-6]: src/usr.sbin/etcupdate Pullup revisions 1.8-1.9 (requested ...



details:   https://anonhg.NetBSD.org/src/rev/d333e9246416
branches:  netbsd-1-6
changeset: 529975:d333e9246416
user:      jmc <jmc%NetBSD.org@localhost>
date:      Mon Jan 27 06:44:39 2003 +0000

description:
Pullup revisions 1.8-1.9 (requested by martti in ticket #1116)
 Add a new -a flag (automatically update files which have not been
locally modified).

diffstat:

 usr.sbin/etcupdate/etcupdate |  34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diffs (91 lines):

diff -r 908525399b99 -r d333e9246416 usr.sbin/etcupdate/etcupdate
--- a/usr.sbin/etcupdate/etcupdate      Mon Jan 27 06:39:02 2003 +0000
+++ b/usr.sbin/etcupdate/etcupdate      Mon Jan 27 06:44:39 2003 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: etcupdate,v 1.3.2.4 2003/01/05 08:29:42 jmc Exp $
+# $NetBSD: etcupdate,v 1.3.2.5 2003/01/27 06:44:39 jmc 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}"



Home | Main Index | Thread Index | Old Index