Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3]: src/usr.sbin/etcupdate Pull up following revision(s) (request...
details: https://anonhg.NetBSD.org/src/rev/20fd9e72ccf9
branches: netbsd-3
changeset: 577858:20fd9e72ccf9
user: riz <riz%NetBSD.org@localhost>
date: Wed Mar 01 03:53:44 2006 +0000
description:
Pull up following revision(s) (requested by apb in ticket #1184):
usr.sbin/etcupdate/etcupdate: revision 1.23
usr.sbin/etcupdate/etcupdate.8: revision 1.11
Give etcupdate the ability to use etc.tgz and xetc.tgz.
* Expand the "-s" flag to -s {srcdir|tgzfile|tempdir}.
* Deprecate the "-b" flag. It is replaced by "-s tempdir".
* Change "-s srcdir" to refer to the top of the source tree (e.g.
/usr/src) instead of the etc subdirectory.
In etcupdate's interactive phase, enhance the "s" command to be able
to invoke alternative diff commands.
Also some style changes.
Approved by christos
diffstat:
usr.sbin/etcupdate/etcupdate | 234 +++++++++++++++++++++++++++-------------
usr.sbin/etcupdate/etcupdate.8 | 113 +++++++++++++++----
2 files changed, 245 insertions(+), 102 deletions(-)
diffs (truncated from 710 to 300 lines):
diff -r a99426d07c69 -r 20fd9e72ccf9 usr.sbin/etcupdate/etcupdate
--- a/usr.sbin/etcupdate/etcupdate Wed Mar 01 03:49:25 2006 +0000
+++ b/usr.sbin/etcupdate/etcupdate Wed Mar 01 03:53:44 2006 +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.2 2006/03/01 03:53:44 riz 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}'`
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,7 +166,7 @@
install_checksum() {
# $1 = target file
- [ "${AUTOMATIC}" != "YES" ] && return
+ ${AUTOMATIC} || return
D=`dirname "${1}"`
mkdir -p "/var/etcupdate/${D}"
@@ -171,22 +183,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 +208,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 +225,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 +240,35 @@
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
+ sd Show the differences ... using "diff -u"
+ sw Show the differences ... using "wdiff -n -l"
+ scommand Show the differences ... using the specified diff-like command
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
+ 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
+ sd Show the differences ... using "diff -u"
+ sw Show the differences ... using "wdiff -n -l"
+ scommand Show the differences ... using the specified diff-like command
+ u Undo merge and restore the original version of the new file
v Show the merged file
EOF
@@ -262,17 +280,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 +298,30 @@
--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]d) DIFF_COMMAND="diff -u" ;;
+ [sS]w) DIFF_COMMAND="wdiff -n -l" ;;
+ *) DIFF_COMMAND="${ANSWER#?}" ;;
+ esac
+ ${DIFF_COMMAND} "${1}" "${TEMPROOT}${1}" | ${PAGER}
;;
[uU])
if [ -f "${B}" ]; then
echo "*** Restoring ${F}"
mv -f "${B}" "${F}"
fi
- ALREADY_MERGED=
+ ALREADY_MERGED=false
;;
[vV])
${PAGER} "${TEMPROOT}${1}"
;;
"")
- STAY_HERE=NO
+ STAY_HERE=false
;;
*)
echo "*** Invalid selection!"
@@ -326,19 +350,18 @@
for i; do
case "${i}" in
-a)
- AUTOMATIC=YES
+ AUTOMATIC=true
shift
;;
-b)
- BINARY=YES
- SRCDIR="${2}"
- shift 2
+ echo "The '-b tempdir' option has been replaced by '-s tempdir'"
+ exit 1
Home |
Main Index |
Thread Index |
Old Index