xref: /netbsd-src/external/gpl2/send-pr/send-pr2netbsd (revision 5b28f239895d55856221c590945769250e289f5f)
1592de268Schristos#! /bin/sh
2592de268Schristos#
3*5b28f239Srillig#	$NetBSD: send-pr2netbsd,v 1.2 2024/09/08 09:36:47 rillig Exp $
4592de268Schristos#
5592de268Schristos# Copyright (c) 2016 The NetBSD Foundation, Inc.
6592de268Schristos# All rights reserved.
7592de268Schristos#
8592de268Schristos# Redistribution and use in source and binary forms, with or without
9592de268Schristos# modification, are permitted provided that the following conditions
10592de268Schristos# are met:
11592de268Schristos# 1. Redistributions of source code must retain the above copyright
12592de268Schristos#    notice, this list of conditions and the following disclaimer.
13592de268Schristos# 2. Redistributions in binary form must reproduce the above copyright
14592de268Schristos#    notice, this list of conditions and the following disclaimer in the
15592de268Schristos#    documentation and/or other materials provided with the distribution.
16592de268Schristos#
17592de268Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18592de268Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19592de268Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20592de268Schristos# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21592de268Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22592de268Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23592de268Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24592de268Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25592de268Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26592de268Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27592de268Schristos# POSSIBILITY OF SUCH DAMAGE.
28592de268Schristos#
29*5b28f239Srillig# send-pr2netbsd:  convert a glibc source tree into a
30592de268Schristos# netbsd send-pr source tree,
31592de268Schristos#
32592de268Schristos# Rough instructions for importing new send-pr release:
33592de268Schristos#
34592de268Schristos#	$ cd /some/where/temporary
35592de268Schristos#	$ tar xpfz /gnats/release/tar/file
36592de268Schristos#	$ sh /usr/src/external/gpl2/send-pr/libmalloc2netbsd malloc `pwd`
37592de268Schristos#	$ cd `pwd`/src/external/gpl2/send-pr/dist
38592de268Schristos#	$ cvs import -m "Import send-pr YYYY-MM-DD" src/external/gpl2/send-pr/dist FSF
39592de268Schristos# merge sources according to instructions given
40592de268Schristos# e.g. cvs -d cvs.netbsd.org:/cvsroot checkout -jsend-pr-1-19 -jlibmalloc-1-19-1 src/gnu/dist/libmalloc
41592de268Schristos
42592de268Schristosif [ $# -ne 2 ]; then echo "send-pr2netbsd src dest"; exit 1; fi
43592de268Schristos
44592de268Schristosr=$1
45592de268Schristosd=$2/src/external/gpl2/send-pr/dist
46592de268Schristos
47592de268Schristoscase "$d" in
48592de268Schristos	/*)
49592de268Schristos		;;
50592de268Schristos	*)
51592de268Schristos		d=`/bin/pwd`/$d
52592de268Schristos		;;
53592de268Schristosesac
54592de268Schristos
55592de268Schristoscase "$r" in
56592de268Schristos	/*)
57592de268Schristos		;;
58592de268Schristos	*)
59592de268Schristos		r=`/bin/pwd`/$r
60592de268Schristos		;;
61592de268Schristosesac
62592de268Schristos
63592de268Schristosecho preparing directory $d
64592de268Schristosrm -rf $d
65592de268Schristosmkdir -p $d
66592de268Schristos
67592de268Schristos### Copy the files and directories
68592de268Schristosecho copying $r to $d
69592de268Schristoscd $r
70592de268Schristospax -rw send-pr $d
71592de268Schristoschmod -x $d/*
72592de268Schristos
73592de268Schristos# cd to import directory
74592de268Schristoscd $d
75592de268Schristos
76592de268Schristos#
77592de268Schristos
78592de268Schristos### Remove the $'s around RCS tags
79592de268Schristoscleantags $d
80592de268Schristos
81592de268Schristos### Add our NetBSD RCS Id
82592de268Schristosfind $d -type f -name '*.[chly]' -print | while read c; do
83592de268Schristos	sed 1q < $c | grep -q '\$NetBSD' || (
84592de268Schristosecho "/*	\$NetBSD\$	*/" >/tmp/send-pr3n$$
85592de268Schristosecho "" >>/tmp/send-pr3n$$
86592de268Schristoscat $c  >> /tmp/send-pr3n$$
87592de268Schristosmv /tmp/send-pr3n$$ $c && echo added NetBSD RCS tag to $c
88592de268Schristos	)
89592de268Schristosdone
90592de268Schristos
91592de268Schristosfind $d -type f -name '*.cpp' -print | while read c; do
92592de268Schristos	sed 1q < $c | grep -q '\$NetBSD' || (
93592de268Schristosecho "/*	\$NetBSD\$	*/" >/tmp/send-pr3n$$
94592de268Schristosecho "" >>/tmp/send-pr3n$$
95592de268Schristoscat $c  >> /tmp/send-pr3n$$
96592de268Schristosmv /tmp/send-pr3n$$ $c && echo added NetBSD RCS tag to $c
97592de268Schristos	)
98592de268Schristosdone
99592de268Schristos
100592de268Schristosfind $d -type f -name '*.[0-9]' -print | while read m; do
101592de268Schristos	sed 1q < $m | grep -q '\$NetBSD' || (
102592de268Schristosecho ".\\\"	\$NetBSD\$" >/tmp/send-pr2m$$
103592de268Schristosecho ".\\\"" >>/tmp/send-pr2m$$
104592de268Schristoscat $m >> /tmp/send-pr2m$$
105592de268Schristosmv /tmp/send-pr2m$$ $m && echo added NetBSD RCS tag to $m
106592de268Schristos	)
107592de268Schristosdone
108592de268Schristos
109592de268Schristosfind $d -type f -name '*.texi' -print | while read t; do
110592de268Schristos        sed "2 s/^/@c \$NetBSD\$\\
111592de268Schristos/" < $t > /tmp/send-pr4t$$
112592de268Schristos	mv /tmp/send-pr4t$$ $t && echo added NetBSD RCS tag to $t
113592de268Schristosdone
114592de268Schristos
115592de268Schristosecho done
116592de268Schristos
117592de268Schristos### Clean up any CVS directories that might be around.
118592de268Schristosecho "cleaning up CVS residue."
119592de268Schristos(
120592de268Schristos	cd $d
121592de268Schristos	find . -type d -name "CVS" -print | xargs rm -r
122592de268Schristos)
123592de268Schristosecho done
124592de268Schristos
125592de268Schristos### Fixing file and directory permissions.
126592de268Schristosecho "Fixing file/directory permissions."
127592de268Schristos(
128592de268Schristos	cd $d
129592de268Schristos	find . -type f -print | xargs chmod u+rw,go+r
130592de268Schristos	find . -type d -print | xargs chmod u+rwx,go+rx
131592de268Schristos)
132592de268Schristosecho done
133592de268Schristos
134592de268Schristosexit 0
135