1#! /bin/sh 2# 3# $NetBSD: ipf2netbsd,v 1.2 2012/03/23 23:14:34 christos 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 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 32 33if [ $# -ne 2 ]; then echo "ipf2netbsd src dest"; exit 1; fi 34 35r=$1 36dest=$2 37 38case "$dest" in 39 /*) 40 ;; 41 *) 42 dest=`/bin/pwd`/$dest 43 ;; 44esac 45 46dbase=$dest/src/external/bsd/ipf/dist 47dsys=$dest/src/sys/external/bsd/ipf/netinet 48#dlkm=$dest/src/sys/modules/ipf 49dtests=$dest/src/tests/ipf 50 51case "$r" in 52 /*) 53 ;; 54 *) 55 r=`/bin/pwd`/$r 56 ;; 57esac 58 59echo preparing directory $dbase, $dsys, $dlkm and $dregress 60rm -rf $dbase $dsys $dlkm $dregress 61 62### Copy the files and directories 63mkdir -p $dbase $dsys $dlkm $dregress 64cd $r 65pax -rvw . $dbase 66pax -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 111cd $r/test 112pax -rvw * $dtest 113list=" 1144bsd 115AIX 116BSD 117BSDOS 118BSDOS3 119BSDOS4 120COMPILE.2.5 121COMPILE.Solaris2 122FAQ.FreeBSD 123FreeBSD 124FreeBSD-2.2 125FreeBSD-3 126FreeBSD-4.0 127HPUX 128INST.FreeBSD-2.2 129INSTALL.BSDOS 130INSTALL.FreeBSD 131INSTALL.IRIX 132INSTALL.Sol2 133INSTALL.SunOS 134INSTALL.Tru64 135Linux 136IRIX 137OSF 138INSTALL.NetBSD 139INSTALL.Linux 140INSTALL.xBSD 141INSTALL.BSDOS3 142NAT.FreeBSD 143OpenBSD 144OpenBSD-2 145OpenBSD-3 146SunOS4 147SunOS5 148ipsend/.OLD 149BugReport 150IMPORTANT 151IPF.KANJI 152Makefile 153NetBSD 154NetBSD-1.2 155Y2K 156arc4random.c 157bsdinstall 158buildsunos 159fil.c 160hpux.c 161ip_auth.c 162ip_auth.h 163ip_compat.h 164ip_fil.h 165ip_fil_aix.c 166ip_fil_freebsd.c 167ip_fil_hpux.c 168ip_fil_irix.c 169ip_fil_linux.c 170ip_fil_netbsd.c 171ip_fil_openbsd.c 172ip_fil_osf.c 173ip_fil_solaris.c 174ip_fil_sunos4.c 175ip_frag.c 176ip_frag.h 177ip_ftp_pxy.c 178ip_ipsec_pxy.c 179ip_log.c 180ip_nat.c 181ip_nat.h 182ip_netbios_pxy.c 183ip_proxy.c 184ip_proxy.h 185ip_raudio_pxy.c 186ip_rcmd_pxy.c 187ip_state.c 188ip_state.h 189ipl.h 190iplang/Makefile 191ipsd/Makefile 192ipsend/Makefile 193l4check/Makefile 194lib/Makefile 195lib/printiphdr.c 196linux.c 197linux.h 198ml_ipl.c 199mlf_ipl.c 200mlf_rule.c 201mlfk_ipl.c 202mlfk_rule.c 203mlh_rule.c 204mli_ipl.c 205mln_ipl.c 206mlo_ipl.c 207mlo_rule.c 208mls_ipl.c 209mls_rule.c 210mlso_rule.c 211samples/Makefile 212solaris.c 213test 214tools/Makefile 215tru64.c 216" 217 218### Remove uninteresting bits 219echo "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) 235echo done 236 237### Remove the $'s around various RCSIDs 238cleantags $dest 239 240### Add our NetBSD RCS Id 241find $dest -type f -name '*.[chly]' -print | while read c; do 242 sed 1q < $c | grep -q '\$NetBSD' || ( 243echo "/* \$NetBSD\$ */" >/tmp/ipf2n$$ 244echo "" >>/tmp/ipf2n$$ 245cat $c >> /tmp/ipf2n$$ 246mv /tmp/ipf2n$$ $c # && echo added RCS tag to $c 247 ) 248done 249 250find $dest -type f -name '*.[0-9]' -a \! -name 'example.*' -a \! -name 'ipv6.*' -print | while read m; do 251 sed 1q < $m | grep -q '\$NetBSD' || ( 252echo ".\\\" \$NetBSD\$" >/tmp/ipf2m$$ 253echo ".\\\"" >>/tmp/ipf2m$$ 254 cat $m >> /tmp/ipf2m$$ 255 mv /tmp/ipf2m$$ $m # && echo added RCS tag to $m 256 ) 257done 258 259find $dest -type f -name 'example.*' -print | while read e; do 260 sed 1q < $e | grep -q '\$NetBSD' || ( 261echo "# \$NetBSD\$" >/tmp/ipf2e$$ 262 cat $e >> /tmp/ipf2e$$ 263 mv /tmp/ipf2e$$ $e # && echo added RCS tag to $e 264 ) 265done 266 267echo done 268 269### Clean up any CVS directories that might be around. 270echo "cleaning up CVS residue." 271( 272 cd $dest 273 find . -type d -name "CVS" -print | xargs rm -r 274) 275echo done 276 277### Fixing file and directory permissions. 278echo "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) 284echo done 285 286exit 0 287 288