summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2010-02-06 14:02:37 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2010-02-06 14:02:37 +0000
commita47d286e3c04303428422d3cea1aa50240401c2d (patch)
tree35ea598bee4583d2448b651db58eeb195ce32312
parent10a30e33d830583d56fe94e3b21a97554400b740 (diff)
Remove newly generated sum file(s) if it did not exist before and trap
is called. While here, change shebang to /bin/ksh to reflect reality and bump copyright year. "checkbashisms says yes. :-)" && ok sthen@
-rw-r--r--usr.sbin/sysmerge/sysmerge.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/sysmerge/sysmerge.sh b/usr.sbin/sysmerge/sysmerge.sh
index 20a0dc56210..62e593bd778 100644
--- a/usr.sbin/sysmerge/sysmerge.sh
+++ b/usr.sbin/sysmerge/sysmerge.sh
@@ -1,9 +1,9 @@
-#!/bin/sh -
+#!/bin/ksh -
#
-# $OpenBSD: sysmerge.sh,v 1.56 2010/01/13 16:22:56 sthen Exp $
+# $OpenBSD: sysmerge.sh,v 1.57 2010/02/06 14:02:36 ajacoutot Exp $
#
# Copyright (c) 1998-2003 Douglas Barton <DougB@FreeBSD.org>
-# Copyright (c) 2008, 2009 Antoine Jacoutot <ajacoutot@openbsd.org>
+# Copyright (c) 2008, 2009, 2010 Antoine Jacoutot <ajacoutot@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -20,8 +20,8 @@
umask 0022
-unset AUTO_INSTALLED_FILES BATCHMODE DIFFMODE NEED_NEWALIASES
-unset OBSOLETE_FILES SRCDIR TGZ TGZURL XTGZ XTGZURL
+unset AUTO_INSTALLED_FILES BATCHMODE DIFFMODE ETCSUM NEED_NEWALIASES
+unset OBSOLETE_FILES SRCDIR SRCSUM TGZ TGZURL XETCSUM XTGZ XTGZURL
WRKDIR=`mktemp -d -p ${TMPDIR:=/var/tmp} sysmerge.XXXXX` || exit 1
SWIDTH=`stty size | awk '{w=$2} END {if (w==0) {w=80} print w}'`
@@ -38,12 +38,15 @@ clean_src() {
fi
}
-# restore files from backups
+# restore files from backups or remove the newly generated sum files if
+# they did not exist
restore_bak() {
- for i in ${DESTDIR}/${DBDIR}/.*.bak; do
+ for i in ${DESTDIR}/${DBDIR}/.{${SRCSUM},${ETCSUM},${XETCSUM}}.bak; do
_i=`basename ${i} .bak`
if [ -f "${i}" ]; then
mv ${i} ${DESTDIR}/${DBDIR}/${_i#.}
+ elif [ -f "${DESTDIR}/${DBDIR}/${_i#.}" ]; then
+ rm ${DESTDIR}/${DBDIR}/${_i#.}
fi
done
}
@@ -127,7 +130,6 @@ do_populate() {
echo "===> Creating and populating temporary root under"
echo " ${TEMPROOT}"
mkdir -p ${TEMPROOT}
- local SRCSUM ETCSUM XETCSUM
if [ "${SRCDIR}" ]; then
SRCSUM=srcsum
cd ${SRCDIR}/etc