Source-Changes-HG archive

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

[src/netbsd-3-0]: src/usr.sbin/etcupdate Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/a3fe9c7446d2
branches:  netbsd-3-0
changeset: 579373:a3fe9c7446d2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Fri Jan 19 21:41:32 2007 +0000

description:
Pull up following revision(s) (requested by martti in ticket #1630):
        usr.sbin/etcupdate/etcupdate: revision 1.23 - 1.30
        usr.sbin/etcupdate/etcupdate.8: revision 1.11 - 1.12

sync etcupdate with HEAD. Fix install/30385 and bin/32343.

diffstat:

 usr.sbin/etcupdate/etcupdate   |  317 ++++++++++++++++++++++++++++++----------
 usr.sbin/etcupdate/etcupdate.8 |  116 +++++++++++---
 2 files changed, 321 insertions(+), 112 deletions(-)

diffs (truncated from 817 to 300 lines):

diff -r 37a0d69fbcc3 -r a3fe9c7446d2 usr.sbin/etcupdate/etcupdate
--- a/usr.sbin/etcupdate/etcupdate      Tue Jan 16 08:51:43 2007 +0000
+++ b/usr.sbin/etcupdate/etcupdate      Fri Jan 19 21:41:32 2007 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: etcupdate,v 1.21.6.1 2005/04/20 11:40:07 tron Exp $
+# $NetBSD: etcupdate,v 1.21.6.1.2.1 2007/01/19 21:41:32 bouyer Exp $
 #
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -53,39 +53,51 @@
 
 # Default settings
 TEMPROOT="${TEMPROOT:=/tmp/temproot}"
-SRCDIR="${SRCDIR:=/usr/src/etc}"
 PAGER="${PAGER:=/usr/bin/more}"
-SWIDTH=`stty -a | awk '/columns/{w=$6}END{if(w==0){w=80}print w}'`
+SWIDTH=`stty size | awk '{w=$2}END{if(w==0){w=80}print w}'`
 WIDTH="${WIDTH:=${SWIDTH}}"
-VERBOSE=
-CONTINUE=
-BINARY=
-AUTOMATIC=
-LOCALSKIP=
+DIFF_COMMAND="diff -u"
+VERBOSE=false
+CONTINUE=false
+SOURCEMODE=false       # true for "-s source_dir"
+SRCDIR=                        # directory for SOURCEMODE
+BINARYMODE=false       # true for both BINARYDIRMODE and BINARYTGZMODE
+BINARYDIRMODE=false    # true for "-s extracted_dir"
+BINARYDIR=             # directory name for BINARYDIRMODE
+BINARYTGZMODE=false    # true for "-s etc.tgz"
+TGZLIST=               # colon-separated list for BINARYTGZMODE
+AUTOMATIC=false
+LOCALSKIP=false
 MACHINE="${MACHINE:=`uname -m`}"
 export MACHINE
 MACHINE_ARCH="${MACHINE_ARCH:=`uname -p`}"
 export MACHINE_ARCH
 
 # Settings for post-installation procedures
-NEED_MTREE=
-NEED_MAKEDEV=
-NEED_NEWALIASES=
-NEED_PWD_MKDB=
+NEED_MTREE=false
+NEED_MAKEDEV=false
+NEED_NEWALIASES=false
+NEED_PWD_MKDB=false
+
+myname="${0##*/}"
 
 usage() {
        cat << EOF
 
-Usage: `basename $0` [options]
+Usage: ${myname} [options]
 
 Options:
 
-  -b srcdir    Location of the extracted sets
   -p pager     Which pager to use              (default: /usr/bin/more)
-  -s srcdir    Location of the source files    (default: /usr/src/etc)
+  -s {srcdir|tgzfile|tempdir}                  (default: /usr/src)
+               Location of the source files used to populate the
+               target directory.  This may be any of the following:
+               * A directory that contains a NetBSD source tree;
+               * A distribution set file such as "etc.tgz" or "xetc.tgz";
+               * A temporary directory in which one or both of "etc.tgz"
+                 and "xetc.tgz" have been extracted.
   -t temproot  Where to store temporary files  (default: /tmp/temproot)
   -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)
@@ -99,7 +111,7 @@
 verbose() {
        # $* = message to display if in verbose mode
 
-       [ ! -z "${VERBOSE}" ] && echo ${*}
+       ${VERBOSE} && echo "${*}"
 }
 
 yesno() {
@@ -123,7 +135,7 @@
        if yesno "Create ${1}"; then
                verbose "Creating ${1}"
                mkdir -p "${1}" || exit 1
-               NEED_MTREE=YES
+               NEED_MTREE=true
        fi
 }
 
@@ -137,16 +149,16 @@
        # Check if this was a special file
        case "${1}" in
        /dev/MAKEDEV)
-               NEED_MAKEDEV=YES
+               NEED_MAKEDEV=true
                ;;
        /dev/MAKEDEV.local)
-               NEED_MAKEDEV=YES
+               NEED_MAKEDEV=true
                ;;
        /etc/mail/aliases)
-               NEED_NEWALIASES=YES
+               NEED_NEWALIASES=true
                ;;
        /etc/master.passwd)
-               NEED_PWD_MKDB=YES
+               NEED_PWD_MKDB=true
                ;;
        esac
 }
@@ -154,13 +166,40 @@
 install_checksum() {
        # $1 = target file
 
-       [ "${AUTOMATIC}" != "YES" ] && return
+       ${AUTOMATIC} || return
 
        D=`dirname "${1}"`
        mkdir -p "/var/etcupdate/${D}"
        md5 "${1}" > "/var/etcupdate/${1}"
 }
 
+# Initialise the DIFF_EXTRA_OPTIONS variable.
+init_diff_extra_options() {
+       #
+       # Start with a few options that are always available.
+       #
+       DIFF_EXTRA_OPTIONS=\
+"  su  Show differences in unified format (\"diff -u\")
+  sc  Show differences in context format (\"diff -c\")
+  ss  Show differences side by side (\"sdiff -w${WIDTH}\")"
+       #
+       # wdiff is not part of the base system, but the
+       # user might have installed it from pkgsrc.  It is
+       # useful to show differences on a word by word basis
+       # instead of line by line.  If it is executable
+       # then offer to use it in the menu.
+       #
+       if (wdiff /dev/null /dev/null) >/dev/null 2>&1 ; then
+               DIFF_EXTRA_OPTIONS="${DIFF_EXTRA_OPTIONS}
+  sw  Show differences word by word (\"wdiff -n -l\")"
+       fi
+       #
+       # End with an option to use a user-specified diff-like command.
+       #
+       DIFF_EXTRA_OPTIONS="${DIFF_EXTRA_OPTIONS}
+  scommand Show differences using the specified diff-like command"
+}
+
 diff_and_merge_file() {
        # $1 = target file
 
@@ -171,22 +210,22 @@
                return
        fi
 
-       if [ "${AUTOMATIC}" = "YES" -a -f "/var/etcupdate/${1}"  ] ; then
+       if ${AUTOMATIC} && [ -f "/var/etcupdate/${1}" ]; then
                SUM1=`md5 "${1}"`
                SUM2=`cat "/var/etcupdate/${1}"`
-               if [ "${SUM1}" = "${SUM2}" ] ; then
+               if [ "${SUM1}" = "${SUM2}" ]; then
                        install_file "${1}"
                        install_checksum "${1}"
                        return
                fi
        fi
 
-       if [ "${LOCALSKIP}" = "YES" ] ; then
+       if ${LOCALSKIP}; 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
+               if [ "${ID1}" = "${ID2}" ]; then
                        verbose "===> ${1} (ok:RCS)"
                        rm -f "${TEMPROOT}${1}"
                        return
@@ -196,16 +235,16 @@
        clear
        if [ ! -f "${1}" ]; then
                verbose "===> ${1} (missing)"
-               DOES_EXIST=
+               DOES_EXIST=false
        else
                verbose "===> ${1} (modified)"
                verbose ""
-               DOES_EXIST=YES
+               DOES_EXIST=true
                diff -u "${1}" "${TEMPROOT}${1}" | ${PAGER}
        fi
 
-       STAY_HERE=YES
-       ALREADY_MERGED=
+       STAY_HERE=true
+       ALREADY_MERGED=false
 
        # Determine name for the backup file (/foo/._etcupdate.bar)
        D=`dirname  "${TEMPROOT}${1}"`
@@ -213,7 +252,7 @@
        B="${D}/.etcupdate.${F}"
        F="${D}/${F}"
 
-       while [ "x${STAY_HERE}" = "xYES" ]; do
+       while ${STAY_HERE}; do
 
                # Ask the user if (s)he wants to install the new
                # version or perform a more complicated manual work.
@@ -228,29 +267,31 @@
                echo ""
                echo "Please select one of the following operations:"
                echo ""
-               if [ -z "${DOES_EXIST}" ]; then
+               if ! ${DOES_EXIST}; then
                        cat << EOF
   d  Don't install the missing file
   i  Install the missing file
   v  Show the missing file
 
 EOF
-               elif [ -z "${ALREADY_MERGED}" ]; then
+               elif ! ${ALREADY_MERGED}; then
                        cat << EOF
-  d  Don't install the new file
-  i  Install the new file (overwrites your modifications!)
+  d  Don't install the new file (keep your old file)
+  i  Install the new file (overwrites your local modifications!)
   m  Merge the currently installed and new files
   s  Show the differences between the currently installed and new files
+${DIFF_EXTRA_OPTIONS}
   v  Show the new file
 
 EOF
                else
                        cat << EOF
-  d  Don't install the new file
-  i  Install the new file (overwrites your modifications!)
-  m  Merge again the currently installed and new files
-  s  Show the differences between the currently installed and new files
-  u  Undo merge and restore the temporary file from backup
+  d  Don't install the merged file (keep your old file)
+  i  Install the merged file (overwrites your old file)
+  m  Merge again (your old file against the result from the previous merge)
+  s  Show the differences between the currently installed and new merged files
+${DIFF_EXTRA_OPTIONS}
+  u  Undo merge (start again with the original version of the new file)
   v  Show the merged file
 
 EOF
@@ -262,17 +303,17 @@
                [dD])
                        verbose "Removing ${TEMPROOT}${1}"
                        rm -f "${TEMPROOT}${1}"
-                       STAY_HERE=NO
+                       STAY_HERE=false
                        ;;
                [iI])
                        install_file "${1}"
-                       if [ -z "${ALREADY_MERGED}" ]; then
+                       if ! ${ALREADY_MERGED}; then
                                install_checksum "${1}"
                        fi
-                       STAY_HERE=NO
+                       STAY_HERE=false
                        ;;
                [mM])
-                       [ -z "${DOES_EXIST}" ] && continue
+                       ${DOES_EXIST} || continue
                        [ ! -f "${B}" ] && cp "${F}" "${B}"
                        cp "${TEMPROOT}${1}" "${TEMPROOT}${1}.merged"
                        sdiff -o "${TEMPROOT}${1}.merged"       \
@@ -280,24 +321,32 @@
                                --suppress-common-lines --text  \
                                "${1}" "${TEMPROOT}${1}"
                        mv -f "${TEMPROOT}${1}.merged" "${TEMPROOT}${1}"
-                       ALREADY_MERGED=YES
+                       ALREADY_MERGED=true
                        ;;
-               [sS])
-                       [ -z "${DOES_EXIST}" ] && continue
-                       diff -u "${1}" "${TEMPROOT}${1}" | ${PAGER}
+               [sS]*)
+                       ${DOES_EXIST} || continue
+                       case "${ANSWER}" in
+                       [sS])   : no change ;;
+                       [sS]u)  DIFF_COMMAND="diff -u" ;;
+                       [sS]c)  DIFF_COMMAND="diff -c" ;;
+                       [sS]s)  DIFF_COMMAND="sdiff -w${WIDTH}" ;;
+                       [sS]w)  DIFF_COMMAND="wdiff -n -l" ;;
+                       [sS]*)  DIFF_COMMAND="${ANSWER#?}" ;;
+                       esac
+                       ${DIFF_COMMAND} "${1}" "${TEMPROOT}${1}" | ${PAGER}



Home | Main Index | Thread Index | Old Index