xref: /netbsd-src/external/ibm-public/postfix/postfix2netbsd (revision 6ee25ca9b9c04ef5f85a3a0c9153bc1ff2ebd503)
1#! /bin/sh
2#
3#	$NetBSD: postfix2netbsd,v 1.3 2011/10/08 19:28:40 christos 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
62cleantags .
63
64### Add our NetBSD RCS Id
65find . -type f -name '*.[chly]' -print | while read c; do
66	sed 1q < $c | grep -q '\$NetBSD' || (
67echo "/*	\$NetBSD\$	*/" >/tmp/postfix3$$
68echo "" >>/tmp/postfix3$$
69cat $c  >> /tmp/postfix3$$
70mv /tmp/postfix3$$ $c && echo "added NetBSD RCS tag to $c"
71	)
72done
73
74find man -type f -name '*.[0-9]' -print | while read m; do
75	sed 1q < $m | grep -q '\$NetBSD' || (
76echo ".\\\"	\$NetBSD\$" >/tmp/postfix4$$
77echo ".\\\"" >>/tmp/postfix4$$
78cat $m >> /tmp/postfix4$$
79mv /tmp/postfix4$$ $m && echo "added NetBSD RCS tag to $m"
80	)
81done
82
83find conf -type f \( -name '*.cf' -o -name 'post*' -o -name 'Makefile*' \) -print | while read t; do
84        grep -q '\$NetBSD' $t && continue
85        sed 1q < $t | grep -q '^\#!'
86        if [ $? -eq 0 ] ; then
87		sed 1q < $t >/tmp/postfix5$$
88		echo "#	\$NetBSD\$" >>/tmp/postfix5$$
89		echo "#" >>/tmp/postfix5$$
90		sed "1d" < $t >>/tmp/postfix5$$
91        else
92		echo "#	\$NetBSD\$" >/tmp/postfix5$$
93		echo "#" >>/tmp/postfix5$$
94		cat $t >> /tmp/postfix5$$
95	fi
96	mv /tmp/postfix5$$ $t && echo "added NetBSD RCS tag to $t"
97done
98echo done
99
100VERSION=$(sed -n -e 's/^#define MAIL_VERSION_NUMBER.*"\(.*\)".*/\1/p' src/global/mail_version.h | tr . -)
101
102echo You can import now.
103
104echo Path: src/external/ibm-public/postfix/dist
105echo Vendor: VENEMA
106echo Versiontag: PFIX-${VERSION}
107
108exit 0
109