synchronize with the much better versions in -current

This commit is contained in:
perry 2003-04-05 18:17:22 +00:00
parent c842b329cd
commit 0da2fd6bad
2 changed files with 201 additions and 84 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: etcupdate,v 1.20 2003/02/04 08:40:57 martti Exp $
# $NetBSD: etcupdate,v 1.21 2003/04/05 18:17:22 perry Exp $
#
# Copyright (c) 2001 The NetBSD Foundation, Inc.
# All rights reserved.
@ -55,11 +55,13 @@ PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
TEMPROOT="${TEMPROOT:=/tmp/temproot}"
SRCDIR="${SRCDIR:=/usr/src/etc}"
PAGER="${PAGER:=/usr/bin/more}"
WIDTH="${WIDTH:=80}"
SWIDTH=`stty -a | fgrep columns | sed -E 's/.+ ([0-9]+) columns.+/\1/'`
WIDTH="${WIDTH:=${SWIDTH}}"
VERBOSE=
CONTINUE=
BINARY=
AUTOMATIC=
LOCALSKIP=
# Settings for post-installation procedures
NEED_MTREE=
@ -81,6 +83,8 @@ Options:
-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
@ -149,8 +153,8 @@ install_checksum() {
[ "${AUTOMATIC}" != "YES" ] && return
D=`dirname "${1}"`
mkdir -p "/etc/etcupdate/${D}"
md5 "${1}" > "/etc/etcupdate/${1}"
mkdir -p "/var/etcupdate/${D}"
md5 "${1}" > "/var/etcupdate/${1}"
}
diff_and_merge_file() {
@ -163,9 +167,9 @@ diff_and_merge_file() {
return
fi
if [ "${AUTOMATIC}" = "YES" -a -f "/etc/etcupdate/${1}" ] ; then
if [ "${AUTOMATIC}" = "YES" -a -f "/var/etcupdate/${1}" ] ; then
SUM1=`md5 "${1}"`
SUM2=`cat "/etc/etcupdate/${1}"`
SUM2=`cat "/var/etcupdate/${1}"`
if [ "${SUM1}" = "${SUM2}" ] ; then
install_file "${1}"
install_checksum "${1}"
@ -173,6 +177,18 @@ diff_and_merge_file() {
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 +316,7 @@ USERRC="${HOME}/.`basename $0`rc"
[ -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
@ -317,6 +333,10 @@ for i; do
-h)
usage
;;
-l)
LOCALSKIP=YES
shift
;;
-p)
PAGER="${2}"
shift 2
@ -394,7 +414,7 @@ if [ -z "${CONTINUE}" ]; then
MAKE=make \
MTREE=mtree \
INSTALL_DONE=1 \
NO_SENDMAIL=1"
USETOOLS=never"
echo "*** Populating ${TEMPROOT} from ${SRCDIR}"
cd ${SRCDIR}
if [ -z "${VERBOSE}" ]; then
@ -417,6 +437,14 @@ if [ -z "${CONTINUE}" ]; then
rm -f "${TEMPROOT}"/etc/spwd.db
find "${TEMPROOT}" -type f -size 0 -exec rm {} \;
# Ignore files we're told to ignore
if [ ! -z "${IGNOREFILES}" ]; then
echo "*** Ignoring files: ${IGNOREFILES}"
for file in ${IGNOREFILES}; do
rm -f "${TEMPROOT}"${file}
done
fi
# Are there any new directories?
echo "*** Checking for new directories"
for i in `find ${TEMPROOT} -type d`; do

View file

@ -1,4 +1,4 @@
.\" $NetBSD: etcupdate.8,v 1.8 2003/01/27 07:54:24 martti Exp $
.\" $NetBSD: etcupdate.8,v 1.9 2003/04/05 18:17:23 perry 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 January 24, 2003
.Dd April 2, 2003
.Dt ETCUPDATE 8
.Os
.Sh NAME
@ -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
@ -53,48 +54,25 @@
.Op Fl w Ar width
.Sh DESCRIPTION
.Nm
is a tool to update the configuration and startup files in
is a tool that lets the administrator update the configuration and
startup files in
.Pa /etc
(and some other directories like
.Pa /dev ,
.Pa /root
and
.Pa /var )
without the need of manually checking and modifying every file.
The user should run this script after performing an operating system
update (e.g. after running
without having to manually check and modify every file.
The administrator should run this script after performing an operating
system update (e.g. after running
.Pa make build
in
.Pa /usr/src
or after extracting the binary distribution files)
to use the latest configuration and startup files.
.Pp
If the user is updating from sources (which is the default mode),
.Nm
will first create a copy of the new configuration and startup files
by running
.Pa make distribution
in
.Pa /usr/src/etc .
.Pp
Instead of using sources, the user can also extract one or more binary
distribution sets and use those files to update the currently installed
files (see usage of the
.Fl b Ar srcdir
argument later in this manual page).
Files in
.Pa srcdir
will be removed by
.Nm
when using the
.Fl b Ar srcdir
argument (as the
.Pa srcdir
directory is treated like
.Pa temproot ) .
or after extracting new binary distribution files)
to update to the latest configuration and startup files.
.Pp
.Nm
compares the new files against the currently installed files.
compares the new configuration files against the currently installed files.
The user is given the option of installing, merging or deleting each
modified or missing file.
.Nm
@ -105,62 +83,156 @@ from the
file.
.Pp
.Nm
needs a clean set of new configuration files to compare the
existing files against.
These files, called the
.Dq reference files
in this manual, may be derived from either a source or binary
distribution of
.Nx .
.Pp
If the user is updating from sources (which is the default mode),
.Nm
will first create a copy of the reference files
by running
.Pa make distribution
in
.Pa /usr/src/etc ,
installing the files to a so-called
.Pa temproot .
(See usage of the
.Fl s Ar srcdir ,
and
.Fl t Ar temproot
options later in this manual page.)
.Pp
Instead of using sources, the user can also extract one or more binary
distribution sets in a special location and use those as the reference
files (see usage of the
.Fl b Ar srcdir
option later in this manual page).
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl a
.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
.Pa /var/etcupdate
and use these checksums to determine if there have been any
local modifications.
.Sh ENVIRONMENT
.Bl -tag -width TEMPROOT
.It Ev TEMPROOT
The temporary files created from
.Pa /usr/src/etc
will be stored here. These files will then be compared
against the currently installed files in the
.Pa /etc
directory. By default this is
.Pa /tmp/temproot
but it can be changed either with the
.Fl t Ar temproot
argument or by defining the
.Ev TEMPROOT
variable.
.It Ev SRCDIR
The location of the
.Nx
sources files. By default this is
.Pa /usr/src/etc
but it can be changed either with the
.Fl s Ar srcdir
argument or by defining the
.Ev SRCDIR
variable.
.It Ev PAGER
The pager to use when displaying files. By default this is
.It Fl b
Location of reference files extracted from a binary distribution of
.Nx .
Note that reference files in
.Pa srcdir
will be altered and removed by
.Nm
when using the
.Fl b Ar srcdir
option (as the
.Pa srcdir
directory is treated like
.Pa temproot ) .
.It Fl h
Prints a help text.
.It Fl l
Automatically skip files with unchanged RCS IDs.
This has the effect of leaving alone files that have been altered
locally but which have not been changed in the
reference files.
Since this works using RCS IDs, files without RCS IDs will not be
skipped even if only modified locally.
This flag may be used together with the
.Fl a
flag described above.
.It Fl p
The pager to use when displaying files.
By default this is
.Xr more 1
but it can be changed either with the
.Fl p Ar pager
argument or by defining the
but it can be changed either with this option
or by defining the
.Ev PAGER
variable.
.It Ev WIDTH
The screen width used during interactive merge. By default this is
80 but it can be changed either with the
.Fl w Ar width
argument or by defining the
.It Fl s
The location of the
.Nx
sources files used to create the reference files.
By default this is
.Pa /usr/src/etc
but it can be changed either with this option
or the
.Ev SRCDIR
variable.
.It Fl t
Specifies the location of the
.Pa temproot
directory.
The temporary reference files created from
.Pa /usr/src/etc
will be stored there.
By default this is
.Pa /tmp/temproot
but can be changed either with this option or the
.Ev TEMPROOT
environment variable.
.It Fl v
Makes
.Nm
verbose about its actions.
.It Fl w
Sets screen width used during interactive merge.
By default this is the number of columns
.Xr stty 1
reports but it can be changed either with this
option or by defining the
.Ev WIDTH
variable.
This is useful for
.Xr xterm 1
users with wider shell windows.
.El
.Sh ENVIRONMENT
.Bl -tag -width TEMPROOT
.It Ev TEMPROOT
Sets a default value for
.Pa temproot .
See
.Fl t
above.
.It Ev SRCDIR
The location of the
.Nx
sources files.
See
.Fl s
above.
.It Ev PAGER
The pager to use when displaying files.
See
.Fl p
above.
.It Ev WIDTH
The screen width used during interactive merge.
See
.Fl w
above.
.It Ev IGNOREFILES
A list of files that
.Nm
should ignore.
Files listed in this
variable will never be considered for updating by
.Nm .
.El
.Sh FILES
The environment variables can also be defined in the following configuration
files. The user's personal configuration file settings override the global
files.
The user's personal configuration file settings override the global
settings.
.Pp
/etc/etcupdate.conf
@ -205,25 +277,42 @@ To get a better idea what's going on, use the
flag:
.Pp
.Dl etcupdate -v
.Sh SEE ALSO
.Xr cmp 1 ,
.Xr more 1 ,
.Xr rcs 1 ,
.Xr sdiff 1 ,
.Xr stty 1 ,
.Xr aliases 5
.Sh HISTORY
The
.Nm
command appeared in
.Nx 1.6 .
.Sh AUTHORS
The
script was written by Martti Kuparinen <martti@netbsd.org> and
improved by several other
The script was written by
.An Martti Kuparinen
.Aq martti@NetBSD.org
and improved by several other
.Nx
users.
.Pp
The idea for this script (including code fragments, variable names etc.)
came from the
.Fx
mergemaster (by Douglas Barton). Unlike the
mergemaster (by Douglas Barton).
Unlike the
.Fx
mergemaster, this does not use CVS version tags to compare if
the files need to be updated. Files are compared with
mergemaster, this does not use CVS version tags by default to compare if
the files need to be updated.
Files are compared with
.Xr cmp 1
as this is more reliable and the only way if the version numbers are the
same even though the files are different.
.\" when exactly are the version the same even though the file changes?
.\" .Pp
.\" .Sh BUGS
.\" Because of the use of
.\" .Xr cmp 1
.\" to compare files, rather than CVS versions, files that are locally changed
.\" from the distribution are always considered needing to be updated.