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
This commit is contained in:
apb 2006-02-18 19:29:48 +00:00
parent 717f2d5d7e
commit 7e321ef839
2 changed files with 245 additions and 102 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# $NetBSD: etcupdate,v 1.22 2005/04/17 23:12:40 lukem Exp $ # $NetBSD: etcupdate,v 1.23 2006/02/18 19:29:48 apb Exp $
# #
# Copyright (c) 2001 The NetBSD Foundation, Inc. # Copyright (c) 2001 The NetBSD Foundation, Inc.
# All rights reserved. # All rights reserved.
@ -53,39 +53,51 @@ PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
# Default settings # Default settings
TEMPROOT="${TEMPROOT:=/tmp/temproot}" TEMPROOT="${TEMPROOT:=/tmp/temproot}"
SRCDIR="${SRCDIR:=/usr/src/etc}"
PAGER="${PAGER:=/usr/bin/more}" PAGER="${PAGER:=/usr/bin/more}"
SWIDTH=`stty -a | awk '/columns/{w=$6}END{if(w==0){w=80}print w}'` SWIDTH=`stty -a | awk '/columns/{w=$6}END{if(w==0){w=80}print w}'`
WIDTH="${WIDTH:=${SWIDTH}}" WIDTH="${WIDTH:=${SWIDTH}}"
VERBOSE= DIFF_COMMAND="diff -u"
CONTINUE= VERBOSE=false
BINARY= CONTINUE=false
AUTOMATIC= SOURCEMODE=false # true for "-s source_dir"
LOCALSKIP= 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`}" MACHINE="${MACHINE:=`uname -m`}"
export MACHINE export MACHINE
MACHINE_ARCH="${MACHINE_ARCH:=`uname -p`}" MACHINE_ARCH="${MACHINE_ARCH:=`uname -p`}"
export MACHINE_ARCH export MACHINE_ARCH
# Settings for post-installation procedures # Settings for post-installation procedures
NEED_MTREE= NEED_MTREE=false
NEED_MAKEDEV= NEED_MAKEDEV=false
NEED_NEWALIASES= NEED_NEWALIASES=false
NEED_PWD_MKDB= NEED_PWD_MKDB=false
myname="${0##*/}"
usage() { usage() {
cat << EOF cat << EOF
Usage: `basename $0` [options] Usage: ${myname} [options]
Options: Options:
-b srcdir Location of the extracted sets
-p pager Which pager to use (default: /usr/bin/more) -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) -t temproot Where to store temporary files (default: /tmp/temproot)
-w width Screen width (default: 80) -w width Screen width (default: 80)
-a Automatically update unmodified files -a Automatically update unmodified files
-l Automatically skip files with strictly local changes -l Automatically skip files with strictly local changes
(this option has no effect on files lacking RCS Ids) (this option has no effect on files lacking RCS Ids)
@ -99,7 +111,7 @@ EOF
verbose() { verbose() {
# $* = message to display if in verbose mode # $* = message to display if in verbose mode
[ ! -z "${VERBOSE}" ] && echo ${*} ${VERBOSE} && echo "${*}"
} }
yesno() { yesno() {
@ -123,7 +135,7 @@ install_dir() {
if yesno "Create ${1}"; then if yesno "Create ${1}"; then
verbose "Creating ${1}" verbose "Creating ${1}"
mkdir -p "${1}" || exit 1 mkdir -p "${1}" || exit 1
NEED_MTREE=YES NEED_MTREE=true
fi fi
} }
@ -137,16 +149,16 @@ install_file() {
# Check if this was a special file # Check if this was a special file
case "${1}" in case "${1}" in
/dev/MAKEDEV) /dev/MAKEDEV)
NEED_MAKEDEV=YES NEED_MAKEDEV=true
;; ;;
/dev/MAKEDEV.local) /dev/MAKEDEV.local)
NEED_MAKEDEV=YES NEED_MAKEDEV=true
;; ;;
/etc/mail/aliases) /etc/mail/aliases)
NEED_NEWALIASES=YES NEED_NEWALIASES=true
;; ;;
/etc/master.passwd) /etc/master.passwd)
NEED_PWD_MKDB=YES NEED_PWD_MKDB=true
;; ;;
esac esac
} }
@ -154,7 +166,7 @@ install_file() {
install_checksum() { install_checksum() {
# $1 = target file # $1 = target file
[ "${AUTOMATIC}" != "YES" ] && return ${AUTOMATIC} || return
D=`dirname "${1}"` D=`dirname "${1}"`
mkdir -p "/var/etcupdate/${D}" mkdir -p "/var/etcupdate/${D}"
@ -171,22 +183,22 @@ diff_and_merge_file() {
return return
fi fi
if [ "${AUTOMATIC}" = "YES" -a -f "/var/etcupdate/${1}" ] ; then if ${AUTOMATIC} && [ -f "/var/etcupdate/${1}" ]; then
SUM1=`md5 "${1}"` SUM1=`md5 "${1}"`
SUM2=`cat "/var/etcupdate/${1}"` SUM2=`cat "/var/etcupdate/${1}"`
if [ "${SUM1}" = "${SUM2}" ] ; then if [ "${SUM1}" = "${SUM2}" ]; then
install_file "${1}" install_file "${1}"
install_checksum "${1}" install_checksum "${1}"
return return
fi fi
fi fi
if [ "${LOCALSKIP}" = "YES" ] ; then if ${LOCALSKIP}; then
ID1=`ident -q "${TEMPROOT}${1}" | sed -n 2p` ID1=`ident -q "${TEMPROOT}${1}" | sed -n 2p`
ID1="${ID1:-0}" ID1="${ID1:-0}"
ID2=`ident -q "${1}" | sed -n 2p` ID2=`ident -q "${1}" | sed -n 2p`
ID2="${ID2:-1}" ID2="${ID2:-1}"
if [ "${ID1}" = "${ID2}" ] ; then if [ "${ID1}" = "${ID2}" ]; then
verbose "===> ${1} (ok:RCS)" verbose "===> ${1} (ok:RCS)"
rm -f "${TEMPROOT}${1}" rm -f "${TEMPROOT}${1}"
return return
@ -196,16 +208,16 @@ diff_and_merge_file() {
clear clear
if [ ! -f "${1}" ]; then if [ ! -f "${1}" ]; then
verbose "===> ${1} (missing)" verbose "===> ${1} (missing)"
DOES_EXIST= DOES_EXIST=false
else else
verbose "===> ${1} (modified)" verbose "===> ${1} (modified)"
verbose "" verbose ""
DOES_EXIST=YES DOES_EXIST=true
diff -u "${1}" "${TEMPROOT}${1}" | ${PAGER} diff -u "${1}" "${TEMPROOT}${1}" | ${PAGER}
fi fi
STAY_HERE=YES STAY_HERE=true
ALREADY_MERGED= ALREADY_MERGED=false
# Determine name for the backup file (/foo/._etcupdate.bar) # Determine name for the backup file (/foo/._etcupdate.bar)
D=`dirname "${TEMPROOT}${1}"` D=`dirname "${TEMPROOT}${1}"`
@ -213,7 +225,7 @@ diff_and_merge_file() {
B="${D}/.etcupdate.${F}" B="${D}/.etcupdate.${F}"
F="${D}/${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 # Ask the user if (s)he wants to install the new
# version or perform a more complicated manual work. # version or perform a more complicated manual work.
@ -228,29 +240,35 @@ diff_and_merge_file() {
echo "" echo ""
echo "Please select one of the following operations:" echo "Please select one of the following operations:"
echo "" echo ""
if [ -z "${DOES_EXIST}" ]; then if ! ${DOES_EXIST}; then
cat << EOF cat << EOF
d Don't install the missing file d Don't install the missing file
i Install the missing file i Install the missing file
v Show the missing file v Show the missing file
EOF EOF
elif [ -z "${ALREADY_MERGED}" ]; then elif ! ${ALREADY_MERGED}; then
cat << EOF cat << EOF
d Don't install the new file d Don't install the new file (keep your old file)
i Install the new file (overwrites your modifications!) i Install the new file (overwrites your local modifications!)
m Merge the currently installed and new files m Merge the currently installed and new files
s Show the differences between 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 v Show the new file
EOF EOF
else else
cat << EOF cat << EOF
d Don't install the new file d Don't install the merged file (keep your old file)
i Install the new file (overwrites your modifications!) i Install the merged file
m Merge again the currently installed and new files m Merge again (your old file against the result from the previous merge)
s Show the differences between the currently installed and new files s Show the differences between the currently installed and new merged files
u Undo merge and restore the temporary file from backup 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 v Show the merged file
EOF EOF
@ -262,17 +280,17 @@ EOF
[dD]) [dD])
verbose "Removing ${TEMPROOT}${1}" verbose "Removing ${TEMPROOT}${1}"
rm -f "${TEMPROOT}${1}" rm -f "${TEMPROOT}${1}"
STAY_HERE=NO STAY_HERE=false
;; ;;
[iI]) [iI])
install_file "${1}" install_file "${1}"
if [ -z "${ALREADY_MERGED}" ]; then if ! ${ALREADY_MERGED}; then
install_checksum "${1}" install_checksum "${1}"
fi fi
STAY_HERE=NO STAY_HERE=false
;; ;;
[mM]) [mM])
[ -z "${DOES_EXIST}" ] && continue ${DOES_EXIST} || continue
[ ! -f "${B}" ] && cp "${F}" "${B}" [ ! -f "${B}" ] && cp "${F}" "${B}"
cp "${TEMPROOT}${1}" "${TEMPROOT}${1}.merged" cp "${TEMPROOT}${1}" "${TEMPROOT}${1}.merged"
sdiff -o "${TEMPROOT}${1}.merged" \ sdiff -o "${TEMPROOT}${1}.merged" \
@ -280,24 +298,30 @@ EOF
--suppress-common-lines --text \ --suppress-common-lines --text \
"${1}" "${TEMPROOT}${1}" "${1}" "${TEMPROOT}${1}"
mv -f "${TEMPROOT}${1}.merged" "${TEMPROOT}${1}" mv -f "${TEMPROOT}${1}.merged" "${TEMPROOT}${1}"
ALREADY_MERGED=YES ALREADY_MERGED=true
;; ;;
[sS]) [sS]*)
[ -z "${DOES_EXIST}" ] && continue ${DOES_EXIST} || continue
diff -u "${1}" "${TEMPROOT}${1}" | ${PAGER} 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]) [uU])
if [ -f "${B}" ]; then if [ -f "${B}" ]; then
echo "*** Restoring ${F}" echo "*** Restoring ${F}"
mv -f "${B}" "${F}" mv -f "${B}" "${F}"
fi fi
ALREADY_MERGED= ALREADY_MERGED=false
;; ;;
[vV]) [vV])
${PAGER} "${TEMPROOT}${1}" ${PAGER} "${TEMPROOT}${1}"
;; ;;
"") "")
STAY_HERE=NO STAY_HERE=false
;; ;;
*) *)
echo "*** Invalid selection!" echo "*** Invalid selection!"
@ -326,19 +350,18 @@ set -- ${ARGV}
for i; do for i; do
case "${i}" in case "${i}" in
-a) -a)
AUTOMATIC=YES AUTOMATIC=true
shift shift
;; ;;
-b) -b)
BINARY=YES echo "The '-b tempdir' option has been replaced by '-s tempdir'"
SRCDIR="${2}" exit 1
shift 2
;; ;;
-h) -h)
usage usage
;; ;;
-l) -l)
LOCALSKIP=YES LOCALSKIP=true
shift shift
;; ;;
-p) -p)
@ -346,15 +369,45 @@ for i; do
shift 2 shift 2
;; ;;
-s) -s)
SRCDIR="${2}" # Three cases:
# -s tgzfile
# -s srcdir
# -s extracted_dir
arg="${2}"
shift 2 shift 2
if [ -f "${arg}" ]; then
# arg refers to a *.tgz file.
# This may happen twice, for both etc.tgz and
# xetc.tgz, so we build up a colon-separated
# list in TGZLIST.
BINARYMODE=true
BINARYTGZMODE=true
TGZLIST="${TGZLIST}${TGZLIST:+:}${arg}"
elif [ -d "${arg}" ] && [ -f "${ARG}/etc/Makefile" ]; then
# arg refers to a source directory
SOURCEMODE=true
SRCDIR="${arg}"
elif [ -d "${arg}" ] && [ -f "${ARG}/../etc/Makefile" ]; then
# backward compatibility: allow arg to refer to
# etc subdirectory within source dir.
SOURCEMODE=true
SRCDIR="${arg}/.."
elif [ -d "${arg}" ] && [ -d "${ARG}/etc" ]; then
# arg refers to a directory where the
# sets have already been extracted
BINARYMODE=true
BINARYDIRMODE=true
BINARYDIR="${arg}"
else
usage
fi
;; ;;
-t) -t)
TEMPROOT="${2}" TEMPROOT="${2}"
shift 2 shift 2
;; ;;
-v) -v)
VERBOSE=YES VERBOSE=true
shift shift
;; ;;
-w) -w)
@ -373,8 +426,21 @@ if [ `id -u` -ne 0 ]; then
echo "*** ERROR: You MUST be root" echo "*** ERROR: You MUST be root"
exit 1 exit 1
fi fi
if [ ! -z "${BINARY}" ]; then if ${SOURCEMODE} && ${BINARYMODE}; then
TEMPROOT="${SRCDIR}" usage
fi
if ${BINARYDIRMODE} && ${BINARYTGZMODE}; then
usage
fi
if ${BINARYDIRMODE}; then
SRCDIR="${BINARYDIR}"
TEMPROOT="${BINARYDIR}"
fi
if ${BINARYTGZMODE}; then
SRCDIR="${TEMPROOT}"
fi
if ${SOURCEMODE} && [ -x "${SRCDIR}" ]; then
SRCDIR=/usr/src
fi fi
if [ -z "${SRCDIR}" -o -z "${TEMPROOT}" ]; then if [ -z "${SRCDIR}" -o -z "${TEMPROOT}" ]; then
echo "*** ERROR: One of the following variables is undefined" echo "*** ERROR: One of the following variables is undefined"
@ -384,21 +450,21 @@ if [ -z "${SRCDIR}" -o -z "${TEMPROOT}" ]; then
echo "" echo ""
exit 1 exit 1
fi fi
if [ -z "${BINARY}" -a -r "${TEMPROOT}" ]; then if ! ${BINARYDIRMODE} && [ -r "${TEMPROOT}" ]; then
echo "" echo ""
echo "*** WARNING: ${TEMPROOT} already exists" echo "*** WARNING: ${TEMPROOT} already exists"
echo "" echo ""
if yesno "Continue previously aborted update"; then if yesno "Continue previously aborted update"; then
CONTINUE=YES CONTINUE=true
elif yesno "Remove the old ${TEMPROOT}"; then elif yesno "Remove the old ${TEMPROOT}"; then
echo "*** Removing ${TEMPROOT}" echo "*** Removing ${TEMPROOT}"
rm -rf "${TEMPROOT}" rm -rf "${TEMPROOT}"
fi fi
fi fi
if [ -z "${CONTINUE}" ]; then if ! ${CONTINUE}; then
# Are we using the sources or binaries? # Are we using the sources or binaries?
if [ -z "${BINARY}" ]; then if ! ${BINARYDIRMODE}; then
# Create the temporary root directory # Create the temporary root directory
echo "*** Creating ${TEMPROOT}" echo "*** Creating ${TEMPROOT}"
mkdir -p "${TEMPROOT}" mkdir -p "${TEMPROOT}"
@ -406,10 +472,25 @@ if [ -z "${CONTINUE}" ]; then
echo "*** ERROR: Unable to create ${TEMPROOT}" echo "*** ERROR: Unable to create ${TEMPROOT}"
exit 1 exit 1
fi fi
fi
if ${BINARYTGZMODE}; then
# Populate ${TEMPROOT} from ${TGZLIST}
oldIFS="${IFS}"
IFS=:
for tgz in ${TGZLIST}; do
if [ ! -f "${tgz}" ]; then
echo "*** ERROR: Unable to find ${tgz}"
exit 1
fi
echo "*** Populating ${TEMPROOT} from ${tgz}"
tar -zxpf "${tgz}" -C "${TEMPROOT}"
[ $? -ne 0 ] && exit 1
done
IFS="${oldIFS}"
elif ! ${BINARYMODE}; then
# Populate ${TEMPROOT} from ${SRCDIR} # Populate ${TEMPROOT} from ${SRCDIR}
if [ ! -f "${SRCDIR}/Makefile" ]; then if [ ! -f "${SRCDIR}/etc/Makefile" ]; then
echo "*** ERROR: Unable to find ${SRCDIR}/Makefile" echo "*** ERROR: Unable to find ${SRCDIR}/etc/Makefile"
exit 1 exit 1
fi fi
# Set the environment for make # Set the environment for make
@ -421,14 +502,15 @@ if [ -z "${CONTINUE}" ]; then
INSTALL_DONE=1 \ INSTALL_DONE=1 \
USETOOLS=never" USETOOLS=never"
echo "*** Populating ${TEMPROOT} from ${SRCDIR}" echo "*** Populating ${TEMPROOT} from ${SRCDIR}"
cd ${SRCDIR} cd ${SRCDIR}/etc
if [ -z "${VERBOSE}" ]; then if ! ${VERBOSE}; then
eval ${MAKE_ENV} make distribution > /dev/null eval ${MAKE_ENV} make distribution > /dev/null
else else
eval ${MAKE_ENV} make distribution eval ${MAKE_ENV} make distribution
fi fi
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
elif [ ! -f "${TEMPROOT}/dev/MAKEDEV" ]; then fi
if [ ! -f "${TEMPROOT}/dev/MAKEDEV" ]; then
echo "" echo ""
echo "*** WARNING: ${TEMPROOT}/dev/MAKEDEV not found" echo "*** WARNING: ${TEMPROOT}/dev/MAKEDEV not found"
echo "Make sure you update /dev/MAKEDEV later and run" echo "Make sure you update /dev/MAKEDEV later and run"
@ -485,14 +567,14 @@ else
fi fi
# Do some post-installation tasks # Do some post-installation tasks
if [ ! -z "${NEED_MTREE}" ]; then if ${NEED_MTREE}; then
if yesno "You have created new directories. Run mtree to set" \ if yesno "You have created new directories. Run mtree to set" \
"permissions" "permissions"
then then
(cd / && mtree -Udef /etc/mtree/NetBSD.dist) (cd / && mtree -Udef /etc/mtree/NetBSD.dist)
fi fi
fi fi
if [ ! -z "${NEED_MAKEDEV}" ]; then if ${NEED_MAKEDEV}; then
if yesno "Do you want to rebuild the device nodes in /dev"; then if yesno "Do you want to rebuild the device nodes in /dev"; then
verbose "Running MAKEDEV in /dev" verbose "Running MAKEDEV in /dev"
(cd "/dev" && ./MAKEDEV all) (cd "/dev" && ./MAKEDEV all)
@ -504,7 +586,7 @@ if [ ! -z "${NEED_MAKEDEV}" ]; then
echo "" echo ""
fi fi
fi fi
if [ ! -z "${NEED_NEWALIASES}" ]; then if ${NEED_NEWALIASES}; then
if yesno "Do you want to rebuild the mail alias database"; then if yesno "Do you want to rebuild the mail alias database"; then
verbose "Running newaliases" verbose "Running newaliases"
newaliases newaliases
@ -516,7 +598,7 @@ if [ ! -z "${NEED_NEWALIASES}" ]; then
echo "" echo ""
fi fi
fi fi
if [ ! -z "${NEED_PWD_MKDB}" ]; then if ${NEED_PWD_MKDB}; then
if yesno "Do you want to rebuild the password databases from the" \ if yesno "Do you want to rebuild the password databases from the" \
"new master.passwd" "new master.passwd"
then then
@ -531,9 +613,9 @@ if [ ! -z "${NEED_PWD_MKDB}" ]; then
echo "" echo ""
fi fi
fi fi
if [ -x /usr/sbin/postinstall -a -z "${BINARY}" ]; then if [ -x /usr/sbin/postinstall ] && ! ${BINARYMODE}; then
S=`echo ${SRCDIR} | sed 's+/etc++'` # XXX we should also run postinstall in binary mode
echo "*** Running /usr/sbin/postinstall" echo "*** Running /usr/sbin/postinstall"
/usr/sbin/postinstall -s "${S}" check /usr/sbin/postinstall -s "${SRCDIR}" check
fi fi
echo "*** All done" echo "*** All done"

View File

@ -1,4 +1,4 @@
.\" $NetBSD: etcupdate.8,v 1.10 2003/04/02 19:30:57 wiz Exp $ .\" $NetBSD: etcupdate.8,v 1.11 2006/02/18 19:29:48 apb Exp $
.\" .\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc. .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd April 2, 2003 .Dd February 18, 2006
.Dt ETCUPDATE 8 .Dt ETCUPDATE 8
.Os .Os
.Sh NAME .Sh NAME
@ -44,9 +44,8 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl ahlv .Op Fl ahlv
.Op Fl b Ar srcdir
.Op Fl p Ar pager .Op Fl p Ar pager
.Op Fl s Ar srcdir .Op Fl s Brq Ar srcdir | Ar tgzfile | Ar tempdir
.Op Fl t Ar temproot .Op Fl t Ar temproot
.Op Fl w Ar width .Op Fl w Ar width
.Sh DESCRIPTION .Sh DESCRIPTION
@ -106,7 +105,11 @@ options later in this manual page.)
Instead of using sources, the user can also extract one or more binary 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 distribution sets in a special location and use those as the reference
files (see usage of the files (see usage of the
.Fl b Ar srcdir .Fl s Ar tempdir
option later in this manual page),
or specify one or more binary distribution sets directly
(see usage of the
.Fl s Ar tgzfile
option later in this manual page). option later in this manual page).
.Pp .Pp
The following options are available: The following options are available:
@ -122,19 +125,6 @@ to store MD5 checksums in
.Pa /var/etcupdate .Pa /var/etcupdate
and use these checksums to determine if there have been any and use these checksums to determine if there have been any
local modifications. local modifications.
.It Fl b Ar srcdir
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 .It Fl h
Prints a help text. Prints a help text.
.It Fl l .It Fl l
@ -155,28 +145,79 @@ but it can be changed either with this option
or by defining the or by defining the
.Ev PAGER .Ev PAGER
variable. variable.
.It Fl s Brq Ar srcdir | Ar tgzfile | Ar tempdir
The location of the reference files, or the
.Nx
source files used to create the reference files.
This may be specified in one of three ways:
.Bl -tag -width XXsXtempdirXX
.It Fl s Ar srcdir .It Fl s Ar srcdir
The location of the The location of the
.Nx .Nx
sources files used to create the reference files. source files used to create the reference files.
By default this is By default this is
.Pa /usr/src/etc .Pa /usr/src
but it can be changed either with this option but it can be changed either with this option
or the or the
.Ev SRCDIR .Ev SRCDIR
variable. variable.
Note that
.Ar srcdir
should refer to the top of the source directory tree;
earlier versions of
.Nm
expected
.Ar srcdir
to refer to the
.Pa etc
subdirectory within the source tree.
.It Fl s Ar tgzfile
The location of a set file from a binary distribution of
.Nx .
The set file is a compressed archive containing reference files.
This option may be specified twice, to specify the locations of
both the
.Pa etc.tgz
and
.Pa xetc.tgz
sets.
The files from the specified sets will be extracted to the
.Pa temproot
directory.
.It Fl s Ar tempdir
Location of reference files extracted from a binary distribution of
.Nx .
Note that reference files in
.Pa tempdir
will be altered and removed by
.Nm
when using the
.Fl s Ar tempdir
option (as the
.Pa tempdir
directory is treated like
.Pa temproot ) .
.El
.It Fl t Ar temproot .It Fl t Ar temproot
Specifies the location of the Specifies the location of the
.Pa temproot .Pa temproot
directory. directory.
The temporary reference files created from The temporary reference files created from
.Pa /usr/src/etc the source directory specified by
.Fl s Ar srcdir ,
or the temporary reference files extracted from
the binary tgz sets specified by
.Fl s Ar tgzfile ,
will be stored there. will be stored there.
By default this is By default this is
.Pa /tmp/temproot .Pa /tmp/temproot
but can be changed either with this option or the but can be changed either with this option or the
.Ev TEMPROOT .Ev TEMPROOT
environment variable. environment variable.
It is an error to specify
.Fl t Ar temproot
in conjunction with
.Fl s Ar tempdir .
.It Fl v .It Fl v
Makes Makes
.Nm .Nm
@ -238,7 +279,7 @@ settings.
.Sh EXAMPLES .Sh EXAMPLES
You have just upgraded your You have just upgraded your
.Nx .Nx
host from 1.6 to 1.6.1 and now it's time host from 3.0 to 4.0 and now it's time
to update the configuration files as well. to update the configuration files as well.
To update the configuration files from the sources (if you have the To update the configuration files from the sources (if you have the
.Pa /usr/src/etc .Pa /usr/src/etc
@ -247,20 +288,25 @@ directory):
.Dl etcupdate .Dl etcupdate
.Pp .Pp
The default location of the source files is The default location of the source files is
.Pa /usr/src/etc .Pa /usr/src
but this may be overridden with the but this may be overridden with the
.Fl s Ar srcdir .Fl s Ar srcdir
command line argument: command line argument:
.Pp .Pp
.Dl etcupdate -s /some/where/src/etc .Dl etcupdate -s /some/where/src
.Pp .Pp
To update the configuration files from binary distribution sets To update the configuration files from binary distribution sets
do something like this: do something like this:
.Pp .Pp
.Dl etcupdate -s /some/where/etc.tgz -s /some/where/xetc.tgz
.Pp
or like this:
.Pp
.Dl mkdir /tmp/temproot .Dl mkdir /tmp/temproot
.Dl cd /tmp/temproot .Dl cd /tmp/temproot
.Dl tar xpzf /some/where/etc.tgz .Dl tar -xpzf /some/where/etc.tgz
.Dl etcupdate -b /tmp/temproot .Dl tar -xpzf /some/where/xetc.tgz
.Dl etcupdate -s /tmp/temproot
.Pp .Pp
You have modified only few files in the You have modified only few files in the
.Pa /etc .Pa /etc
@ -286,6 +332,21 @@ The
.Nm .Nm
command appeared in command appeared in
.Nx 1.6 . .Nx 1.6 .
.Pp
In
.Nx 4.0 ,
the
.Fl s Ar tgzfile
option was added, the
.Fl b Ar tempdir
option was converted to
.Fl s Ar tempdir ,
and the
.Fl s Ar srcdir
option was changed to refer to the top of the
source directory tree rather than to the
.Pa etc
subdirectory.
.Sh AUTHORS .Sh AUTHORS
The script was written by The script was written by
.An Martti Kuparinen .An Martti Kuparinen