Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/cleantags Small script used when importing 3rd party...



details:   https://anonhg.NetBSD.org/src/rev/27cb29630178
branches:  trunk
changeset: 770223:27cb29630178
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 08 19:16:08 2011 +0000

description:
Small script used when importing 3rd party programs. The code in this
script is used in many foo2netbsd scripts, but none of them has the
complete list of keywords. I will make all those scripts use this one
instead.

diffstat:

 usr.bin/cleantags/Makefile     |   6 +++
 usr.bin/cleantags/cleantags.1  |  28 +++++++++++++++++
 usr.bin/cleantags/cleantags.sh |  67 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+), 0 deletions(-)

diffs (113 lines):

diff -r e87b082de95f -r 27cb29630178 usr.bin/cleantags/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/cleantags/Makefile        Sat Oct 08 19:16:08 2011 +0000
@@ -0,0 +1,6 @@
+#      $NetBSD: Makefile,v 1.1 2011/10/08 19:16:08 christos Exp $
+
+MAN=   cleantags.1
+SCRIPTS=cleantags.sh
+
+.include <bsd.prog.mk>
diff -r e87b082de95f -r 27cb29630178 usr.bin/cleantags/cleantags.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/cleantags/cleantags.1     Sat Oct 08 19:16:08 2011 +0000
@@ -0,0 +1,28 @@
+.\"    $NetBSD: cleantags.1,v 1.1 2011/10/08 19:16:08 christos Exp $
+.\"
+.Dd October 8, 2001
+.Dt cleantags 1
+.Os
+.Sh NAME
+.Nm cleantags
+.Nd Remove
+.Dv $
+around
+.Xr rcs 1
+keywords.
+.Sh SYNOPSIS
+.Nm Op Ar v
+.Ar files|directories
+.Sh DESCRIPTION
+The
+.Nm
+utility removes dollars around
+.Xr rcs 1
+id keywords in order to disable further changes to them.
+It is used when importing 3rd party programs to the tree.
+.Pp
+The
+.Op v
+flag can be used to list the files that are changed.
+.Sh SEE ALSO
+.Xr rcs 1
diff -r e87b082de95f -r 27cb29630178 usr.bin/cleantags/cleantags.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/cleantags/cleantags.sh    Sat Oct 08 19:16:08 2011 +0000
@@ -0,0 +1,67 @@
+#!/bin/sh
+# $NetBSD: cleantags.sh,v 1.1 2011/10/08 19:16:08 christos Exp $
+# Remove the $'s from rcs tags
+
+PROG="$(basename "$0")"
+PAT='\$(Author|Date|CVSHeader|Header|Id|LocalId|Locker|Log|Name|RCSfile|Revision|Source|State|NetBSD)'
+verbose=false
+
+dosed() {
+       sed \
+           -e 's/\$\(Author.*\) \$/\1/' \
+           -e 's/\$\(Date.*\) \$/\1/' \
+           -e 's/\$\(CVSHeader.*\) \$/\1/' \
+           -e 's/\$\(Header.*\) \$/\1/' \
+           -e 's/\$\(Id.*\) \$/\1/' \
+           -e 's/\$\(LocalId.*\) \$/\1/' \
+           -e 's/\$\(Locker.*\) \$/\1/' \
+           -e 's/\$\(Log.*\) \$/\1/' \
+           -e 's/\$\(Name.*\) \$/\1/' \
+           -e 's/\$\(RCSfile.*\) \$/\1/' \
+           -e 's/\$\(Revision.*\) \$/\1/' \
+           -e 's/\$\(Source.*\) \$/\1/' \
+           -e 's/\$\(State.*\) \$/\1/' \
+           -e 's/\$\(NetBSD.*\) \$/\1/' \
+           "$1" > "/tmp/$PROG$$" && mv "/tmp/$PROG$$" "$1"
+       if $verbose
+       then
+               echo "$1"
+       fi
+}
+
+usage() {
+       echo "Usage: $PROG [-v] <files>|<directories>" 1>&2
+       exit 1
+}
+
+while getopts "v" f
+do
+       case "$f" in
+       v)
+               verbose=true;;
+       *)
+               usage;;
+       esac
+done
+
+shift "$(expr "$OPTIND" - 1)"
+
+if [ -z "$1" ]
+then
+       usage
+fi
+
+for i
+do
+       if [ -d "$i" ]
+       then
+               find "$i" -type f -print0 | xargs -0 egrep -l "$PAT" |
+               while read f
+               do
+                       dosed "$f"
+               done
+       elif egrep -qs "$PAT" "$i" 
+       then
+               dosed "$i"
+       fi
+done



Home | Main Index | Thread Index | Old Index