diff options
author | martti <martti@pkgsrc.org> | 2001-12-01 11:42:09 +0000 |
---|---|---|
committer | martti <martti@pkgsrc.org> | 2001-12-01 11:42:09 +0000 |
commit | 4fb369cb8cca19c2a445a650e9ff6e7085022272 (patch) | |
tree | f47b45ba10e928c2fd4ff5e20db65fc9722e1ddc /sysutils | |
parent | c8d6490e84c6018dd26cc9eee6071c6fedf56681 (diff) | |
download | pkgsrc-4fb369cb8cca19c2a445a650e9ff6e7085022272.tar.gz |
Updated to 20011201. Changes since last commit:
* The -b switch requires now argument
* The -s switch defines the location of /usr/src/etc (used to be /usr/src)
* Manual page fixes
* Better menu after merge
* Possibility to undo merge
Usage:
# etcupdate -s /some/where/src/etc
or
# mkdir /tmp/temproot
# cd /tmp/temproot
# tar xzf /some/where/etc.tgz
# etcupdate -b /tmp/temproot
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/etcupdate/Makefile | 4 | ||||
-rwxr-xr-x | sysutils/etcupdate/files/etcupdate | 48 | ||||
-rw-r--r-- | sysutils/etcupdate/files/etcupdate.8 | 82 |
3 files changed, 78 insertions, 56 deletions
diff --git a/sysutils/etcupdate/Makefile b/sysutils/etcupdate/Makefile index 5536b37bf59..80b36b2c27f 100644 --- a/sysutils/etcupdate/Makefile +++ b/sysutils/etcupdate/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.6 2001/11/23 19:16:38 martti Exp $ +# $NetBSD: Makefile,v 1.7 2001/12/01 11:42:09 martti Exp $ -DISTNAME= etcupdate-20011123 +DISTNAME= etcupdate-20011201 CATEGORIES= sysutils MASTER_SITES= # empty DISTFILES= # empty diff --git a/sysutils/etcupdate/files/etcupdate b/sysutils/etcupdate/files/etcupdate index 9f5e854c56d..b9b2eac4019 100755 --- a/sysutils/etcupdate/files/etcupdate +++ b/sysutils/etcupdate/files/etcupdate @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: etcupdate,v 1.7 2001/11/23 19:16:38 martti Exp $ +# $NetBSD: etcupdate,v 1.8 2001/12/01 11:42:09 martti Exp $ # # Copyright (c) 2001 The NetBSD Foundation, Inc. # All rights reserved. @@ -53,7 +53,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin # Default settings TEMPROOT="${TEMPROOT:=/tmp/temproot}" -SRCDIR="${SRCDIR:=/usr/src}" +SRCDIR="${SRCDIR:=/usr/src/etc}" PAGER="${PAGER:=/usr/bin/more}" WIDTH="${WIDTH:=80}" VERBOSE= @@ -73,7 +73,7 @@ Usage: `basename $0` [options] Options: - -b Use binary distributions + -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) -t temproot Where to store temporary files (default: /tmp/temproot) @@ -161,6 +161,14 @@ diff_and_merge_file() { fi STAY_HERE=YES + ALREADY_MERGED= + + # Determine name for the backup file (/foo/._etcupdate.bar) + D=`dirname "${TEMPROOT}${1}"` + F=`basename "${TEMPROOT}${1}"` + B="${D}/.etcupdate.${F}" + F="${D}/${F}" + while [ "x${STAY_HERE}" = "xYES" ]; do # Ask the user if (s)he wants to install the new @@ -183,7 +191,7 @@ diff_and_merge_file() { v Show the missing file EOF - else + elif [ -z "${ALREADY_MERGED}" ]; then cat << EOF d Don't install the new file i Install the new file (overwrites your modifications!) @@ -192,10 +200,21 @@ EOF 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 + v Show the merged file + +EOF fi echo -n "What do you want to do? [Leave it for later] " read ANSWER case "${ANSWER}" in + [dD]) verbose "Removing ${TEMPROOT}${1}" rm -f "${TEMPROOT}${1}" @@ -207,17 +226,26 @@ EOF ;; [mM]) [ -z "${DOES_EXIST}" ] && continue + [ ! -f "${B}" ] && cp "${F}" "${B}" cp "${TEMPROOT}${1}" "${TEMPROOT}${1}.merged" sdiff -o "${TEMPROOT}${1}.merged" \ --width=${WIDTH} \ --suppress-common-lines --text \ "${1}" "${TEMPROOT}${1}" mv -f "${TEMPROOT}${1}.merged" "${TEMPROOT}${1}" + ALREADY_MERGED=YES ;; [sS]) [ -z "${DOES_EXIST}" ] && continue diff -u "${1}" "${TEMPROOT}${1}" | ${PAGER} ;; + [uU]) + if [ -f "${B}" ]; then + echo "*** Restoring ${F}" + mv -f "${B}" "${F}" + fi + ALREADY_MERGED= + ;; [vV]) ${PAGER} "${TEMPROOT}${1}" ;; @@ -229,6 +257,7 @@ EOF ;; esac done + rm -f "._etcupdate_${TEMPROOT}${1}" } # @@ -244,14 +273,15 @@ USERRC="${HOME}/.`basename $0`rc" [ -r ${USERRC} ] && . ${USERRC} # Read command line arguments -ARGV=`getopt bhp:s:t:vw: $*` +ARGV=`getopt b:hp:s:t:vw: $*` [ $? != 0 ] && usage set -- ${ARGV} for i; do case "${i}" in -b) BINARY=YES - shift + SRCDIR="${2}" + shift 2 ;; -h) usage @@ -323,12 +353,12 @@ if [ -z "${CONTINUE}" ]; then fi # Populate ${TEMPROOT} from ${SRCDIR} - if [ ! -f "${SRCDIR}/etc/Makefile" ]; then - echo "*** ERROR: Unable to find ${SRCDIR}/etc/Makefile" + if [ ! -f "${SRCDIR}/Makefile" ]; then + echo "*** ERROR: Unable to find ${SRCDIR}/Makefile" exit 1 fi echo "*** Populating ${TEMPROOT} from ${SRCDIR}" - cd ${SRCDIR}/etc + cd ${SRCDIR} if [ -z "${VERBOSE}" ]; then make DESTDIR="${TEMPROOT}" MTREE="mtree" \ INSTALL_DONE=1 NO_SENDMAIL=1 \ diff --git a/sysutils/etcupdate/files/etcupdate.8 b/sysutils/etcupdate/files/etcupdate.8 index be09e180494..5e1e1c527ae 100644 --- a/sysutils/etcupdate/files/etcupdate.8 +++ b/sysutils/etcupdate/files/etcupdate.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: etcupdate.8,v 1.5 2001/11/23 19:16:38 martti Exp $ +.\" $NetBSD: etcupdate.8,v 1.6 2001/12/01 11:42:09 martti Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -43,7 +43,7 @@ .Pa /etc .Sh SYNOPSIS .Nm -.Op Fl b +.Op Fl b Ar srcdir .Op Fl h .Op Fl p Ar pager .Op Fl s Ar srcdir @@ -55,9 +55,10 @@ is a tool to update the configuration and startup files in .Pa /etc (and some other directories like -.Pa /dev +.Pa /dev , +.Pa /root and -.Pa /root ) +.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 @@ -67,17 +68,35 @@ in 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 either running +by running .Pa make distribution in -.Pa /usr/src/etc -or extracting the given binary distribution files) and compare these -against the currently installed files. The user is given the option -of installing, merging or deleting each modified or missing file. +.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 ) . .Pp .Nm +compares the new files against the currently installed files. +The user is given the option of installing, merging or deleting each +modified or missing file. +.Nm also detects if the user installs certain special files and performs corresponding tasks like remaking device nodes or rebuilding a database from the @@ -102,31 +121,12 @@ variable. The location of the .Nx sources files. By default this is -.Pa /usr/src +.Pa /usr/src/etc but it can be changed either with the .Fl s Ar srcdir argument or by defining the .Ev SRCDIR variable. -.Pp -If the -.Fl b -flag is not used, -.Nm -expects to find -.Pa etc/Makefile -within the source directory. This will be used to create the temporary -files in -.Pa /tmp/temproot . -.Pp -If the -.Fl b -flag is used (maybe together with the -.Fl s Ar srcdir -argument), -.Nm -uses the source directory directly as the temporary directory -.Pa ( /tmp/temproot ) . .It Ev PAGER The pager to use when displaying files. By default this is .Xr more 1 @@ -160,34 +160,26 @@ You have just upgraded your host from 1.5.2 to 1.5.3 and now it's time to update the configuration files as well. To update the configuration files from the sources (if you have the -.Pa /usr/src +.Pa /usr/src/etc directory): .Pp .Dl etcupdate .Pp The default location of the source files is -.Pa /usr/src +.Pa /usr/src/etc but this may be overridden with the .Fl s Ar srcdir command line argument: .Pp -.Dl etcupdate -s /some/where/src +.Dl etcupdate -s /some/where/src/etc .Pp -To update the configuration files from binary distribution packages +To update the configuration files from binary distribution sets do something like this: .Pp -.Dl mkdir /tmp/etc -.Dl cd /tmp/etc -.Dl tar xf /some/where/etc.tgz -.Dl etcupdate -b -s /tmp/etc -.Pp -The -.Fl b -flag tells -.Nm -that the source directory does not have any -.Pa etc/Makefile -but the files from the binary distribution set(s). +.Dl mkdir /tmp/temproot +.Dl cd /tmp/temproot +.Dl tar xzf /some/where/etc.tgz +.Dl etcupdate -b /tmp/temproot .Pp To get a better idea what's going on, use the .Fl v |