Home | History | Annotate | Line # | Download | only in postfix
postfix2netbsd revision 1.1.2.2
      1 #! /bin/sh
      2 #
      3 #	$NetBSD: postfix2netbsd,v 1.1.2.2 2009/09/15 06:01:40 snj Exp $
      4 #
      5 # Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
      6 # All rights reserved.
      7 #
      8 # Redistribution and use in source and binary forms, with or without
      9 # modification, are permitted provided that the following conditions
     10 # are met:
     11 # 1. Redistributions of source code must retain the above copyright
     12 #    notice, this list of conditions and the following disclaimer.
     13 # 2. Redistributions in binary form must reproduce the above copyright
     14 #    notice, this list of conditions and the following disclaimer in the
     15 #    documentation and/or other materials provided with the distribution.
     16 #
     17 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27 # POSSIBILITY OF SUCH DAMAGE.
     28 #
     29 # postfix2netbsd: adds NetBSD tag, removes unnecessary files and
     30 # resolve symlinks for importing postfix tree into netbsd.
     31 # works on current directory.
     32 
     33 # postfix2netbsd: convert a postfix source tree into a
     34 # format suitable for commit. Works on current dir.
     35 #
     36 # Seed from Wiz's grep2netbsd.
     37 
     38 PROG="$(basename "$0")"
     39 if [ -z "$1" -o -n "$2" ]
     40 then
     41 	echo "Usage: $PROG <dir>" 1>&2
     42 	exit 1
     43 fi
     44 cd "$1"
     45 # delete some superfluous files
     46 echo deleting some superfluous files
     47 find . \( -type f -o -type l \) -a \
     48 	\( -name .indent.pro -o -name .printfck -o -name .keep \) \
     49 	-exec rm {} \;
     50 rm -rf bin include lib libexec man/cat? auxiliary
     51 echo done
     52 
     53 ### ditch symlinks
     54 find . -type l | while read t; do
     55 	cp $t /tmp/postfix7$$   
     56 	rm -f $t
     57 	mv /tmp/postfix7$$ $t
     58 	echo "resolved symlink $t"
     59 done    
     60 
     61 ### Remove the $'s around RCS tags
     62 find . -type f -print | xargs egrep -l '\$(Id|Created|Header|Revision|Source)' | while read f; do
     63 	sed -e 's/\$\(Id.*\) ?\$/\1/' \
     64 	    -e 's/\$\(Created.*\) \$/\1/' \
     65 	    -e 's/\$\(Header.*\) \$/\1/' \
     66 	    -e 's/\$\(Revision.*\) ?\$/\1/' \
     67 	    -e 's/\$\(Source.*\) ?\$/\1/' \
     68 	    $f > /tmp/postfix2$$ && mv /tmp/postfix2$$ $f && \
     69 	echo "removed RCS tag from $f"
     70 done
     71 
     72 ### Add our NetBSD RCS Id
     73 find . -type f -name '*.[chly]' -print | while read c; do
     74 	sed 1q < $c | grep -q '\$NetBSD' || (
     75 echo "/*	\$NetBSD\$	*/" >/tmp/postfix3$$
     76 echo "" >>/tmp/postfix3$$
     77 cat $c  >> /tmp/postfix3$$
     78 mv /tmp/postfix3$$ $c && echo "added NetBSD RCS tag to $c"
     79 	)
     80 done
     81 
     82 find man -type f -name '*.[0-9]' -print | while read m; do
     83 	sed 1q < $m | grep -q '\$NetBSD' || (
     84 echo ".\\\"	\$NetBSD\$" >/tmp/postfix4$$
     85 echo ".\\\"" >>/tmp/postfix4$$
     86 cat $m >> /tmp/postfix4$$
     87 mv /tmp/postfix4$$ $m && echo "added NetBSD RCS tag to $m"
     88 	)
     89 done
     90 
     91 find conf -type f \( -name '*.cf' -o -name 'post*' -o -name 'Makefile*' \) -print | while read t; do  
     92         grep -q '\$NetBSD' $t && continue
     93         sed 1q < $t | grep -q '^\#!'
     94         if [ $? -eq 0 ] ; then
     95 		sed 1q < $t >/tmp/postfix5$$
     96 		echo "#	\$NetBSD\$" >>/tmp/postfix5$$
     97 		echo "#" >>/tmp/postfix5$$
     98 		sed "1d" < $t >>/tmp/postfix5$$
     99         else
    100 		echo "#	\$NetBSD\$" >/tmp/postfix5$$
    101 		echo "#" >>/tmp/postfix5$$
    102 		cat $t >> /tmp/postfix5$$
    103 	fi
    104 	mv /tmp/postfix5$$ $t && echo "added NetBSD RCS tag to $t"
    105 done
    106 echo done
    107 
    108 echo You can import now.
    109 
    110 echo Path: src/external/ibm-public/postfix/dist
    111 echo Vendor: VENEMA
    112 echo Versiontag: PFIX-X-Y-Z
    113 
    114 exit 0
    115