dtc2netbsd revision 1.1 1 #! /bin/sh
2 #
3 # $NetBSD: dtc2netbsd,v 1.1 2017/06/08 15:51:12 skrll 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 if [ $# -ne 2 ]; then echo "dtc2netbsd dtcsrc tmpdir"; exit 1; fi
57
58 r=$1
59 d=$2
60
61 case "$d" in
62 /*)
63 ;;
64 *)
65 d=`/bin/pwd`/$d
66 ;;
67 esac
68
69 case "$r" in
70 /*)
71 ;;
72 *)
73 r=`/bin/pwd`/$r
74 ;;
75 esac
76
77 echo preparing directory $d
78 rm -rf $d
79 mkdir -p $d/dtc
80
81 ### Copy the files and directories
82 echo copying $r to $d
83 cd $r
84 pax -rw * $d/dtc
85 mv $d/dtc/libfdt $d/libfdt
86
87 # cd to import directory
88 cd $d
89
90 #
91
92 ### Remove the $'s around RCS tags
93 cleantags $d
94
95 ### Add our NetBSD RCS Id
96 find $d -type f -name '*.[chly]' -print | while read c; do
97 sed 1q < $c | grep -q '\$NetBSD' || (
98 echo "/* \$NetBSD\$ */" >/tmp/dtc$$
99 echo "" >>/tmp/dtc$$
100 cat $c >> /tmp/dtc$$
101 mv /tmp/dtc$$ $c && echo added NetBSD RCS tag to $c
102 )
103 done
104
105 echo done
106
107 ### Clean up any CVS directories that might be around.
108 echo "cleaning up CVS residue."
109 (
110 cd $d
111 find . -type d -name "CVS" -print | xargs rm -r
112 )
113 echo done
114
115 ### Fixing file and directory permissions.
116 echo "Fixing file/directory permissions."
117 (
118 cd $d
119 find . -type f -print | xargs chmod u+rw,go+r
120 find . -type d -print | xargs chmod u+rwx,go+rx
121 )
122 echo done
123
124 exit 0
125