Home | History | Annotate | Line # | Download | only in ipf
      1 #! /bin/sh
      2 #
      3 #	$NetBSD: ipf2netbsd,v 1.3 2024/09/08 10:01:59 rillig Exp $
      4 #
      5 # Copyright (c) 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 # ipf2netbsd:  convert an 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
     32 
     33 if [ $# -ne 2 ]; then echo "ipf2netbsd src dest"; exit 1; fi
     34 
     35 r=$1
     36 dest=$2
     37 
     38 case "$dest" in
     39 	/*)
     40 		;;
     41 	*)
     42 		dest=`/bin/pwd`/$dest
     43 		;;
     44 esac
     45 
     46 dbase=$dest/src/external/bsd/ipf/dist
     47 dsys=$dest/src/sys/external/bsd/ipf/netinet
     48 #dlkm=$dest/src/sys/modules/ipf
     49 dtests=$dest/src/tests/ipf
     50 
     51 case "$r" in
     52 	/*)
     53 		;;
     54 	*)
     55 		r=`/bin/pwd`/$r
     56 		;;
     57 esac
     58 
     59 echo preparing directory $dbase, $dsys, $dlkm and $dregress
     60 rm -rf $dbase $dsys $dlkm $dregress
     61 
     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_dns_pxy.c \
     72 	ip_dstlist.c \
     73 	ip_dstlist.h \
     74 	ip_fil.h \
     75 	ip_fil_compat.c \
     76 	ip_fil_netbsd.c \
     77 	ip_frag.c \
     78 	ip_frag.h \
     79 	ip_ftp_pxy.c \
     80 	ip_htable.c \
     81 	ip_htable.h \
     82 	ip_ipsec_pxy.c \
     83 	ip_irc_pxy.c \
     84 	ip_log.c \
     85 	ip_lookup.c \
     86 	ip_lookup.h \
     87 	ip_nat.c \
     88 	ip_nat6.c \
     89 	ip_nat.h \
     90 	ip_netbios_pxy.c \
     91 	ip_pool.c \
     92 	ip_pool.h \
     93 	ip_pptp_pxy.c \
     94 	ip_proxy.c \
     95 	ip_proxy.h \
     96 	ip_raudio_pxy.c \
     97 	ip_rcmd_pxy.c \
     98 	ip_rpcb_pxy.c \
     99 	ip_scan.c \
    100 	ip_scan.h \
    101 	ip_state.c \
    102 	ip_state.h \
    103 	ip_sync.c \
    104 	ip_sync.h \
    105 	ip_tftp_pxy.c \
    106 	ipf_rb.h \
    107 	ipl.h \
    108 	radix_ipf.c \
    109 	radix_ipf.h \
    110 	$dsys
    111 cd $r/test
    112 pax -rvw * $dtest
    113 list="
    114 4bsd
    115 AIX
    116 BSD
    117 BSDOS
    118 BSDOS3
    119 BSDOS4
    120 COMPILE.2.5
    121 COMPILE.Solaris2
    122 FAQ.FreeBSD
    123 FreeBSD
    124 FreeBSD-2.2
    125 FreeBSD-3
    126 FreeBSD-4.0
    127 HPUX
    128 INST.FreeBSD-2.2
    129 INSTALL.BSDOS
    130 INSTALL.FreeBSD
    131 INSTALL.IRIX
    132 INSTALL.Sol2
    133 INSTALL.SunOS
    134 INSTALL.Tru64
    135 Linux
    136 IRIX
    137 OSF
    138 INSTALL.NetBSD
    139 INSTALL.Linux
    140 INSTALL.xBSD
    141 INSTALL.BSDOS3
    142 NAT.FreeBSD
    143 OpenBSD
    144 OpenBSD-2
    145 OpenBSD-3
    146 SunOS4
    147 SunOS5
    148 ipsend/.OLD
    149 BugReport
    150 IMPORTANT
    151 IPF.KANJI
    152 Makefile
    153 NetBSD
    154 NetBSD-1.2
    155 Y2K
    156 arc4random.c
    157 bsdinstall
    158 buildsunos
    159 fil.c
    160 hpux.c
    161 ip_auth.c
    162 ip_auth.h
    163 ip_compat.h
    164 ip_fil.h
    165 ip_fil_aix.c
    166 ip_fil_freebsd.c
    167 ip_fil_hpux.c
    168 ip_fil_irix.c
    169 ip_fil_linux.c
    170 ip_fil_netbsd.c
    171 ip_fil_openbsd.c
    172 ip_fil_osf.c
    173 ip_fil_solaris.c
    174 ip_fil_sunos4.c
    175 ip_frag.c
    176 ip_frag.h
    177 ip_ftp_pxy.c
    178 ip_ipsec_pxy.c
    179 ip_log.c
    180 ip_nat.c
    181 ip_nat.h
    182 ip_netbios_pxy.c
    183 ip_proxy.c
    184 ip_proxy.h
    185 ip_raudio_pxy.c
    186 ip_rcmd_pxy.c
    187 ip_state.c
    188 ip_state.h
    189 ipl.h
    190 iplang/Makefile
    191 ipsd/Makefile
    192 ipsend/Makefile
    193 l4check/Makefile
    194 lib/Makefile
    195 lib/printiphdr.c
    196 linux.c
    197 linux.h
    198 ml_ipl.c
    199 mlf_ipl.c
    200 mlf_rule.c
    201 mlfk_ipl.c
    202 mlfk_rule.c
    203 mlh_rule.c
    204 mli_ipl.c
    205 mln_ipl.c
    206 mlo_ipl.c
    207 mlo_rule.c
    208 mls_ipl.c
    209 mls_rule.c
    210 mlso_rule.c
    211 samples/Makefile
    212 solaris.c
    213 test
    214 tools/Makefile
    215 tru64.c
    216 "
    217 
    218 ### Remove uninteresting bits
    219 echo "removing extraneous files and directiones."
    220 (
    221 	cd ${dbase}
    222 	find . -name .cvsignore | xargs /bin/rm -f
    223 	for i in $list; do
    224 		echo "removing $i";
    225 		/bin/rm -rf "$i"
    226 	done
    227 )
    228 (
    229 	cd ${dtest}
    230 	for i in Makefile expected/Makefile; do
    231 		echo "removing $i";
    232 		/bin/rm -rf "$i"
    233 	done
    234 )
    235 echo done
    236 
    237 ### Remove the $'s around various RCSIDs
    238 cleantags $dest
    239 
    240 ### Add our NetBSD RCS Id
    241 find $dest -type f -name '*.[chly]' -print | while read c; do
    242 	sed 1q < $c | grep -q '\$NetBSD' || (
    243 echo "/*	\$NetBSD\$	*/" >/tmp/ipf2n$$
    244 echo "" >>/tmp/ipf2n$$
    245 cat $c  >> /tmp/ipf2n$$
    246 mv /tmp/ipf2n$$ $c # && echo added RCS tag to $c
    247 	)
    248 done
    249 
    250 find $dest -type f -name '*.[0-9]' -a \! -name 'example.*' -a \! -name 'ipv6.*' -print | while read m; do
    251 	sed 1q < $m | grep -q '\$NetBSD' || (
    252 echo ".\\\"	\$NetBSD\$" >/tmp/ipf2m$$
    253 echo ".\\\"" >>/tmp/ipf2m$$
    254 	cat $m >> /tmp/ipf2m$$
    255 	mv /tmp/ipf2m$$ $m # && echo added RCS tag to $m
    256 	)
    257 done
    258 
    259 find $dest -type f -name 'example.*' -print | while read e; do
    260 	sed 1q < $e | grep -q '\$NetBSD' || (
    261 echo "#	\$NetBSD\$" >/tmp/ipf2e$$
    262 	cat $e >> /tmp/ipf2e$$
    263 	mv /tmp/ipf2e$$ $e # && echo added RCS tag to $e
    264 	)
    265 done
    266 
    267 echo done
    268 
    269 ### Clean up any CVS directories that might be around.
    270 echo "cleaning up CVS residue."
    271 (
    272 	cd $dest
    273 	find . -type d -name "CVS" -print | xargs rm -r
    274 )
    275 echo done
    276 
    277 ### Fixing file and directory permissions.
    278 echo "Fixing file/directory permissions."
    279 (
    280 	cd $dest
    281 	find . -type f -print | xargs chmod u+rw,go+r
    282 	find . -type d -print | xargs chmod u+rwx,go+rx
    283 )
    284 echo done
    285 
    286 exit 0
    287 
    288