1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

1. Add a new option, --run-updates, to always or never run the newalises,

pwd_mkdb, etc. updates at the end of the comparison.

2. Add an update to the end to handle /etc/localtime, if it exists.
   If /var/db/zoneinfo exists, automatically update /etc/localtime,
   which should (hopefully) be safe to do. If not, prompt the user
   to run tzsetup.

3. Update run_it_now(), the function that handles input for the updates,
   to make sure that we got a valid answer, and to handle the --run-updates
   option if supplied.
This commit is contained in:
Doug Barton 2011-11-02 07:40:23 +00:00
parent 8393768074
commit b90270a146
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227013
2 changed files with 63 additions and 17 deletions

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 9, 2011
.Dd November 1, 2011
.Dt MERGEMASTER 8
.Os
.Sh NAME
@ -34,6 +34,7 @@
.Nm
.Op Fl scrvhpCP
.Op Fl a|iFU
.Op Fl -run-updates=[always|never]
.Op Fl m Ar /path/to/sources
.Op Fl t Ar /path/to/temp/root
.Op Fl d
@ -246,6 +247,11 @@ rc file.
Attempt to auto upgrade files that have not been user modified.
This option can be dangerous when there are critical changes
in the new versions that affect your running system.
.It Fl -run-updates=[always|never]
Specify always or never to run newaliases, pwd_mkdb, etc.
at the end of the comparison run.
If this option is omitted the default is to prompt the user
for each update as necessary.
.It Fl m Ar /path/to/sources
Specify the path to the directory where you want to do the
.Xr make 1 .
@ -365,6 +371,9 @@ with all values commented out:
# ***DANGEROUS***
#AUTO_UPGRADE=
#
# Either always or never run newaliases, pwd_mkdb at the end (--run-updates)
#RUN_UPDATES=
#
# Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf (-C)
#COMP_CONFS=
#

View File

@ -15,7 +15,7 @@ PATH=/bin:/usr/bin:/usr/sbin
display_usage () {
VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
echo "mergemaster version ${VERSION_NUMBER}"
echo 'Usage: mergemaster [-scrvhpCP] [-a|[-iFU]]'
echo 'Usage: mergemaster [-scrvhpCP] [-a|[-iFU]] [--run-updates=always|never]'
echo ' [-m /path] [-t /path] [-d] [-u N] [-w N] [-A arch] [-D /path]'
echo "Options:"
echo " -s Strict comparison (diff every pair of files)"
@ -31,6 +31,7 @@ display_usage () {
echo ' -P Preserve files that are overwritten'
echo " -U Attempt to auto upgrade files that have not been user modified"
echo ' ***DANGEROUS***'
echo ' --run-updates= Specify always or never to run newalises, pwd_mkdb, etc.'
echo ''
echo " -m /path/directory Specify location of source to do the make in"
echo " -t /path/directory Specify temp root directory"
@ -262,6 +263,20 @@ if [ -r "$HOME/.mergemasterrc" ]; then
. "$HOME/.mergemasterrc"
fi
for var in "$@" ; do
case "$var" in
--run-updates*)
RUN_UPDATES=`echo ${var#--run-updates=} | tr [:upper:] [:lower:]`
;;
*)
newopts="$newopts $var"
;;
esac
done
set -- $newopts
unset var newopts
# Check the command line options
#
while getopts ":ascrvhipCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do
@ -1224,34 +1239,43 @@ case "${AUTO_UPGRADED_FILES}" in
esac
run_it_now () {
case "${AUTO_RUN}" in
'')
unset YES_OR_NO
echo ''
echo -n ' Would you like to run it now? y or n [n] '
read YES_OR_NO
[ -n "$AUTO_RUN" ] && return
case "${YES_OR_NO}" in
local answer
echo ''
while : ; do
if [ "$RUN_UPDATES" = always ]; then
answer=y
elif [ "$RUN_UPDATES" = never ]; then
answer=n
else
echo -n ' Would you like to run it now? y or n [n] '
read answer
fi
case "$answer" in
y)
echo " Running ${1}"
echo ''
eval "${1}"
return
;;
''|n)
echo ''
echo " *** Cancelled"
echo ''
if [ ! "$RUN_UPDATES" = never ]; then
echo ''
echo " *** Cancelled"
echo ''
fi
echo " Make sure to run ${1} yourself"
return
;;
*)
echo ''
echo " *** Sorry, I do not understand your answer (${YES_OR_NO})"
echo " *** Sorry, I do not understand your answer (${answer})"
echo ''
echo " Make sure to run ${1} yourself"
esac
;;
*) ;;
esac
done
}
case "${NEED_NEWALIASES}" in
@ -1310,6 +1334,19 @@ case "${NEED_PWD_MKDB}" in
;;
esac
if [ -e "${DESTDIR}/etc/localtime" ]; then # Ignore if TZ == UTC
echo ''
if [ -f "${DESTDIR}/var/db/zoneinfo" ]; then
echo "*** Reinstalling `cat ${DESTDIR}/var/db/zoneinfo` as ${DESTDIR}/etc/localtime"
[ -n "${DESTDIR}" ] && tzs_args="-C ${DESTDIR}"
tzsetup $tzs_args -r
else
echo "*** There is no ${DESTDIR}/var/db/zoneinfo file to update ${DESTDIR}/etc/localtime."
echo ' You should run tzsetup'
run_it_now tzsetup
fi
fi
echo ''
if [ -r "${MM_EXIT_SCRIPT}" ]; then