Add helper script to generate README.DELETED files.
authorSimon Schubert <corecode@dragonflybsd.org>
Mon, 12 Sep 2005 00:10:00 +0000 (00:10 +0000)
committerSimon Schubert <corecode@dragonflybsd.org>
Mon, 12 Sep 2005 00:10:00 +0000 (00:10 +0000)
usage:
  genreadmedeleted origdir trimddir

tools/tools/README
tools/tools/genreadmedeleted/genreadmedeleted [new file with mode: 0644]

index 105538f..8dab3a7 100644 (file)
@@ -1,5 +1,5 @@
 # $FreeBSD: src/tools/tools/README,v 1.18.2.2 2003/02/24 22:52:36 sam Exp $
-# $DragonFly: src/tools/tools/README,v 1.4 2005/01/10 22:20:27 joerg Exp $
+# $DragonFly: src/tools/tools/README,v 1.5 2005/09/12 00:10:00 corecode Exp $
 
 This directory is for tools.
 
@@ -13,6 +13,7 @@ commitsdb     A tool for reconstructing commit history using md5
 crypto         Exercise the crypto framework through /dev/crypto
 editing                Editor modes and the like to help editing FreeBSD code.
 epfe           Extract printing filter examples from printing.sgml.
+genreadmedeleted  Create a README.DELETED suitable for the new contrib system.
 html-mv         Rename HTML generated filenames to human readable filenames.
 ifinfo         Uses the interface MIB to print out all the information
                an interface exports in an ugly form.
diff --git a/tools/tools/genreadmedeleted/genreadmedeleted b/tools/tools/genreadmedeleted/genreadmedeleted
new file mode 100644 (file)
index 0000000..771915e
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# $DragonFly: src/tools/tools/genreadmedeleted/genreadmedeleted,v 1.1 2005/09/12 00:10:00 corecode Exp $
+
+if [ $# -lt 2 -o $# -gt 3 ]
+then
+       echo "$0 <origdir> <trim'ddir> [readmefile]" >&2
+       echo "    readmefile defaults to trim'ddir/README.DELETED" >&2
+       echo "    you can use '-' as readmefile to force output to stdout" >&2
+       exit 1
+fi
+
+origdir=`realpath $1`/; shift
+trimdir=`realpath $1`/; shift
+readme=${1:-$trimdir/README.DELETED}
+
+trimdir() {
+       local curdir=$1
+       local isdir
+       cd "$origdir$curdir"
+       set -- .* *
+       for f
+       do
+               case "$f" in
+               .|..)
+                       continue
+                       ;;
+               esac
+
+               if [ -d "$f" ]
+               then
+                       isdir=/
+               else
+                       isdir=
+               fi
+
+               if [ ! -e "$trimdir$curdir$f" ]
+               then
+                       printf '%s%s\n' "$curdir$f" "$isdir"
+                       continue
+               fi
+
+               case "$isdir" in
+               /)
+                       trimdir "$curdir$f/"
+                       ;;
+               esac
+       done
+}
+
+case "$readme" in
+-)
+       ;;
+*)
+       exec > $readme
+       ;;
+esac
+
+trimdir ""