1 #! /bin/sh 2 # 3 # $NetBSD: send-pr2netbsd,v 1.2 2024/09/08 09:36:47 rillig Exp $ 4 # 5 # Copyright (c) 2016 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 # send-pr2netbsd: convert a glibc source tree into a 30 # netbsd send-pr source tree, 31 # 32 # Rough instructions for importing new send-pr release: 33 # 34 # $ cd /some/where/temporary 35 # $ tar xpfz /gnats/release/tar/file 36 # $ sh /usr/src/external/gpl2/send-pr/libmalloc2netbsd malloc `pwd` 37 # $ cd `pwd`/src/external/gpl2/send-pr/dist 38 # $ cvs import -m "Import send-pr YYYY-MM-DD" src/external/gpl2/send-pr/dist FSF 39 # merge sources according to instructions given 40 # e.g. cvs -d cvs.netbsd.org:/cvsroot checkout -jsend-pr-1-19 -jlibmalloc-1-19-1 src/gnu/dist/libmalloc 41 42 if [ $# -ne 2 ]; then echo "send-pr2netbsd src dest"; exit 1; fi 43 44 r=$1 45 d=$2/src/external/gpl2/send-pr/dist 46 47 case "$d" in 48 /*) 49 ;; 50 *) 51 d=`/bin/pwd`/$d 52 ;; 53 esac 54 55 case "$r" in 56 /*) 57 ;; 58 *) 59 r=`/bin/pwd`/$r 60 ;; 61 esac 62 63 echo preparing directory $d 64 rm -rf $d 65 mkdir -p $d 66 67 ### Copy the files and directories 68 echo copying $r to $d 69 cd $r 70 pax -rw send-pr $d 71 chmod -x $d/* 72 73 # cd to import directory 74 cd $d 75 76 # 77 78 ### Remove the $'s around RCS tags 79 cleantags $d 80 81 ### Add our NetBSD RCS Id 82 find $d -type f -name '*.[chly]' -print | while read c; do 83 sed 1q < $c | grep -q '\$NetBSD' || ( 84 echo "/* \$NetBSD\$ */" >/tmp/send-pr3n$$ 85 echo "" >>/tmp/send-pr3n$$ 86 cat $c >> /tmp/send-pr3n$$ 87 mv /tmp/send-pr3n$$ $c && echo added NetBSD RCS tag to $c 88 ) 89 done 90 91 find $d -type f -name '*.cpp' -print | while read c; do 92 sed 1q < $c | grep -q '\$NetBSD' || ( 93 echo "/* \$NetBSD\$ */" >/tmp/send-pr3n$$ 94 echo "" >>/tmp/send-pr3n$$ 95 cat $c >> /tmp/send-pr3n$$ 96 mv /tmp/send-pr3n$$ $c && echo added NetBSD RCS tag to $c 97 ) 98 done 99 100 find $d -type f -name '*.[0-9]' -print | while read m; do 101 sed 1q < $m | grep -q '\$NetBSD' || ( 102 echo ".\\\" \$NetBSD\$" >/tmp/send-pr2m$$ 103 echo ".\\\"" >>/tmp/send-pr2m$$ 104 cat $m >> /tmp/send-pr2m$$ 105 mv /tmp/send-pr2m$$ $m && echo added NetBSD RCS tag to $m 106 ) 107 done 108 109 find $d -type f -name '*.texi' -print | while read t; do 110 sed "2 s/^/@c \$NetBSD\$\\ 111 /" < $t > /tmp/send-pr4t$$ 112 mv /tmp/send-pr4t$$ $t && echo added NetBSD RCS tag to $t 113 done 114 115 echo done 116 117 ### Clean up any CVS directories that might be around. 118 echo "cleaning up CVS residue." 119 ( 120 cd $d 121 find . -type d -name "CVS" -print | xargs rm -r 122 ) 123 echo done 124 125 ### Fixing file and directory permissions. 126 echo "Fixing file/directory permissions." 127 ( 128 cd $d 129 find . -type f -print | xargs chmod u+rw,go+r 130 find . -type d -print | xargs chmod u+rwx,go+rx 131 ) 132 echo done 133 134 exit 0 135