1 #! /bin/sh 2 # 3 # $NetBSD: dts2netbsd,v 1.4 2021/11/13 08:35:54 skrll Exp $ */ 4 # 5 # Copyright (c) 2013, 2017 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 # dts2netbsd: prepare the dts source files and headers for import into the 30 # netbsd dts source tree, under src/sys/external/gpl2/dts/dist, 31 # based on the other *2netbsd scripts in the NetBSD source tree 32 # 33 # Instructions for importing new dts release: 34 # 35 # $ cd /some/where/temporary 36 # $ ftp https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.x.y.tar.xz 37 # $ tar -jxvf linux-5.x.y.tar.xz 38 # $ DTSSRCS=$(pwd)/linux-5.x.y 39 # $ WRKDIR=/an/other/temporary 40 # $ sh /usr/src/sys/external/gpl2/dts/dts2netbsd $DTSSRCS $WRKDIR 41 # $ cd $WRKDIR 42 # $ cvs -d cvs.netbsd.org:/cvsroot import -m "Import dts from Linux 5.x.y" src/sys/external/gpl2/dts/dist LINUX linux-5_x_y 43 # 44 45 if [ $# -ne 2 ]; then echo "dts2netbsd src dest"; exit 1; fi 46 47 r=$1 48 d=$2 49 50 case "$d" in 51 /*) 52 ;; 53 *) 54 d=`/bin/pwd`/$d 55 ;; 56 esac 57 58 case "$r" in 59 /*) 60 ;; 61 *) 62 r=`/bin/pwd`/$r 63 ;; 64 esac 65 66 echo preparing directory $d 67 rm -rf $d 68 mkdir -p $d 69 70 ### Copy the files and directories 71 echo copying $r to $d 72 cd $r 73 74 mkdir -p $d/include 75 cp -RL $r/include/dt-bindings $d/include 76 77 for arch in arm arm64 mips riscv; do 78 mkdir -p $d/arch/${arch}/boot 79 cp -RL $r/arch/${arch}/boot/dts $d/arch/${arch}/boot 80 rm -rf $d/arch/${arch}/boot/dts/include 81 done 82 83 # cd to import directory 84 cd $d 85 86 ### dts distribution doesn't have RCS/CVS tags, so add them. 87 88 ### Add our NetBSD RCS Id 89 find $d -type f -name '*.[ch]' -print | while read c; do 90 sed 1q < $c | grep -q '\$NetBSD' || ( 91 echo "/* \$NetBSD\$ */" >/tmp/dts2n$$ 92 echo "" >>/tmp/dts2n$$ 93 cat $c >> /tmp/dts2n$$ 94 mv /tmp/dts2n$$ $c && echo added NetBSD RCS tag to $c 95 ) 96 done 97 98 echo done 99 100 ### Clean up any CVS directories that might be around. 101 echo "cleaning up CVS residue." 102 ( 103 cd $d 104 find . -type d -name "CVS" -print | xargs rm -r 105 ) 106 echo done 107 108 ### Fixing file and directory permissions. 109 echo "Fixing file/directory permissions." 110 ( 111 cd $d 112 find . -type f -print | xargs chmod u+rw,go+r 113 find . -type d -print | xargs chmod u+rwx,go+rx 114 ) 115 echo done 116 117 exit 0 118