Reduce amount of macro magic. Use the same special characters as nroff
[netbsd-mini2440.git] / dist / ipf / ipf2netbsd
blob3663c0ecf720d6fc67220a0f4a1e8fe7ed359930
1 #! /bin/sh
3 # $NetBSD: ipf2netbsd,v 1.21 2008/04/30 13:10:47 martin Exp $
5 # Copyright (c) 1999 The NetBSD Foundation, Inc.
6 # All rights reserved.
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.
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.
29 # ipf2netbsd: convert a ipf source tree into a netbsd ipf source tree,
30 # under src/dist/ipf, src/sys/dist/ipf/netinet, src/sys/lkm/netinet/if_ipl
31 # and src/regress/sys/kern/ipf
33 if [ $# -ne 2 ]; then echo "ipf2netbsd src dest"; exit 1; fi
35 r=$1
36 dest=$2
38 case "$dest" in
39 /*)
42 dest=`/bin/pwd`/$dest
44 esac
46 dbase=$dest/src/dist/ipf
47 dsys=$dest/src/sys/dist/ipf/netinet
48 dlkm=$dest/src/sys/lkm/netinet/if_ipl
49 dregress=$dest/src/regress/sys/kern/ipf
51 case "$r" in
52 /*)
55 r=`/bin/pwd`/$r
57 esac
59 echo preparing directory $dbase, $dsys, $dlkm and $dregress
60 rm -rf $dbase $dsys $dlkm $dregress
62 ### Copy the files and directories
63 mkdir -p $dbase $dsys $dlkm $dregress
64 cd $r
65 pax -rvw . $dbase
66 pax -rvw \
67 fil.c \
68 ip_auth.c \
69 ip_auth.h \
70 ip_compat.h \
71 ip_fil.h \
72 ip_fil_netbsd.c \
73 ip_frag.c \
74 ip_frag.h \
75 ip_ftp_pxy.c \
76 ip_h323_pxy.c \
77 ip_htable.c \
78 ip_htable.h \
79 ip_ipsec_pxy.c \
80 ip_irc_pxy.c \
81 ip_log.c \
82 ip_lookup.c \
83 ip_lookup.h \
84 ip_nat.c \
85 ip_nat.h \
86 ip_netbios_pxy.c \
87 ip_pool.c \
88 ip_pool.h \
89 ip_pptp_pxy.c \
90 ip_proxy.c \
91 ip_proxy.h \
92 ip_raudio_pxy.c \
93 ip_rcmd_pxy.c \
94 ip_rpcb_pxy.c \
95 ip_scan.c \
96 ip_scan.h \
97 ip_state.c \
98 ip_state.h \
99 ip_sync.c \
100 ip_sync.h \
101 ipl.h \
102 $dsys
103 pax -rvw mln_ipl.c $dlkm
104 cd $r/test
105 pax -rvw * $dregress
107 ### Remove uninteresting bits
108 echo "removing extraneous files and directiones."
110 cd ${dest}/src/dist/ipf
111 find . -name .cvsignore | xargs /bin/rm -f
112 for i in 4bsd AIX BSD BSDOS BSDOS3 BSDOS4 COMPILE.2.5 COMPILE.Solaris2 \
113 FAQ.FreeBSD FreeBSD FreeBSD-2.2 FreeBSD-3 FreeBSD-4.0 HPUX \
114 INST.FreeBSD-2.2 INSTALL.BSDOS INSTALL.FreeBSD INSTALL.IRIX \
115 INSTALL.Sol2 INSTALL.SunOS INSTALL.Tru64 Linux IRIX OSF \
116 INSTALL.NetBSD INSTALL.Linux INSTALL.xBSD INSTALL.BSDOS3 NAT.FreeBSD OpenBSD OpenBSD-2 OpenBSD-3 SunOS4 SunOS5 ipsend/.OLD; do
117 echo "removing $i";
118 /bin/rm -rf "$i"
119 done
121 echo done
123 ### Remove the $'s around various RCSIDs
124 find $dest -type f -print | while read f; do
125 sed -e 's/\$\(Id.*\) \$/\1/' \
126 -e 's/\$\(Header.*\) \$/\1/' \
127 $f > /tmp/ipf2f$$ && mv /tmp/ipf2f$$ $f && \
128 echo removed RCS tag from $f
129 done
131 ### Add our NetBSD RCS Id
132 find $dest -type f -name '*.[chly]' -print | while read c; do
133 sed 1q < $c | grep -q '\$NetBSD' || (
134 echo "/* \$NetBSD\$ */" >/tmp/ipf2n$$
135 echo "" >>/tmp/ipf2n$$
136 cat $c >> /tmp/ipf2n$$
137 mv /tmp/ipf2n$$ $c && echo added RCS tag to $c
139 done
141 find $dest -type f -name '*.[0-9]' -a \! -name 'example.*' -a \! -name 'ipv6.*' -print | while read m; do
142 sed 1q < $m | grep -q '\$NetBSD' || (
143 echo ".\\\" \$NetBSD\$" >/tmp/ipf2m$$
144 echo ".\\\"" >>/tmp/ipf2m$$
145 cat $m >> /tmp/ipf2m$$
146 mv /tmp/ipf2m$$ $m && echo added RCS tag to $m
148 done
150 find $dest -type f -name 'example.*' -print | while read e; do
151 sed 1q < $e | grep -q '\$NetBSD' || (
152 echo "# \$NetBSD\$" >/tmp/ipf2e$$
153 cat $e >> /tmp/ipf2e$$
154 mv /tmp/ipf2e$$ $e && echo added RCS tag to $e
156 done
158 echo done
160 ### Clean up any CVS directories that might be around.
161 echo "cleaning up CVS residue."
163 cd $dest
164 find . -type d -name "CVS" -print | xargs rm -r
166 echo done
168 ### Fixing file and directory permissions.
169 echo "Fixing file/directory permissions."
171 cd $dest
172 find . -type f -print | xargs chmod u+rw,go+r
173 find . -type d -print | xargs chmod u+rwx,go+rx
175 echo done
177 exit 0