Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc When backing files listed in /etc/changelist, instead of...



details:   https://anonhg.NetBSD.org/src/rev/d70ee33c9ce0
branches:  trunk
changeset: 509691:d70ee33c9ce0
user:      atatat <atatat%NetBSD.org@localhost>
date:      Thu May 10 14:19:27 2001 +0000

description:
When backing files listed in /etc/changelist, instead of truncating
to the basename of the file, use the whole path with $backup_dir
prepended, in effect mirrorring the directory tree.  This eliminates
the possibility of a name collision.

Closes pr bin/12727.

diffstat:

 etc/security |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r d90109d3da14 -r d70ee33c9ce0 etc/security
--- a/etc/security      Thu May 10 14:10:15 2001 +0000
+++ b/etc/security      Thu May 10 14:19:27 2001 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#      $NetBSD: security,v 1.53 2001/05/10 14:10:15 atatat Exp $
+#      $NetBSD: security,v 1.54 2001/05/10 14:19:27 atatat Exp $
 #      from: @(#)security      8.1 (Berkeley) 6/9/93
 #
 
@@ -677,8 +677,26 @@
 
 if [ -n "$CHANGELIST" ]; then
        for file in `egrep -hv "^#|$MP" $CHANGELIST`; do
-               CUR=$backup_dir/${file##*/}.current
-               BACK=$backup_dir/${file##*/}.backup
+               # old changelist backup names
+               OCUR=$backup_dir/${file##*/}.current
+               OBACK=$backup_dir/${file##*/}.backup
+               # new changelist backup names
+               CUR=$backup_dir$file.current
+               BACK=$backup_dir$file.backup
+               # roll over old backups
+               if [ ! -d ${CUR%/*} ]; then
+                       mkdir -p ${CUR%/*}
+               fi
+               if [ -f $OCUR -a ! -f $CUR ]; then
+                       mv $OCUR $CUR
+               fi
+               if [ -f $OCUR,v -a ! -f $CUR,v ]; then
+                       mv $OCUR,v $CUR,v
+               fi
+               if [ -f $OBACK -a ! -f $BACK ]; then
+                       mv $OBACK $BACK
+               fi
+               # and down to work
                if [ -f $file ]; then
                        if [ -f $CUR ] ; then
                                diff $CUR $file > $OUTPUT



Home | Main Index | Thread Index | Old Index