Add several new features, reorder some code, and continue with the

process of making the script more cross platform friendly.

* Add -i option to automatically install files that do not exist
  on the system already.
* Add the ability to specify DESTDIR.
* Allow the user to specify scripts to run right before the
  comparison starts, and when mm is done. This will
  allow the user to specify customized local behavior, and
  implement features such as automatically deleting files.
* Document the above changes in the man page.
* Switch to using 'ident' for the CVS Id comparison, which
  should help with portability, and makes it faster.
* Reorder, and in one case fix some code by doing things in
  ways that make more sense.
* Check to see if the file exists on the system before doing
  the comparisons. This saves CPU cycles, and streamlines
  the auto-install process.

I used bits and pieces of suggestions and patches from various
people, ultimately too numerous to name. Which is not to say
that they were not both appreciated, and helpful in achieving
the ultimate result.
This commit is contained in:
Doug Barton 2000-10-30 10:33:51 +00:00
parent d75c9e3a48
commit d5a5b144b6
2 changed files with 194 additions and 97 deletions

View File

@ -24,7 +24,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 10, 1999 .Dd October 30, 2000
.Dt MERGEMASTER 8 .Dt MERGEMASTER 8
.Os FreeBSD .Os FreeBSD
.Sh NAME .Sh NAME
@ -32,12 +32,13 @@
.Nd Merge configuration files, et al during an upgrade .Nd Merge configuration files, et al during an upgrade
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl scrvah .Op Fl scrvahi
.Op Fl m Ar /path/to/sources .Op Fl m Ar /path/to/sources
.Op Fl t Ar /path/to/temp/root .Op Fl t Ar /path/to/temp/root
.Op Fl d .Op Fl d
.Op Fl u Ar N .Op Fl u Ar N
.Op Fl w Ar N .Op Fl w Ar N
.Op Fl D Ar /path
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
is a Bourne shell script which is designed to aid you is a Bourne shell script which is designed to aid you
@ -58,7 +59,10 @@ files.
You can specify a different source directory You can specify a different source directory
with the with the
.Op Fl m .Op Fl m
command line option. command line option, or specify the destination
directory with the
.Op Fl D
option.
It then compares each file in that environment It then compares each file in that environment
to its installed counterpart. to its installed counterpart.
When the script finds a When the script finds a
@ -113,6 +117,26 @@ and file permissions as specified by the umask.
Unified diffs are used by default to display any Unified diffs are used by default to display any
differences unless you choose context diffs. differences unless you choose context diffs.
.Pp .Pp
.Nm
will source scripts that you specify right before
it starts the comparison, and after it's done running.
The easiest way to handle this is to place the path
to the script(s) in the appropriate variables in your
.Pa .mergemasterrc
file.
The script sourced before comparison is named in
.Ev MM_PRE_COMPARE_SCRIPT ,
and the one sourced after the script is done is
.Ev MM_EXIT_SCRIPT .
This is the recommended way to specify local modifications,
or files that you want to give special handling to.
This includes files that you want to be deleted without
being compared.
Because the named scripts are sourced from within
.Nm ,
all of the script's variables are available for use in
your custom script.
.Pp
The options are as follows: The options are as follows:
.Bl -tag -width Fl .Bl -tag -width Fl
.It Fl s .It Fl s
@ -149,6 +173,9 @@ Setting -a makes
-w superfluous. -w superfluous.
.It Fl h .It Fl h
Display usage and help information. Display usage and help information.
.It Fl i
Automatically install any files that do not exist in the
destination directory.
.It Fl m Ar /path/to/sources .It Fl m Ar /path/to/sources
Specify the path to the directory where you want to do the Specify the path to the directory where you want to do the
.Xr make 1 . .Xr make 1 .
@ -172,6 +199,8 @@ Supply an alternate screen width to the
.Xr sdiff 1 .Xr sdiff 1
command in numbers of columns. command in numbers of columns.
The default is 80. The default is 80.
.It Fl D Ar /path
Specify the destination directory for the installed files.
.El .El
.Sh ENVIRONMENT .Sh ENVIRONMENT
The The
@ -190,6 +219,15 @@ limited
without specifying the full path, without specifying the full path,
.Nm .Nm
prompts you with options on how to proceed. prompts you with options on how to proceed.
The
.Ev MM_PRE_COMPARE_SCRIPT
and
.Ev MM_EXIT_SCRIPT
variables are used as described above.
Other variables that are used by the script internally
can be specified in
.Pa .mergemasterrc
as described in more detail below.
.Sh EXAMPLES .Sh EXAMPLES
Typically all you will need to do is type Typically all you will need to do is type
.Nm .Nm
@ -240,19 +278,33 @@ with all values commented out:
# Verbose mode includes more details and additional checks # Verbose mode includes more details and additional checks
#VERBOSE= #VERBOSE=
# #
# Automatically install files that do not exist on the system already
#AUTO_INSTALL=
#
# Sourcedir is the directory to do the 'make' in (where the new files are) # Sourcedir is the directory to do the 'make' in (where the new files are)
#SOURCEDIR=/usr/src/etc #SOURCEDIR='/usr/src/etc'
# #
# The umask for mergemaster to compare the default file's modes to # The umask for mergemaster to compare the default file's modes to
#NEW_UMASK=022 #NEW_UMASK=022
# #
# Specify the destination directory for the installed files
#DESTDIR=
#
# The following options have no command line overrides # The following options have no command line overrides
# For those who just cannot stand including the full path to PAGER # For those who just cannot stand including the full path to PAGER
#DONT_CHECK_PAGER= #DONT_CHECK_PAGER=
#
# If you set 'yes' above, make sure to include the PATH to your pager # If you set 'yes' above, make sure to include the PATH to your pager
#PATH=/bin:/usr/bin:/usr/sbin #PATH=/bin:/usr/bin:/usr/sbin:/sbin
#
# Don't compare the old and new motd files # Don't compare the old and new motd files
#IGNORE_MOTD=yes #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=
#MM_EXIT_SCRIPT=
.Ed .Ed
.Sh SEE ALSO .Sh SEE ALSO
.Xr cvs 1 , .Xr cvs 1 ,
@ -291,7 +343,7 @@ make world tutorial which is referenced above.
.Pp .Pp
.Sh AUTHOR .Sh AUTHOR
This manual page and the script itself were written by This manual page and the script itself were written by
.An Douglas Barton Aq Doug@gorean.org . .An Douglas Barton Aq DougB@FreeBSD.org .
.Sh BUGS .Sh BUGS
There are no known bugs. There are no known bugs.
Please report any problems, Please report any problems,

View File

@ -15,7 +15,8 @@ PATH=/bin:/usr/bin:/usr/sbin:/sbin
display_usage () { display_usage () {
VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
echo "mergemaster version ${VERSION_NUMBER}" echo "mergemaster version ${VERSION_NUMBER}"
echo "Usage: mergemaster [-scrvah] [-m /path] [-t /path] [-d] [-u N] [-w N]" echo 'Usage: mergemaster [-scrvahi] [-m /path]'
echo ' [-t /path] [-d] [-u N] [-w N] [-D /path]'
echo "Options:" echo "Options:"
echo " -s Strict comparison (diff every pair of files)" echo " -s Strict comparison (diff every pair of files)"
echo " -c Use context diff instead of unified diff" echo " -c Use context diff instead of unified diff"
@ -23,26 +24,24 @@ display_usage () {
echo " -v Be more verbose about the process, include additional checks" echo " -v Be more verbose about the process, include additional checks"
echo " -a Leave all files that differ to merge by hand" echo " -a Leave all files that differ to merge by hand"
echo " -h Display more complete help" echo " -h Display more complete help"
echo ' -i Automatically install files that do not exist in destination directory'
echo " -m /path/directory Specify location of source to do the make in" echo " -m /path/directory Specify location of source to do the make in"
echo " -t /path/directory Specify temp root directory" echo " -t /path/directory Specify temp root directory"
echo " -d Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)" echo " -d Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)"
echo " -u N Specify a numeric umask" echo " -u N Specify a numeric umask"
echo " -w N Specify a screen width in columns to sdiff" echo " -w N Specify a screen width in columns to sdiff"
echo ' -D /path/directory Specify the destination directory to install files to'
echo '' echo ''
} }
display_help () { display_help () {
echo "* To create a temporary root environment, compare CVS revision \$Ids"
echo " for files that have them, and compare diffs for files that do not,"
echo " or have different ones, just type, mergemaster"
echo "* To specify a directory other than /var/tmp/temproot for the" echo "* To specify a directory other than /var/tmp/temproot for the"
echo " temporary root environment, use -t /path/to/temp/root" echo " temporary root environment, use -t /path/to/temp/root"
echo "* The -w option takes a number as an argument for the column width" echo "* The -w option takes a number as an argument for the column width"
echo " of the screen. The default is 80." echo " of the screen. The default is 80."
echo "* The -a option causes mergemaster to run without prompting" echo '* The -a option causes mergemaster to run without prompting.'
} }
# Loop allowing the user to use sdiff to merge files and display the merged # Loop allowing the user to use sdiff to merge files and display the merged
# file. # file.
merge_loop () { merge_loop () {
@ -58,7 +57,7 @@ merge_loop () {
# Prime file.merged so we don't blat the owner/group id's # Prime file.merged so we don't blat the owner/group id's
cp -p "${COMPFILE}" "${COMPFILE}.merged" cp -p "${COMPFILE}" "${COMPFILE}.merged"
sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \ sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \
--width=${SCREEN_WIDTH:-80} "${COMPFILE#.}" "${COMPFILE}" --width=${SCREEN_WIDTH:-80} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
INSTALL_MERGED=V INSTALL_MERGED=V
while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do
echo '' echo ''
@ -107,18 +106,36 @@ diff_loop () {
HANDLE_COMPFILE=v HANDLE_COMPFILE=v
while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o "${HANDLE_COMPFILE}" = "NOT V" ]; do while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o "${HANDLE_COMPFILE}" = "NOT V" ]; do
if [ -f "${COMPFILE#.}" -a -f "${COMPFILE}" ]; then if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
( (
echo ''
echo " *** Displaying differences between ${COMPFILE} and installed version:" echo " *** Displaying differences between ${COMPFILE} and installed version:"
echo '' echo ''
diff "${DIFF_FLAG}" "${COMPFILE#.}" "${COMPFILE}" diff "${DIFF_FLAG}" "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
) | ${PAGER} ) | ${PAGER}
echo '' echo ''
fi fi
else else
echo ''
echo " *** There is no installed version of ${COMPFILE}" echo " *** There is no installed version of ${COMPFILE}"
NO_INSTALLED=yes case "${AUTO_INSTALL}" in
[Yy][Ee][Ss])
echo ''
if mm_install "${COMPFILE}"; then
echo " *** ${COMPFILE} installed successfully"
# Make the list print one file per line
AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES} ${DESTDIR}${COMPFILE#.}
"
else
echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand"
fi
return
;;
*)
NO_INSTALLED=yes
;;
esac
fi fi
echo " Use 'd' to delete the temporary ${COMPFILE}" echo " Use 'd' to delete the temporary ${COMPFILE}"
@ -179,7 +196,6 @@ diff_loop () {
;; ;;
esac # End of "How to handle files that are different" esac # End of "How to handle files that are different"
done done
echo ''
unset NO_INSTALLED unset NO_INSTALLED
echo '' echo ''
case "${VERBOSE}" in case "${VERBOSE}" in
@ -196,13 +212,13 @@ TEMPROOT='/var/tmp/temproot'
# Read .mergemasterrc before command line so CLI can override # Read .mergemasterrc before command line so CLI can override
# #
if [ -f "$HOME/.mergemasterrc" ]; then if [ -r "$HOME/.mergemasterrc" ]; then
. "$HOME/.mergemasterrc" . "$HOME/.mergemasterrc"
fi fi
# Check the command line options # Check the command line options
# #
while getopts ":ascrvhm:t:du:w:" COMMAND_LINE_ARGUMENT ; do while getopts ":ascrvhim:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do
case "${COMMAND_LINE_ARGUMENT}" in case "${COMMAND_LINE_ARGUMENT}" in
s) s)
STRICT=yes STRICT=yes
@ -227,6 +243,9 @@ while getopts ":ascrvhm:t:du:w:" COMMAND_LINE_ARGUMENT ; do
display_help display_help
exit 0 exit 0
;; ;;
i)
AUTO_INSTALL=yes
;;
m) m)
SOURCEDIR=${OPTARG} SOURCEDIR=${OPTARG}
;; ;;
@ -242,6 +261,9 @@ while getopts ":ascrvhm:t:du:w:" COMMAND_LINE_ARGUMENT ; do
w) w)
SCREEN_WIDTH=${OPTARG} SCREEN_WIDTH=${OPTARG}
;; ;;
D)
DESTDIR=${OPTARG}
;;
*) *)
display_usage display_usage
exit 1 exit 1
@ -406,6 +428,7 @@ case "${RERUN}" in
esac esac
{ cd ${SOURCEDIR} && { cd ${SOURCEDIR} &&
make DESTDIR=${DESTDIR} distrib-dirs &&
make DESTDIR=${TEMPROOT} distrib-dirs && make DESTDIR=${TEMPROOT} distrib-dirs &&
make DESTDIR=${TEMPROOT} -DNO_MAKEDEV distribution;} || make DESTDIR=${TEMPROOT} -DNO_MAKEDEV distribution;} ||
{ echo ''; { echo '';
@ -414,11 +437,33 @@ case "${RERUN}" in
echo ''; echo '';
exit 1;} exit 1;}
# Doing the inventory and removing files that we don't want to compare only makes
# sense if we are not doing a rerun, since we have no way of knowing what happened
# to the files during previous incarnations.
case "${VERBOSE}" in
'') ;;
*)
echo ''
echo ' *** The following files exist only in the installed version of'
echo " ${DESTDIR}/etc. In the vast majority of cases these files"
echo ' are necessary parts of the system and should not be deleted.'
echo ' However because these files are not updated by this process you'
echo ' might want to verify their status before rebooting your system.'
echo ''
echo ' *** Press [Enter] or [Return] key to continue'
read ANY_KEY
unset ANY_KEY
diff -qr ${DESTDIR}/etc ${TEMPROOT}/etc | grep "^Only in /etc" | ${PAGER}
echo ''
echo ' *** Press [Enter] or [Return] key to continue'
read ANY_KEY
unset ANY_KEY
;;
esac
# We really don't want to have to deal with these files, since # We really don't want to have to deal with these files, since
# master.passwd is the real file that should be compared, then # master.passwd is the real file that should be compared, then
# the user should run pwd_mkdb if necessary. # the user should run pwd_mkdb if necessary.
# Only do this if we are not rerun'ing, since if we are the
# files will not be there.
# #
rm ${TEMPROOT}/etc/spwd.db ${TEMPROOT}/etc/passwd ${TEMPROOT}/etc/pwd.db rm ${TEMPROOT}/etc/spwd.db ${TEMPROOT}/etc/passwd ${TEMPROOT}/etc/pwd.db
@ -439,27 +484,6 @@ esac
# Get ready to start comparing files # Get ready to start comparing files
case "${VERBOSE}" in
'') ;;
*)
echo ''
echo " *** The following files exist only in the installed version"
echo " of /etc. In the far majority of cases these files are"
echo " necessary parts of the system and should not be deleted,"
echo " however because these files are not updated by this process"
echo " you might want to verify their status before rebooting your system."
echo ''
echo " *** Press [Enter] or [Return] key to continue"
read ANY_KEY
unset ANY_KEY
diff -qr /etc ${TEMPROOT}/etc | grep "^Only in /etc" | ${PAGER}
echo ''
echo " *** Press [Enter] or [Return] key to continue"
read ANY_KEY
unset ANY_KEY
;;
esac
# Check umask if not specified on the command line, # Check umask if not specified on the command line,
# and we are not doing an autorun # and we are not doing an autorun
# #
@ -490,15 +514,18 @@ fi
CONFIRMED_UMASK=${NEW_UMASK:-0022} CONFIRMED_UMASK=${NEW_UMASK:-0022}
# Warn users who have an /etc/sysconfig file # Warn users who still have ${DESTDIR}/etc/sysconfig
# #
if [ -f /etc/sysconfig ]; then if [ -e "${DESTDIR}/etc/sysconfig" ]; then
echo " *** There is an /etc/sysconfig file on this system. Starting with" echo ''
echo " FreeBSD version 2.2.2 those settings have moved from /etc/sysconfig" echo " *** There is a sysconfig file on this system in ${DESTDIR}/etc/."
echo " to /etc/rc.conf. If you are upgrading an older system make sure" echo ''
echo " that you transfer your settings by hand from sysconfig to rc.conf and" echo ' Starting with FreeBSD version 2.2.2 those settings moved from'
echo " install the rc.conf file. If you have already made this transition," echo ' /etc/sysconfig to /etc/rc.conf. If you are upgrading an older'
echo " you should consider renaming or deleting the /etc/sysconfig file." echo ' system make sure that you transfer your settings by hand from'
echo ' sysconfig to rc.conf and install the rc.conf file. If you'
echo ' have already made this transition, you should consider'
echo ' renaming or deleting the sysconfig file.'
echo '' echo ''
case "${AUTO_RUN}" in case "${AUTO_RUN}" in
'') '')
@ -519,12 +546,6 @@ if [ -f /etc/sysconfig ]; then
esac esac
fi fi
echo ''
echo "*** Beginning comparison"
echo ''
cd "${TEMPROOT}"
# Use the umask/mode information to install the files # Use the umask/mode information to install the files
# Create directories as needed # Create directories as needed
# #
@ -532,24 +553,22 @@ mm_install () {
local INSTALL_DIR local INSTALL_DIR
INSTALL_DIR=${1#.} INSTALL_DIR=${1#.}
INSTALL_DIR=${INSTALL_DIR%/*} INSTALL_DIR=${INSTALL_DIR%/*}
case "${INSTALL_DIR}" in case "${INSTALL_DIR}" in
'') '')
INSTALL_DIR=/ INSTALL_DIR=/
;; ;;
esac esac
if [ -n "${INSTALL_DIR}" -a ! -d "${INSTALL_DIR}" ]; then if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
DIR_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ oct("$ARGV[1]"))' "${TEMPROOT}/${INSTALL_DIR}" "${CONFIRMED_UMASK}"` DIR_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ oct("$ARGV[1]"))' "${TEMPROOT}/${INSTALL_DIR}" "${CONFIRMED_UMASK}"`
install -d -o root -g wheel -m "${DIR_MODE}" "${INSTALL_DIR}" install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
fi fi
FILE_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ oct("$ARGV[1]"))' "${1}" "${CONFIRMED_UMASK}"` FILE_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ oct("$ARGV[1]"))' "${1}" "${CONFIRMED_UMASK}"`
if [ ! -x "${1}" ]; then if [ ! -x "${1}" ]; then
case "${1#.}" in case "${1#.}" in
/dev/MAKEDEV)
NEED_MAKEDEV=yes
;;
/etc/mail/aliases) /etc/mail/aliases)
NEED_NEWALIASES=yes NEED_NEWALIASES=yes
;; ;;
@ -557,7 +576,7 @@ mm_install () {
NEED_CAP_MKDB=yes NEED_CAP_MKDB=yes
;; ;;
/etc/master.passwd) /etc/master.passwd)
install -m 600 "${1}" "${INSTALL_DIR}" install -m 600 "${1}" "${DESTDIR}${INSTALL_DIR}"
NEED_PWD_MKDB=yes NEED_PWD_MKDB=yes
DONT_INSTALL=yes DONT_INSTALL=yes
;; ;;
@ -575,7 +594,7 @@ mm_install () {
esac esac
echo " Use 'd' to delete the temporary ${COMPFILE}" echo " Use 'd' to delete the temporary ${COMPFILE}"
echo " Use 'l' to delete the existing ${COMPFILE#.} and create the link" echo " Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link"
echo '' echo ''
echo " Default is to leave the temporary file to deal with by hand" echo " Default is to leave the temporary file to deal with by hand"
echo '' echo ''
@ -590,14 +609,12 @@ mm_install () {
;; ;;
[lL]*) [lL]*)
echo '' echo ''
if [ -e "${COMPFILE#.}" ]; then rm -f "${DESTDIR}${COMPFILE#.}"
rm "${COMPFILE#.}" if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then
fi echo " *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully"
if ln "/root/${COMPFILE##*/}" "${COMPFILE#.}"; then
echo " *** Link from ${COMPFILE#.} to /root/${COMPFILE##*/} installed successfully"
rm "${COMPFILE}" rm "${COMPFILE}"
else else
echo " *** Error linking ${COMPFILE#.} to /root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand" echo " *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand"
fi fi
;; ;;
*) *)
@ -610,56 +627,68 @@ mm_install () {
case "${DONT_INSTALL}" in case "${DONT_INSTALL}" in
'') '')
install -m "${FILE_MODE}" "${1}" "${INSTALL_DIR}" install -m "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
;; ;;
*) *)
unset DONT_INSTALL unset DONT_INSTALL
;; ;;
esac esac
else else
install -m "${FILE_MODE}" "${1}" "${INSTALL_DIR}" case "${1#.}" in
/dev/MAKEDEV)
NEED_MAKEDEV=yes
;;
esac
install -m "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
fi fi
return $? return $?
} }
compare_ids () { echo ''
case "${1}" in echo "*** Beginning comparison"
"${2}") echo ''
echo " *** Temp ${COMPFILE} and installed have the same ${IDTAG}, deleting"
rm "${COMPFILE}" cd "${TEMPROOT}"
;;
esac if [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then
} . "${MM_PRE_COMPARE_SCRIPT}"
fi
# Using -size +0 avoids uselessly checking the empty log files created # Using -size +0 avoids uselessly checking the empty log files created
# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does # by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does
# check the scripts in ./dev, as we'd like. # check the scripts in ./dev, as we'd like (assuming no devfs of course).
# #
for COMPFILE in `find . -type f -size +0`; do for COMPFILE in `find . -type f -size +0`; do
# First, check to see if the file exists in DESTDIR. If not, the
# diff_loop function knows how to handle it.
#
if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then
diff_loop
continue
fi
case "${STRICT}" in case "${STRICT}" in
'' | [Nn][Oo]) '' | [Nn][Oo])
# Compare CVS $Id's first so if the file hasn't been modified # Compare CVS $Id's first so if the file hasn't been modified
# local changes will be ignored. # local changes will be ignored.
# If the files have the same $Id, delete the one in temproot so the # If the files have the same $Id, delete the one in temproot so the
# user will have less to wade through if files are left to merge by hand. # user will have less to wade through if files are left to merge by hand.
# Take the $Id -> $FreeBSD tag change into account
# #
FREEBSDID1=`grep "[$]FreeBSD:" ${COMPFILE#.} 2>/dev/null` # Reduce complexity and improve portability by using ident
FREEBSDID2=`grep "[$]FreeBSD:" ${COMPFILE} 2>/dev/null` #
CVSID1=`ident ${DESTDIR}${COMPFILE#.} 2>&1`
CVSID1="${CVSID1#${DESTDIR}}"
CVSID2=`ident ${COMPFILE} 2>&1`
if [ -n "${FREEBSDID1}" -a -n "${FREEBSDID2}" ]; then case "${CVSID2}" in
IDTAG='$FreeBSD' *'no id keywords'*)
compare_ids "${FREEBSDID1}" "${FREEBSDID2}" ;;
else ."${CVSID1}")
CVSID1=`grep "[$]Id:" ${COMPFILE#.} 2>/dev/null` echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
CVSID2=`grep "[$]Id:" ${COMPFILE} 2>/dev/null` rm "${COMPFILE}"
;;
if [ -n "${CVSID1}" -a -n "${CVSID2}" ]; then esac
IDTAG='$Id'
compare_ids "${CVSID1}" "${CVSID2}"
fi
fi
;; ;;
esac esac
@ -671,7 +700,7 @@ for COMPFILE in `find . -type f -size +0`; do
# Do an absolute diff first to see if the files are actually different. # Do an absolute diff first to see if the files are actually different.
# If they're not different, delete the one in temproot. # If they're not different, delete the one in temproot.
# #
if diff -q "${COMPFILE#.}" "${COMPFILE}" > /dev/null 2>&1; then if diff -q "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > /dev/null 2>&1; then
echo " *** Temp ${COMPFILE} and installed are the same, deleting" echo " *** Temp ${COMPFILE} and installed are the same, deleting"
rm "${COMPFILE}" rm "${COMPFILE}"
else else
@ -761,7 +790,23 @@ case "${NEED_PWD_MKDB}" in
;; ;;
esac esac
case "${AUTO_INSTALLED_FILES}" in
'') ;;
*)
(
echo ''
echo '*** You chose the automatic install option for files that did not exist'
echo ' on your system. The following files were installed for you:'
echo "${AUTO_INSTALLED_FILES}"
) | ${PAGER}
;;
esac
echo '' echo ''
if [ -r "${MM_EXIT_SCRIPT}" ]; then
. "${MM_EXIT_SCRIPT}"
fi
exit 0 exit 0