Home | History | Annotate | Line # | Download | only in dtc
dtc2netbsd revision 1.2.4.2
      1 #! /bin/sh
      2 #
      3 #	$NetBSD: dtc2netbsd,v 1.2.4.2 2017/07/18 17:17:52 snj Exp $
      4 #
      5 #
      6 # Copyright (c) 2017 The NetBSD Foundation, Inc.
      7 # All rights reserved.
      8 #
      9 # This code is derived from software contributed to The NetBSD Foundation
     10 # by Nick Hudson
     11 #
     12 # Redistribution and use in source and binary forms, with or without
     13 # modification, are permitted provided that the following conditions
     14 # are met:
     15 # 1. Redistributions of source code must retain the above copyright
     16 #    notice, this list of conditions and the following disclaimer.
     17 # 2. Redistributions in binary form must reproduce the above copyright
     18 #    notice, this list of conditions and the following disclaimer in the
     19 #    documentation and/or other materials provided with the distribution.
     20 #
     21 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     22 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     25 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31 # POSSIBILITY OF SUCH DAMAGE.
     32 #
     33 # dtc2netbsd:  convert a dtc source tree into netbsd dtc/libfdt source trees
     34 #
     35 # Rough instructions for importing new dtc release:
     36 #
     37 #	$ cd /some/where/temporary
     38 #	$ tar xpfz /dtc/release/tar/file
     39 #	$ DTCSRCS=$(pwd)
     40 #	$ WRKDIR=/an/other/temporary
     41 #	$ sh /usr/src/external/gpl2/dtc/dtc2netbsd $DTCSRCS $WRKDIR
     42 #
     43 # Import libfdt using
     44 #	$ cd $WRKDIR/libfdt
     45 #	$ cvs import -m "Import libfdt <version>" src/sys/external/bsd/libfdt/dist DTC dtc-<version>
     46 #
     47 # merge libfdt sources using, e.g.
     48 #	$ cvs -d cvs.netbsd.org:/cvsroot checkout -jdtc-1-4-1 -jdtc-1-4-4 src/sys/external/bsd/libfdt/dist
     49 #
     50 # Import dtc using
     51 #	$ cd $WRKDIR/dtc
     52 #	$ cvs import -m "Import dtc YYYY-MM-DD" src/external/gpl2/dtc/dist DTC dtc-<version>
     53 # merge dtc sources using, e.g.
     54 # 	$ cvs -d cvs.netbsd.org:/cvsroot checkout -jdtc-1-4-1 -jdtc-1-4-4 src/external/gpl2/dtc/dist
     55 #
     56 # Update the version string in the version_gen.h header to match the imported version:
     57 #	$ echo '#define DTC_VERSION "DTC 1.4.4"' > src/external/gpl2/dtc/usr.bin/dtc/version_gen.h
     58 
     59 if [ $# -ne 2 ]; then echo "dtc2netbsd dtcsrc tmpdir"; exit 1; fi
     60 
     61 r=$1
     62 d=$2
     63 
     64 case "$d" in
     65 	/*)
     66 		;;
     67 	*)
     68 		d=`/bin/pwd`/$d
     69 		;;
     70 esac
     71 
     72 case "$r" in
     73 	/*)
     74 		;;
     75 	*)
     76 		r=`/bin/pwd`/$r
     77 		;;
     78 esac
     79 
     80 echo preparing directory $d
     81 rm -rf $d
     82 mkdir -p $d/dtc
     83 
     84 ### Copy the files and directories
     85 echo copying $r to $d
     86 cd $r
     87 pax -rw * $d/dtc
     88 mv $d/dtc/libfdt $d/libfdt
     89 
     90 # cd to import directory
     91 cd $d
     92 
     93 #
     94 
     95 ### Remove the $'s around RCS tags
     96 cleantags $d
     97 
     98 ### Add our NetBSD RCS Id
     99 find $d -type f -name '*.[chly]' -print | while read c; do
    100 	sed 1q < $c | grep -q '\$NetBSD' || (
    101 echo "/*	\$NetBSD\$	*/" >/tmp/dtc$$
    102 echo "" >>/tmp/dtc$$
    103 cat $c  >> /tmp/dtc$$
    104 mv /tmp/dtc$$ $c && echo added NetBSD RCS tag to $c
    105 	)
    106 done
    107 
    108 echo done
    109 
    110 ### Clean up any CVS directories that might be around.
    111 echo "cleaning up CVS residue."
    112 (
    113 	cd $d
    114 	find . -type d -name "CVS" -print | xargs rm -r
    115 )
    116 echo done
    117 
    118 ### Fixing file and directory permissions.
    119 echo "Fixing file/directory permissions."
    120 (
    121 	cd $d
    122 	find . -type f -print | xargs chmod u+rw,go+r
    123 	find . -type d -print | xargs chmod u+rwx,go+rx
    124 )
    125 echo done
    126 
    127 exit 0
    128