summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2008-05-14 07:48:37 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2008-05-14 07:48:37 +0000
commita2c6cf22f67cbcca2d9d4b78ee842ca7f11d1d59 (patch)
tree17023c41a9401f0c0c64a62ac1733c4e5f73f77c
parent061ad1998a863108b170a10410e852ef37275c3f (diff)
- add a non-interactive mode to sysmerge ('-b')
- yesno is only used once man page consulting jmc@ ;) ok laurent@ pyr@
-rw-r--r--usr.sbin/sysmerge/sysmerge.812
-rw-r--r--usr.sbin/sysmerge/sysmerge.sh71
2 files changed, 47 insertions, 36 deletions
diff --git a/usr.sbin/sysmerge/sysmerge.8 b/usr.sbin/sysmerge/sysmerge.8
index b927997c277..dca1c1ba53f 100644
--- a/usr.sbin/sysmerge/sysmerge.8
+++ b/usr.sbin/sysmerge/sysmerge.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sysmerge.8,v 1.3 2008/04/30 20:15:54 ajacoutot Exp $
+.\" $OpenBSD: sysmerge.8,v 1.4 2008/05/14 07:48:35 ajacoutot Exp $
.\"
.\" Copyright (c) 2008 Antoine Jacoutot <ajacoutot@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 30 2008 $
+.Dd $Mdocdate: May 14 2008 $
.Dt SYSMERGE 8
.Os
.Sh NAME
@@ -22,7 +22,7 @@
.Nd update system configuration files
.Sh SYNOPSIS
.Nm
-.Op Fl a
+.Op Fl ab
.Op Fl s Ar src \*(Ba etcXX.tgz
.Op Fl x Ar xetcXX.tgz
.Sh DESCRIPTION
@@ -122,6 +122,12 @@ If this option is specified,
will automatically install missing files,
create databases and device nodes,
and will disable strict file comparison when possible (using CVS Ids).
+.It Fl b
+Batch mode.
+If this option is specified,
+.Nm
+will run unattended (non-interactively), saving differing files for
+later manual processing.
.It Fl s Ar src \*(Ba etcXX.tgz
Specify a path to an
.Ox
diff --git a/usr.sbin/sysmerge/sysmerge.sh b/usr.sbin/sysmerge/sysmerge.sh
index b38386e9358..c1b4498a23a 100644
--- a/usr.sbin/sysmerge/sysmerge.sh
+++ b/usr.sbin/sysmerge/sysmerge.sh
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $OpenBSD: sysmerge.sh,v 1.5 2008/04/30 20:15:55 ajacoutot Exp $
+# $OpenBSD: sysmerge.sh,v 1.6 2008/05/14 07:48:36 ajacoutot Exp $
#
# This script is based on the FreeBSD mergemaster script, written by
# Douglas Barton <DougB@FreeBSD.org>
@@ -30,20 +30,6 @@ PATH="/bin:/usr/bin:/sbin:/usr/sbin"
PAGER="${PAGER:=/usr/bin/more}"
SWIDTH=`stty size | awk '{w=$2} END {if (w==0) {w=80} print w}'`
-yesno() {
- echo -n "${*}? (y|[n]) "
- read ANSWER
- case "${ANSWER}" in
- y|Y)
- echo ""
- return 0
- ;;
- *)
- return 1
- ;;
- esac
-}
-
do_pre() {
if [ `id -u` -ne 0 ]; then
@@ -73,11 +59,19 @@ do_pre() {
echo " temp root directory: ${TEMPROOT}"
echo " backup directory: ${BKPDIR}"
echo ""
- if yesno "Continue"; then
- echo -n ""
- else
- rmdir ${WRKDIR} 2> /dev/null
- exit 1
+
+ if [ -z "${BATCHMODE}" ]; then
+ echo -n "Continue? (y|[n]) "
+ read ANSWER
+ case "${ANSWER}" in
+ y|Y)
+ echo ""
+ ;;
+ *)
+ rmdir ${WRKDIR} 2> /dev/null
+ exit 1
+ ;;
+ esac
fi
}
@@ -205,7 +199,11 @@ merge_loop() {
diff_loop() {
- HANDLE_COMPFILE=v
+ if [ "${BATCHMODE}" ]; then
+ HANDLE_COMPFILE=todo
+ else
+ HANDLE_COMPFILE=v
+ fi
while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "todo" ]; do
if [ "${HANDLE_COMPFILE}" = "v" ]; then
@@ -236,17 +234,21 @@ diff_loop() {
fi
fi
- echo " Use 'd' to delete the temporary ${COMPFILE}"
- echo " Use 'i' to install the temporary ${COMPFILE}"
- if [ -z "${NO_INSTALLED}" -a -z "${IS_BINFILE}" ]; then
- echo " Use 'm' to merge the temporary and installed versions"
- echo " Use 'v' to view the diff results again"
+ if [ -z "${BATCHMODE}" ]; then
+ echo " Use 'd' to delete the temporary ${COMPFILE}"
+ echo " Use 'i' to install the temporary ${COMPFILE}"
+ if [ -z "${NO_INSTALLED}" -a -z "${IS_BINFILE}" ]; then
+ echo " Use 'm' to merge the temporary and installed versions"
+ echo " Use 'v' to view the diff results again"
+ fi
+ echo ""
+ echo " Default is to leave the temporary file to deal with by hand"
+ echo ""
+ echo -n "How should I deal with this? [Leave it for later] "
+ read HANDLE_COMPFILE
+ else
+ unset HANDLE_COMPFILE
fi
- echo ""
- echo " Default is to leave the temporary file to deal with by hand"
- echo ""
- echo -n "How should I deal with this? [Leave it for later] "
- read HANDLE_COMPFILE
case "${HANDLE_COMPFILE}" in
[dD])
@@ -410,9 +412,9 @@ do_post() {
}
-ARGS=`getopt as:x: $*`
+ARGS=`getopt abs:x: $*`
if [ $? -ne 0 ]; then
- echo "usage: ${0##*/} [-a] [-s src | etcXX.tgz] [-x xetcXX.tgz]" >&2
+ echo "usage: ${0##*/} [-ab] [-s src | etcXX.tgz] [-x xetcXX.tgz]" >&2
exit 1
fi
set -- ${ARGS}
@@ -422,6 +424,9 @@ do
-a)
AUTOMODE=yes
shift;;
+ -b)
+ BATCHMODE=1
+ shift;;
-s)
WHERE="${2}"
shift 2