xref: /netbsd-src/external/ibm-public/postfix/postfix2netbsd (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1#! /bin/sh
2#
3#	$NetBSD: postfix2netbsd,v 1.1 2009/06/23 15:02:51 tron 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
38PROG="$(basename "$0")"
39if [ -z "$1" -o -n "$2" ]
40then
41	echo "Usage: $PROG <dir>" 1>&2
42	exit 1
43fi
44cd "$1"
45# delete some superfluous files
46echo deleting some superfluous files
47find . \( -type f -o -type l \) -a \
48	\( -name .indent.pro -o -name .printfck -o -name .keep \) \
49	-exec rm {} \;
50rm -rf bin include lib libexec man/cat? auxiliary
51echo done
52
53### ditch symlinks
54find . -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"
59done
60
61### Remove the $'s around RCS tags
62find . -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"
70done
71
72### Add our NetBSD RCS Id
73find . -type f -name '*.[chly]' -print | while read c; do
74	sed 1q < $c | grep -q '\$NetBSD' || (
75echo "/*	\$NetBSD\$	*/" >/tmp/postfix3$$
76echo "" >>/tmp/postfix3$$
77cat $c  >> /tmp/postfix3$$
78mv /tmp/postfix3$$ $c && echo "added NetBSD RCS tag to $c"
79	)
80done
81
82find man -type f -name '*.[0-9]' -print | while read m; do
83	sed 1q < $m | grep -q '\$NetBSD' || (
84echo ".\\\"	\$NetBSD\$" >/tmp/postfix4$$
85echo ".\\\"" >>/tmp/postfix4$$
86cat $m >> /tmp/postfix4$$
87mv /tmp/postfix4$$ $m && echo "added NetBSD RCS tag to $m"
88	)
89done
90
91find 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"
105done
106echo done
107
108echo You can import now.
109
110echo Path: src/external/ibm-public/postfix/dist
111echo Vendor: VENEMA
112echo Versiontag: PFIX-X-Y-Z
113
114exit 0
115