diff options
| author | apb <apb@NetBSD.org> | 2007-03-26 18:11:03 +0000 |
|---|---|---|
| committer | apb <apb@NetBSD.org> | 2007-03-26 18:11:03 +0000 |
| commit | 46e1ba7e4ee5da467ed6f8a920bbe7eab7205c9b (patch) | |
| tree | 5ddd3a98fb05a8224e877c7f821e92f59d153f89 /usr.sbin/etcupdate | |
| parent | bc4861bd29956a3992b617a342c256bbd39629d3 (diff) | |
* Make etcupdate's -s option accept a colon-separated list of tgz
files. (It was already possible to use several -s options.)
* Change man page to refer to "-s tgzdir" instead of "-s tempdir",
to reduce confusion between tempdir and temproot.
* Always use a temproot directory, even if passed "-s tgzdir".
* Always invoke "postinstall check", even when not using a source dir.
* Add a BUGS section saying that using -s srcdir is not recommended.
Reviewed by lukem and martti.
Diffstat (limited to 'usr.sbin/etcupdate')
| -rw-r--r-- | usr.sbin/etcupdate/etcupdate | 61 | ||||
| -rw-r--r-- | usr.sbin/etcupdate/etcupdate.8 | 125 |
2 files changed, 121 insertions, 65 deletions
diff --git a/usr.sbin/etcupdate/etcupdate b/usr.sbin/etcupdate/etcupdate index dbe09029b71..20b32b808f5 100644 --- a/usr.sbin/etcupdate/etcupdate +++ b/usr.sbin/etcupdate/etcupdate @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: etcupdate,v 1.33 2007/03/03 06:44:38 apb Exp $ +# $NetBSD: etcupdate,v 1.34 2007/03/26 18:11:03 apb Exp $ # # Copyright (c) 2001 The NetBSD Foundation, Inc. # All rights reserved. @@ -66,6 +66,7 @@ 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 +SRC_ARG= # argument for "-s" AUTOMATIC=false LOCALSKIP=false MACHINE="${MACHINE:=`uname -m`}" @@ -90,10 +91,11 @@ Options: -p pager Which pager to use (default: /usr/bin/more) -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: + Location of the source files. 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 distribution set file such as "etc.tgz" or + "xetc.tgz", or a colon-separated list of such files; * 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) @@ -406,6 +408,7 @@ EOF BINARYMODE=true BINARYDIRMODE=true BINARYDIR="${arg}" + SRC_ARG="${BINARYDIR}" ;; -h) usage @@ -425,18 +428,21 @@ EOF # -s extracted_dir arg="${2}" shift 2 - if [ -f "${arg}" ]; then - # arg refers to a *.tgz file. + if [ -f "${arg%%:*}" ]; then + # arg refers to a *.tgz file, or a colon-separated + # list. # 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}" + SRC_ARG="${TGZLIST}" elif [ -d "${arg}" ] && [ -f "${arg}/etc/Makefile" ]; then # arg refers to a source directory SOURCEMODE=true SRCDIR="${arg}" + SRC_ARG="${SRCDIR}" elif [ -d "${arg}" ] && [ -f "${arg}/../etc/Makefile" ]; then # backward compatibility: allow arg to refer to # etc subdirectory within source dir. @@ -447,6 +453,7 @@ EOF EOF SOURCEMODE=true SRCDIR="${arg}/.." + SRC_ARG="${SRCDIR}" elif [ -d "${arg}" ] && [ -d "${ARG}/etc" ] \ && ! [ -f "${arg}/etc/Makefile" ] then @@ -455,7 +462,9 @@ EOF BINARYMODE=true BINARYDIRMODE=true BINARYDIR="${arg}" + SRC_ARG="${BINARYDIR}" else + echo "*** Cannot understand -s ${arg}" usage fi ;; @@ -490,8 +499,7 @@ if ${BINARYDIRMODE} && ${BINARYTGZMODE}; then usage fi if ${BINARYDIRMODE}; then - SRCDIR="${BINARYDIR}" - TEMPROOT="${BINARYDIR}" + SRCDIR="${TEMPROOT}" fi if ${BINARYTGZMODE}; then SRCDIR="${TEMPROOT}" @@ -500,6 +508,7 @@ if ! ${SOURCEMODE} && ! ${BINARYMODE}; then # default if no "-s" option was specified SOURCEMODE=true SRCDIR=/usr/src + SRC_ARG="${SRCDIR}" fi if [ -z "${SRCDIR}" -o -z "${TEMPROOT}" ]; then echo "*** ERROR: One of the following variables is undefined" @@ -509,7 +518,7 @@ if [ -z "${SRCDIR}" -o -z "${TEMPROOT}" ]; then echo "" exit 1 fi -if ! ${BINARYDIRMODE} && [ -r "${TEMPROOT}" ]; then +if [ -r "${TEMPROOT}" ]; then echo "" echo "*** WARNING: ${TEMPROOT} already exists" echo "" @@ -522,16 +531,14 @@ if ! ${BINARYDIRMODE} && [ -r "${TEMPROOT}" ]; then fi if ! ${CONTINUE}; then - # Are we using the sources or binaries? - if ! ${BINARYDIRMODE}; then - # Create the temporary root directory - echo "*** Creating ${TEMPROOT}" - mkdir -p "${TEMPROOT}" - if [ ! -d "${TEMPROOT}" ]; then - echo "*** ERROR: Unable to create ${TEMPROOT}" - exit 1 - fi + # Create the temporary root directory + echo "*** Creating ${TEMPROOT}" + mkdir -p "${TEMPROOT}" + if [ ! -d "${TEMPROOT}" ]; then + echo "*** ERROR: Unable to create ${TEMPROOT}" + exit 1 fi + # Are we using the sources or binaries? if ${BINARYTGZMODE}; then # Populate ${TEMPROOT} from ${TGZLIST} oldIFS="${IFS}" @@ -546,14 +553,19 @@ if ! ${CONTINUE}; then [ $? -ne 0 ] && exit 1 done IFS="${oldIFS}" - elif ! ${BINARYMODE}; then - # Populate ${TEMPROOT} from ${SRCDIR} + elif ${BINARYDIRMODE}; then + # Populate ${TEMPROOT} from ${SRCDIR} by copying + echo "*** Populating ${TEMPROOT} from ${BINARYDIR} (copying)" + cp -RPp "${BINARYDIR}"/* "${TEMPROOT}"/ + [ $? -ne 0 ] && exit 1 + elif ${SOURCEMODE}; then + # Populate ${TEMPROOT} from ${SRCDIR} by running make if [ ! -f "${SRCDIR}/etc/Makefile" ]; then echo "*** ERROR: Unable to find ${SRCDIR}/etc/Makefile" exit 1 fi set_makeenv - echo "*** Populating ${TEMPROOT} from ${SRCDIR}" + echo "*** Populating ${TEMPROOT} from ${SRCDIR} (make distribution)" cd ${SRCDIR}/etc if ! ${VERBOSE}; then eval ${MAKE_ENV} make distribution > /dev/null @@ -620,7 +632,7 @@ else fi # Clean up after "make distribution" -if ! ${BINARYMODE}; then +if ${SOURCEMODE}; then echo "*** Cleaning up in ${SRCDIR}/etc" set_makeenv cd ${SRCDIR}/etc @@ -678,9 +690,8 @@ if ${NEED_NEWALIASES}; then echo "" fi fi -if [ -x /usr/sbin/postinstall ] && ! ${BINARYMODE}; then - # XXX we should also run postinstall in binary mode +if [ -x /usr/sbin/postinstall ]; then echo "*** Running /usr/sbin/postinstall" - /usr/sbin/postinstall -s "${SRCDIR}" check + /usr/sbin/postinstall -s "${SRC_ARG}" check fi echo "*** All done" diff --git a/usr.sbin/etcupdate/etcupdate.8 b/usr.sbin/etcupdate/etcupdate.8 index 6afc95f8026..8982f151bf8 100644 --- a/usr.sbin/etcupdate/etcupdate.8 +++ b/usr.sbin/etcupdate/etcupdate.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: etcupdate.8,v 1.12 2006/08/11 20:28:22 hubertf Exp $ +.\" $NetBSD: etcupdate.8,v 1.13 2007/03/26 18:11:03 apb 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 February 18, 2006 +.Dd March 25, 2007 .Dt ETCUPDATE 8 .Os .Sh NAME @@ -45,7 +45,7 @@ .Nm .Op Fl ahlv .Op Fl p Ar pager -.Op Fl s Brq Ar srcdir | Ar tgzfile | Ar tempdir +.Op Fl s Brq Ar srcdir | Ar tgzdir | Ar tgzfile .Op Fl t Ar temproot .Op Fl w Ar width .Sh DESCRIPTION @@ -77,6 +77,11 @@ corresponding tasks like remaking device nodes or rebuilding a database from the .Xr aliases 5 file. +Finally, +.Nm +runs +.Xr postinstall 8 +to check the results. .Pp .Nm needs a clean set of new configuration files to compare the @@ -101,11 +106,15 @@ installing the files to a so-called and .Fl t Ar temproot options later in this manual page.) +Although this is the default mode, it is not recommended +(see the +.Dq BUGS +section). .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 s Ar tempdir +Instead of using sources, it is recommended that the user should extract +one or more binary distribution sets in a special location and use those +as the reference files (see usage of the +.Fl s Ar tgzdir option later in this manual page), or specify one or more binary distribution sets directly (see usage of the @@ -145,22 +154,27 @@ but it can be changed either with this option or by defining the .Ev PAGER variable. -.It Fl s Brq Ar srcdir | Ar tgzfile | Ar tempdir +.It Fl s Brq Ar srcdir | Ar tgzdir | Ar tgzfile 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 +.Bl -tag -width XXsXtgzfileXX .It Fl s Ar srcdir -The location of the +The top level directory of the .Nx -source files used to create the reference files. +source tree. By default this is .Pa /usr/src but it can be changed either with this option or the .Ev SRCDIR variable. +The reference files will be created by running +.Dq "make distribution" +in the +.Ar srcdir Ns Pa /etc +directory. Note that .Ar srcdir should refer to the top of the source directory tree; @@ -171,53 +185,63 @@ expected to refer to the .Pa etc subdirectory within the source tree. +.It Fl s Ar tgzdir +A directory in which reference files have been +extracted from one or more of the +.Dq Pa etc.tgz +or +.Dq Pa xetc.tgz +files from a binary distribution of +.Nx . +The reference files from the specified directory will be copied to the +.Pa temproot +directory. .It Fl s Ar tgzfile -The location of a set file from a binary distribution of +The location of one or more set files +(or +.Dq "tgz files" ) +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 +Each set file is a compressed archive containing reference files. +More than one set file may be specified, either by +using a single +.Fl s +option with a colon-separated list of +.Ar tgzfile +names, or by using multiple +.Fl s +options; this is likely to be useful to specify the locations of both the .Pa etc.tgz and .Pa xetc.tgz -sets. +set files. +Note that file names may not contain embedded colon +.Pq Ql \&: +characters, because that would conflict with the use of the colon +character to delimit multiple file names with a single argument. 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 Specifies the location of the .Pa temproot directory. -The temporary reference files created from -the source directory specified by +This directory will be used for a temporary copy of +the reference files created by running +.Dq "make distribution" +in the source directory specified by .Fl s Ar srcdir , -or the temporary reference files extracted from -the binary tgz sets specified by +or a temporary copy of the reference files extracted from +the binary sets specified by .Fl s Ar tgzfile , -will be stored there. +or a temporary copy of the reference files from the directory specified by +.Fl s Ar tempdir . By default this is .Pa /tmp/temproot but can be changed either with this option or the .Ev TEMPROOT environment variable. -It is an error to specify -.Fl t Ar temproot -in conjunction with -.Fl s Ar tempdir . .It Fl v Makes .Nm @@ -341,7 +365,7 @@ the option was added, the .Fl b Ar tempdir option was converted to -.Fl s Ar tempdir , +.Fl s Ar tgzdir , and the .Fl s Ar srcdir option was changed to refer to the top of the @@ -370,7 +394,28 @@ 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 +.Sh BUGS +If a source directory is specified via the +.Dq Fl s Ar srcdir +option (or if the +.Pa /usr/src +directory is used by default), then +.Nm +will run +.Dq "make distribution" +in the +.Pa etc +subdirectory of the source directory, but it will not use the same +options or environment variables that would be used during a full build +of the operating system. +For this reason, use of the +.Dq Fl s Ar srcdir +option is not recommended, and use of the +.Dq Fl s Ar tgzdir +or +.Dq Fl s Ar tgzfile +options is recommended. +.\" .Pp .\" Because of the use of .\" .Xr cmp 1 .\" to compare files, rather than CVS versions, files that are locally changed |
