11.1Sjmcneill#! /bin/sh 21.1Sjmcneill# 31.4Sskrll# $NetBSD: dts2netbsd,v 1.4 2021/11/13 08:35:54 skrll Exp $ */ 41.1Sjmcneill# 51.1Sjmcneill# Copyright (c) 2013, 2017 The NetBSD Foundation, Inc. 61.1Sjmcneill# All rights reserved. 71.1Sjmcneill# 81.1Sjmcneill# Redistribution and use in source and binary forms, with or without 91.1Sjmcneill# modification, are permitted provided that the following conditions 101.1Sjmcneill# are met: 111.1Sjmcneill# 1. Redistributions of source code must retain the above copyright 121.1Sjmcneill# notice, this list of conditions and the following disclaimer. 131.1Sjmcneill# 2. Redistributions in binary form must reproduce the above copyright 141.1Sjmcneill# notice, this list of conditions and the following disclaimer in the 151.1Sjmcneill# documentation and/or other materials provided with the distribution. 161.1Sjmcneill# 171.1Sjmcneill# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 181.1Sjmcneill# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 191.1Sjmcneill# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 201.1Sjmcneill# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 211.1Sjmcneill# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 221.1Sjmcneill# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 231.1Sjmcneill# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 241.1Sjmcneill# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 251.1Sjmcneill# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 261.1Sjmcneill# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 271.1Sjmcneill# POSSIBILITY OF SUCH DAMAGE. 281.1Sjmcneill# 291.1Sjmcneill# dts2netbsd: prepare the dts source files and headers for import into the 301.1Sjmcneill# netbsd dts source tree, under src/sys/external/gpl2/dts/dist, 311.1Sjmcneill# based on the other *2netbsd scripts in the NetBSD source tree 321.1Sjmcneill# 331.1Sjmcneill# Instructions for importing new dts release: 341.1Sjmcneill# 351.1Sjmcneill# $ cd /some/where/temporary 361.4Sskrll# $ ftp https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.x.y.tar.xz 371.4Sskrll# $ tar -jxvf linux-5.x.y.tar.xz 381.4Sskrll# $ DTSSRCS=$(pwd)/linux-5.x.y 391.1Sjmcneill# $ WRKDIR=/an/other/temporary 401.1Sjmcneill# $ sh /usr/src/sys/external/gpl2/dts/dts2netbsd $DTSSRCS $WRKDIR 411.1Sjmcneill# $ cd $WRKDIR 421.4Sskrll# $ 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 431.1Sjmcneill# 441.1Sjmcneill 451.1Sjmcneillif [ $# -ne 2 ]; then echo "dts2netbsd src dest"; exit 1; fi 461.1Sjmcneill 471.1Sjmcneillr=$1 481.1Sjmcneilld=$2 491.1Sjmcneill 501.1Sjmcneillcase "$d" in 511.1Sjmcneill /*) 521.1Sjmcneill ;; 531.1Sjmcneill *) 541.1Sjmcneill d=`/bin/pwd`/$d 551.1Sjmcneill ;; 561.1Sjmcneillesac 571.1Sjmcneill 581.1Sjmcneillcase "$r" in 591.1Sjmcneill /*) 601.1Sjmcneill ;; 611.1Sjmcneill *) 621.1Sjmcneill r=`/bin/pwd`/$r 631.1Sjmcneill ;; 641.1Sjmcneillesac 651.1Sjmcneill 661.1Sjmcneillecho preparing directory $d 671.1Sjmcneillrm -rf $d 681.1Sjmcneillmkdir -p $d 691.1Sjmcneill 701.1Sjmcneill### Copy the files and directories 711.1Sjmcneillecho copying $r to $d 721.1Sjmcneillcd $r 731.1Sjmcneill 741.1Sjmcneillmkdir -p $d/include 751.3Sjmcneillcp -RL $r/include/dt-bindings $d/include 761.1Sjmcneill 771.4Sskrllfor arch in arm arm64 mips riscv; do 781.1Sjmcneill mkdir -p $d/arch/${arch}/boot 791.3Sjmcneill cp -RL $r/arch/${arch}/boot/dts $d/arch/${arch}/boot 801.2Sjmcneill rm -rf $d/arch/${arch}/boot/dts/include 811.1Sjmcneilldone 821.1Sjmcneill 831.1Sjmcneill# cd to import directory 841.1Sjmcneillcd $d 851.1Sjmcneill 861.1Sjmcneill### dts distribution doesn't have RCS/CVS tags, so add them. 871.1Sjmcneill 881.1Sjmcneill### Add our NetBSD RCS Id 891.1Sjmcneillfind $d -type f -name '*.[ch]' -print | while read c; do 901.1Sjmcneill sed 1q < $c | grep -q '\$NetBSD' || ( 911.1Sjmcneillecho "/* \$NetBSD\$ */" >/tmp/dts2n$$ 921.1Sjmcneillecho "" >>/tmp/dts2n$$ 931.1Sjmcneillcat $c >> /tmp/dts2n$$ 941.1Sjmcneillmv /tmp/dts2n$$ $c && echo added NetBSD RCS tag to $c 951.1Sjmcneill ) 961.1Sjmcneilldone 971.1Sjmcneill 981.1Sjmcneillecho done 991.1Sjmcneill 1001.1Sjmcneill### Clean up any CVS directories that might be around. 1011.1Sjmcneillecho "cleaning up CVS residue." 1021.1Sjmcneill( 1031.1Sjmcneill cd $d 1041.1Sjmcneill find . -type d -name "CVS" -print | xargs rm -r 1051.1Sjmcneill) 1061.1Sjmcneillecho done 1071.1Sjmcneill 1081.1Sjmcneill### Fixing file and directory permissions. 1091.1Sjmcneillecho "Fixing file/directory permissions." 1101.1Sjmcneill( 1111.1Sjmcneill cd $d 1121.1Sjmcneill find . -type f -print | xargs chmod u+rw,go+r 1131.1Sjmcneill find . -type d -print | xargs chmod u+rwx,go+rx 1141.1Sjmcneill) 1151.1Sjmcneillecho done 1161.1Sjmcneill 1171.1Sjmcneillexit 0 118