svn commit: r186938 - stable/6/usr.sbin/mergemaster
Doug Barton
dougb at FreeBSD.org
Fri Jan 9 03:21:27 PST 2009
Author: dougb
Date: Fri Jan 9 11:21:25 2009
New Revision: 186938
URL: http://svn.freebsd.org/changeset/base/186938
Log:
MFC the changes from r179725, documentation of the AUTO_UPGRADE knob,
and 186677:186749:
o Removal of 184781, 184804, and 184832 (automatic installation of files
that differ only by VCS Id)
o Fix cross-platform builds
o Various improvements to the mtree (-U) feature
o Remove the last of the MAKEDEV stuff
o Switch to using the top level (e.g., /usr/src) Makefile, and specify
that we should use the *.mk files from the source directory instead of
the installed versions.
o Check for the deprecated 'nodev' option in /etc/fstab
o Add support for the IGNORE_FILES variable
o Before installing a file check to make sure that the target does not
already exist as a directory
o Check to be sure that the file installed and error out if not
o We only need to check for the presence of the target of $PAGER
if that variable is actually set
Modified:
stable/6/usr.sbin/mergemaster/ (props changed)
stable/6/usr.sbin/mergemaster/mergemaster.8
stable/6/usr.sbin/mergemaster/mergemaster.sh
Modified: stable/6/usr.sbin/mergemaster/mergemaster.8
==============================================================================
--- stable/6/usr.sbin/mergemaster/mergemaster.8 Fri Jan 9 11:20:51 2009 (r186937)
+++ stable/6/usr.sbin/mergemaster/mergemaster.8 Fri Jan 9 11:21:25 2009 (r186938)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 1998-2003 Douglas Barton
+.\" Copyright (c) 1998-2009 Douglas Barton
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 4, 2006
+.Dd January 2, 2009
.Dt MERGEMASTER 8
.Os
.Sh NAME
@@ -32,14 +32,14 @@
.Nd merge configuration files, et al during an upgrade
.Sh SYNOPSIS
.Nm
-.Op Fl scrvahipCPU
+.Op Fl achiprsvCPU
+.Op Fl A Ar Target architecture
+.Op Fl D Ar /destdir/path
.Op Fl m Ar /path/to/sources
.Op Fl t Ar /path/to/temp/root
.Op Fl d
.Op Fl u Ar N
.Op Fl w Ar N
-.Op Fl A Ar architecture
-.Op Fl D Ar /path
.Sh DESCRIPTION
The
.Nm
@@ -54,7 +54,7 @@ recommended that you back up your
directory before beginning this process.
.Pp
The script uses
-.Pa /usr/src/etc/Makefile
+.Pa /usr/src/Makefile
to build a temporary root environment from
.Pa /
down, populating that environment with the various
@@ -218,6 +218,14 @@ Specify the path to the directory where
.Xr make 1 .
(In other words, where your sources are, but -s was already
taken.)
+In previous versions of
+.Nm
+you needed to specify the path all the way to
+.Pa src/etc .
+Starting with r186678 you only need to specify the path to
+.Pa src .
+.Nm
+will convert the path for you if you use the old method.
.It Fl t Ar /path/to/temp/root
Create the temporary root environment in
.Pa /path/to/temp/root
@@ -236,7 +244,7 @@ Supply an alternate screen width to the
.Xr sdiff 1
command in numbers of columns.
The default is 80.
-.It Fl A Ar architecture
+.It Fl A Ar Target architecture
Specify an alternative
.Ev TARGET_ARCH
architecture name.
@@ -294,24 +302,33 @@ with all values commented out:
# These are options for mergemaster, with their default values listed
# The following options have command line overrides
#
+# The target architecture (unset by default)
+#ARCHSTRING='TARGET_ARCH=<foo>'
+#
+# Sourcedir is the directory to do the 'make' in (where the new files are)
+#SOURCEDIR='/usr/src'
+#
# Directory to install the temporary root environment into
#TEMPROOT='/var/tmp/temproot'
#
+# Specify the destination directory for the installed files
+#DESTDIR=
+#
# Strict comparison bypasses the CVS $Id tests and compares every file
#STRICT=no
#
# Type of diff, such as unified, context, etc.
#DIFF_FLAG='-u'
#
-# Additional options for diff. This will get unset when using -s.
-#DIFF_OPTIONS='-I$\&FreeBSD:.*[$]' # Ignores CVS Id tags
-#
# Verbose mode includes more details and additional checks
#VERBOSE=
#
# Automatically install files that do not exist on the system already
#AUTO_INSTALL=
#
+# Automatically upgrade files that have not been user modified
+#AUTO_UPGRADE=
+#
# Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf
#COMP_CONFS=yes
#
@@ -319,25 +336,26 @@ with all values commented out:
#PRESERVE_FILES=yes
#PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
#
-# Sourcedir is the directory to do the 'make' in (where the new files are)
-#SOURCEDIR='/usr/src/etc'
-#
# The umask for mergemaster to compare the default file's modes to
#NEW_UMASK=022
#
-# Specify the destination directory for the installed files
-#DESTDIR=
-#
# The following options have no command line overrides
+#
+# Files to always avoid comparing
+#IGNORE_FILES='/etc/motd /etc/printcap foo bar'
+#
+# Additional options for diff. This will get unset when using -s.
+#DIFF_OPTIONS='-I$\&FreeBSD:.*[$]' # Ignores CVS Id tags
+#
+# Location to store the list of mtree values for AUTO_UPGRADE purposes
+#MTREEDB='/var/db'
+#
# For those who just cannot stand including the full path to PAGER
#DONT_CHECK_PAGER=
#
# If you set 'yes' above, make sure to include the PATH to your pager
#PATH=/bin:/usr/bin:/usr/sbin
#
-# Don't compare the old and new motd files
-#IGNORE_MOTD=yes
-#
# Specify the path to scripts to run before the comparison starts,
# and/or after the script has finished its work
#MM_PRE_COMPARE_SCRIPT=
@@ -354,6 +372,11 @@ Invalid command line option
Failure to create the temporary root environment
.Pp
Failure to populate the temporary root
+.Pp
+Presence of the 'nodev' option in
+.Pa <DESTDIR>/etc/fstab
+.Pp
+Failure to install a file
.Sh EXAMPLES
Typically all you will need to do is type
.Nm
Modified: stable/6/usr.sbin/mergemaster/mergemaster.sh
==============================================================================
--- stable/6/usr.sbin/mergemaster/mergemaster.sh Fri Jan 9 11:20:51 2009 (r186937)
+++ stable/6/usr.sbin/mergemaster/mergemaster.sh Fri Jan 9 11:21:25 2009 (r186938)
@@ -5,7 +5,7 @@
# Compare files created by /usr/src/etc/Makefile (or the directory
# the user specifies) with the currently installed copies.
-# Copyright 1998-2004 Douglas Barton
+# Copyright 1998-2009 Douglas Barton
# DougB at FreeBSD.org
# $FreeBSD$
@@ -244,10 +244,6 @@ press_to_continue () {
#
TEMPROOT='/var/tmp/temproot'
-# Assign the location of the mtree database
-#
-MTREEDB='/var/db/mergemaster.mtree'
-
# Read /etc/mergemaster.rc first so the one in $HOME can override
#
if [ -r /etc/mergemaster.rc ]; then
@@ -260,12 +256,17 @@ if [ -r "$HOME/.mergemasterrc" ]; then
. "$HOME/.mergemasterrc"
fi
+# Assign the location of the mtree database
+#
+MTREEDB=${MTREEDB:-/var/db}
+MTREEFILE="${MTREEDB}/mergemaster.mtree"
+
# Check the command line options
#
while getopts ":ascrvhipCPm:t:du:w:D:A:U" COMMAND_LINE_ARGUMENT ; do
case "${COMMAND_LINE_ARGUMENT}" in
A)
- ARCHSTRING='MACHINE_ARCH='${OPTARG}
+ ARCHSTRING='TARGET_ARCH='${OPTARG}
;;
U)
AUTO_UPGRADE=yes
@@ -338,10 +339,30 @@ if [ -n "${PRESERVE_FILES}" -a -z "${PRE
PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
fi
-# Check the for the mtree database in DESTDIR.
-if [ ! -f ${DESTDIR}${MTREEDB} ]; then
- echo "*** Unable to find mtree database. Skipping auto-upgrade."
- unset AUTO_UPGRADE
+# Check for the mtree database in DESTDIR
+case "${AUTO_UPGRADE}" in
+'') ;; # If the option is not set no need to run the test or warn the user
+*)
+ if [ ! -f "${DESTDIR}${MTREEFILE}" ]; then
+ echo ''
+ echo "*** Unable to find mtree database. Skipping auto-upgrade."
+ echo ''
+ press_to_continue
+ unset AUTO_UPGRADE
+ fi
+ ;;
+esac
+
+if [ -e "${DESTDIR}/etc/fstab" ]; then
+ if grep -q nodev ${DESTDIR}/etc/fstab; then
+ echo ''
+ echo "*** You have the deprecated 'nodev' option in ${DESTDIR}/etc/fstab."
+ echo " This can prevent the filesystem from being mounted on reboot."
+ echo " Please update your fstab before continuing."
+ echo " See fstab(5) for more information."
+ echo ''
+ exit 1
+ fi
fi
echo ''
@@ -350,7 +371,8 @@ echo ''
#
case "${DONT_CHECK_PAGER}" in
'')
- while ! type "${PAGER%% *}" >/dev/null && [ -n "${PAGER}" ]; do
+check_pager () {
+ while ! type "${PAGER%% *}" >/dev/null; do
echo " *** Your PAGER environment variable specifies '${PAGER}', but"
echo " due to the limited PATH that I use for security reasons,"
echo " I cannot execute it. So, what would you like to do?"
@@ -392,6 +414,10 @@ case "${DONT_CHECK_PAGER}" in
esac
echo ''
done
+}
+ if [ -n "${PAGER}" ]; then
+ check_pager
+ fi
;;
esac
@@ -412,14 +438,25 @@ DIFF_FLAG=${DIFF_FLAG:--u}
# Assign the source directory
#
-SOURCEDIR=${SOURCEDIR:-/usr/src/etc}
+SOURCEDIR=${SOURCEDIR:-/usr/src}
+if [ ! -f ${SOURCEDIR}/Makefile.inc1 -a \
+ -f ${SOURCEDIR}/../Makefile.inc1 ]; then
+ echo " *** The source directory you specified (${SOURCEDIR})"
+ echo " will be reset to ${SOURCEDIR}/.."
+ echo ''
+ sleep 3
+ SOURCEDIR=${SOURCEDIR}/..
+fi
+
+# Setup make to use system files from SOURCEDIR
+MM_MAKE="make ${ARCHSTRING} -m ${SOURCEDIR}/share/mk"
# Check DESTDIR against the mergemaster mtree database to see what
# files the user changed from the reference files.
#
CHANGED=
-if [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEDB}" ]; then
- for file in `mtree -eq -f ${DESTDIR}${MTREEDB} -p ${DESTDIR}/ \
+if [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEFILE}" ]; then
+ for file in `mtree -eq -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
2>/dev/null | awk '($2 == "changed") {print $1}'`; do
if [ -f "${DESTDIR}/$file" ]; then
CHANGED="${CHANGED} ${DESTDIR}/$file"
@@ -552,14 +589,14 @@ case "${RERUN}" in
case "${DESTDIR}" in
'') ;;
*)
- make DESTDIR=${DESTDIR} ${ARCHSTRING} distrib-dirs
+ ${MM_MAKE} DESTDIR=${DESTDIR} distrib-dirs
;;
esac
- make DESTDIR=${TEMPROOT} ${ARCHSTRING} distrib-dirs &&
- MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} obj &&
- MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} all &&
- MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} \
- DESTDIR=${TEMPROOT} distribution;} ||
+ od=${TEMPROOT}/usr/obj
+ ${MM_MAKE} DESTDIR=${TEMPROOT} distrib-dirs &&
+ MAKEOBJDIRPREFIX=$od ${MM_MAKE} _obj SUBDIR_OVERRIDE=etc &&
+ MAKEOBJDIRPREFIX=$od ${MM_MAKE} everything SUBDIR_OVERRIDE=etc &&
+ MAKEOBJDIRPREFIX=$od ${MM_MAKE} DESTDIR=${TEMPROOT} distribution;} ||
{ echo '';
echo " *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to";
echo " the temproot environment";
@@ -569,8 +606,8 @@ case "${RERUN}" in
*)
# Only set up files that are crucial to {build|install}world
{ mkdir -p ${TEMPROOT}/etc &&
- cp -p ${SOURCEDIR}/master.passwd ${TEMPROOT}/etc &&
- cp -p ${SOURCEDIR}/group ${TEMPROOT}/etc;} ||
+ cp -p ${SOURCEDIR}/etc/master.passwd ${TEMPROOT}/etc &&
+ cp -p ${SOURCEDIR}/etc/group ${TEMPROOT}/etc;} ||
{ echo '';
echo ' *** FATAL ERROR: Cannot copy files to the temproot environment';
echo '';
@@ -599,17 +636,17 @@ case "${RERUN}" in
esac
# Avoid comparing the motd if the user specifies it in .mergemasterrc
+ # Compatibility shim to be removed in FreeBSD 9.x
case "${IGNORE_MOTD}" in
'') ;;
- *) rm -f ${TEMPROOT}/etc/motd
+ *) IGNORE_FILES="${IGNORE_FILES} /etc/motd"
;;
esac
- # Avoid trying to update MAKEDEV if /dev is on a devfs
- if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
- rm -f ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local
- fi
-
+ # Avoid comparing the following user specified files
+ for file in ${IGNORE_FILES}; do
+ test -e ${TEMPROOT}/${file} && unlink ${TEMPROOT}/${file}
+ done
;; # End of the "RERUN" test
esac
@@ -626,9 +663,9 @@ find ${TEMPROOT}/usr/obj -type f -delete
find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null
# Build the mtree database in a temporary location.
-# TODO: Possibly use mktemp instead for security reasons?
+MTREENEW=`mktemp -t mergemaster.mtree`
case "${PRE_WORLD}" in
-'') mtree -ci -p ${TEMPROOT} -k size,md5digest > ${DESTDIR}${MTREEDB}.new 2>/dev/null
+'') mtree -ci -p ${TEMPROOT} -k size,md5digest > ${DESTDIR}${MTREENEW} 2>/dev/null
;;
*) # We don't want to mess with the mtree database on a pre-world run.
;;
@@ -647,7 +684,7 @@ if [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN
echo ''
echo " *** Your umask is currently set to ${USER_UMASK}. By default, this script"
echo " installs all files with the same user, group and modes that"
- echo " they are created with by ${SOURCEDIR}/Makefile, compared to"
+ echo " they are created with by ${SOURCEDIR}/etc/Makefile, compared to"
echo " a umask of 022. This umask allows world read permission when"
echo " the file's default permissions have it."
echo ''
@@ -714,6 +751,12 @@ esac
# Use the umask/mode information to install the files
# Create directories as needed
#
+install_error () {
+ echo "*** FATAL ERROR: Unable to install ${1} to ${2}"
+ echo ''
+ exit 1
+}
+
do_install_and_rm () {
case "${PRESERVE_FILES}" in
[Yy][Ee][Ss])
@@ -724,8 +767,15 @@ do_install_and_rm () {
;;
esac
- install -m "${1}" "${2}" "${3}" &&
- rm -f "${2}"
+ if [ ! -d "${3}/${2##*/}" ]; then
+ if install -m ${1} ${2} ${3}; then
+ unlink ${2}
+ else
+ install_error ${2} ${3}
+ fi
+ else
+ install_error ${2} ${3}
+ fi
}
# 4095 = "obase=10;ibase=8;07777" | bc
@@ -828,11 +878,6 @@ mm_install () {
;;
esac
else # File matched -x
- case "${1#.}" in
- /dev/MAKEDEV)
- NEED_MAKEDEV=yes
- ;;
- esac
do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
fi
return $?
@@ -904,7 +949,7 @@ if [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; th
fi
# Using -size +0 avoids uselessly checking the empty log files created
-# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does
+# by ${SOURCEDIR}/etc/Makefile and the device entries in ./dev, but does
# check the scripts in ./dev, as we'd like (assuming no devfs of course).
#
for COMPFILE in `find . -type f -size +0`; do
@@ -947,25 +992,6 @@ for COMPFILE in `find . -type f -size +0
echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
rm "${COMPFILE}"
;;
-
- *)
- tempfoo=`basename $0`
- TMPFILE1=`mktemp -t ${tempfoo}` || break
- TMPFILE2=`mktemp -t ${tempfoo}` || break
- sed "s/[$]${CVS_ID_TAG}:.*[$]//g" "${DESTDIR}${COMPFILE#.}" > "${TMPFILE1}"
- sed "s/[$]${CVS_ID_TAG}:.*[$]//g" "${COMPFILE}" > "${TMPFILE2}"
- if diff -q ${DIFF_OPTIONS} "${TMPFILE1}" "${TMPFILE2}" > \
- /dev/null 2>&1; then
- echo " *** Temp ${COMPFILE} and installed are the same except CVS Id, replacing"
- if mm_install "${COMPFILE}"; then
- echo " *** ${COMPFILE} upgraded successfully"
- echo ''
- else
- echo " *** Problem upgrading ${COMPFILE}, it will remain to merge by hand"
- fi
- fi
- rm -f "${TMPFILE1}" "${TMPFILE2}"
- ;;
esac
;;
esac
@@ -1005,9 +1031,10 @@ done # This is for the do way up there a
echo ''
echo "*** Comparison complete"
-if [ -f "${DESTDIR}${MTREEDB}.new" ]; then
+if [ -f "${DESTDIR}${MTREENEW}" ]; then
echo "*** Saving mtree database for future upgrades"
- mv -f ${DESTDIR}${MTREEDB}.new ${DESTDIR}${MTREEDB} 2>/dev/null
+ test -e "${MTREEFILE}" && unlink ${MTREEFILE}
+ mv ${DESTDIR}${MTREENEW} ${DESTDIR}${MTREEFILE}
fi
echo ''
@@ -1115,16 +1142,6 @@ run_it_now () {
esac
}
-case "${NEED_MAKEDEV}" in
-'') ;;
-*)
- echo ''
- echo "*** You installed a new ${DESTDIR}/dev/MAKEDEV script, so make sure that you run"
- echo " 'cd ${DESTDIR}/dev && /bin/sh MAKEDEV all' to rebuild your devices"
- run_it_now "cd ${DESTDIR}/dev && /bin/sh MAKEDEV all"
- ;;
-esac
-
case "${NEED_NEWALIASES}" in
'') ;;
*)
@@ -1206,7 +1223,7 @@ esac
case "${PRE_WORLD}" in
'') ;;
*)
- MAKE_CONF="${SOURCEDIR%etc}share/examples/etc/make.conf"
+ MAKE_CONF="${SOURCEDIR}/share/examples/etc/make.conf"
(echo ''
echo '*** Comparing make variables'
More information about the svn-src-all
mailing list