summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mergemaster
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2011-11-02 07:40:23 +0000
committerdougb <dougb@FreeBSD.org>2011-11-02 07:40:23 +0000
commite799577150fdcc39ca2271625bcbf034a547340b (patch)
treeb00050a914500a60bae5bc61ad51865c9c459d71 /usr.sbin/mergemaster
parent6dbf0412bb20d5223dff1585c838f34acd129b1d (diff)
downloadFreeBSD-src-e799577150fdcc39ca2271625bcbf034a547340b.zip
FreeBSD-src-e799577150fdcc39ca2271625bcbf034a547340b.tar.gz
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.
Diffstat (limited to 'usr.sbin/mergemaster')
-rw-r--r--usr.sbin/mergemaster/mergemaster.811
-rwxr-xr-xusr.sbin/mergemaster/mergemaster.sh69
2 files changed, 63 insertions, 17 deletions
diff --git a/usr.sbin/mergemaster/mergemaster.8 b/usr.sbin/mergemaster/mergemaster.8
index 4dcad39..36eba1b 100644
--- a/usr.sbin/mergemaster/mergemaster.8
+++ b/usr.sbin/mergemaster/mergemaster.8
@@ -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=
#
diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index 78d5c08..6b5003e 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -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
+
+ 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 "${YES_OR_NO}" in
+ 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
OpenPOWER on IntegriCloud