Home | History | Annotate | Line # | Download | only in bktr
bktr2netbsd revision 1.2
      1 #! /bin/sh
      2 #
      3 #	$NetBSD: bktr2netbsd,v 1.2 2000/05/07 03:01:58 wiz Exp $
      4 #
      5 # Copyright (c) 2000 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 # 3. All advertising materials mentioning features or use of this software
     17 #    must display the following acknowledgement:
     18 #	This product includes software developed by the NetBSD
     19 #	Foundation, Inc. and its contributors.
     20 # 4. Neither the name of The NetBSD Foundation nor the names of its
     21 #    contributors may be used to endorse or promote products derived
     22 #    from this software without specific prior written permission.
     23 #
     24 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34 # POSSIBILITY OF SUCH DAMAGE.
     35 #
     36 # bktr2netbsd:  convert a bktr source directory tree into a
     37 # netbsd bktr source tree, under sys/dev/pci/bktr
     38 # based on bind2netbsd by Bernd Ernesti
     39 
     40 if [ $# -ne 2 ]; then echo "bktr2netbsd src dest"; exit 1; fi
     41 
     42 r=$1
     43 d=$2/sys/dev/pci/bktr
     44 
     45 case "$d" in
     46 	/*)
     47 		;;
     48 	*)
     49 		d=`/bin/pwd`/$d
     50 		;;
     51 esac
     52 
     53 case "$r" in
     54 	/*)
     55 		;;
     56 	*)
     57 		r=`/bin/pwd`/$r
     58 		;;
     59 esac
     60 
     61 echo preparing directory $d
     62 rm -rf $d
     63 mkdir -p $d
     64 
     65 ### Copy the files
     66 echo copying $r to $d
     67 cd $r
     68 pax -rw * $d
     69 
     70 echo removing unneeded files
     71 
     72 ### Remove unneeded files
     73 cd $d
     74 rm CHANGELOG.TXT README.* bktr_i2c.[ch]
     75 
     76 ### Remove the $'s around RCS tags
     77 find $d -type f -print | xargs egrep -l '\$(Id|Created|Header|FreeBSD)' | while read f; do
     78 	sed -e 's/\$\(Id.*\) \$/\1/' \
     79 	    -e 's/\$\(Created.*\) \$/\1/' \
     80 	    -e 's/\$\(FreeBSD.*\) \$/\1/' \
     81 	    -e 's/\$\(Header.*\) \$/\1/' \
     82 	    < $f > /tmp/bktr1f$$ && mv /tmp/bktr1f$$ $f && \
     83 	echo removed \$RCS tag from $f
     84 done
     85 
     86 ### create bt8xx.h from ioctl_meteor.h and ioctl_bt848.h
     87 echo merging ioctl_meteor.h and ioctl_bt848.h to bt8xx.h
     88 echo "/* This file is merged from ioctl_meteor.h and ioctl_bt848.h from FreeBSD. */" > bt8xx.h
     89 echo "/* The copyright below only applies to the ioctl_meteor.h part of this file. */" >> bt8xx.h
     90 echo "" >> bt8xx.h
     91 echo "#ifndef _DEV_IC_BT8XX_H_" >> bt8xx.h
     92 echo "#define _DEV_IC_BT8XX_H_" >> bt8xx.h
     93 cat ioctl_meteor.h ioctl_bt848.h | grep -v _MACHINE_IOCTL_METEOR_H_ | \
     94 	grep -v _MACHINE_IOCTL_BT848_H >> bt8xx.h
     95 echo "#endif /* _DEV_IC_BT8XX_H_ */" >> bt8xx.h
     96 rm ioctl_meteor.h ioctl_bt848.h
     97 
     98 ### Add our NetBSD RCS Id
     99 find $d -name '*.[chly]' -print | while read c; do
    100 	sed 1q < $c | grep -q '\$NetBSD' || (
    101 echo "/*	\$NetBSD\$	*/" >/tmp/bktr3n$$
    102 echo "" >>/tmp/bktr3n$$
    103 cat $c  >> /tmp/bktr3n$$
    104 mv /tmp/bktr3n$$ $c && echo added NetBSD RCS tag to $c
    105 	)
    106 done
    107 
    108 echo done
    109 
    110 ### move bt8xx.h to correct place
    111 echo moving bt8xx.h to dev/ic
    112 mkdir -p $d/../../ic
    113 mv bt8xx.h $d/../../ic
    114 
    115 ### Clean up any CVS directories that might be around.
    116 echo "cleaning up CVS residue."
    117 (
    118 	cd $d
    119 	find . -type d -name "CVS" -print | xargs rm -r
    120 )
    121 echo done
    122 
    123 ### Fixing file and directory permissions.
    124 echo "Fixing file/directory permissions."
    125 (
    126 	cd $d
    127 	find . -type f -print | xargs chmod u+rw,go+r
    128 	find . -type d -print | xargs chmod u+rwx,go+rx
    129 )
    130 echo done
    131 
    132 echo Do not forget to also import bt8xx.h in dev/ic!
    133 exit 0
    134