Home | History | Annotate | Line # | Download | only in rcs
      1  1.1  christos #! /bin/sh
      2  1.1  christos #
      3  1.2    rillig #	$NetBSD: rcs2netbsd,v 1.2 2024/09/08 09:36:47 rillig Exp $
      4  1.1  christos #
      5  1.1  christos # Copyright (c) 2016 The NetBSD Foundation, Inc.
      6  1.1  christos # All rights reserved.
      7  1.1  christos #
      8  1.1  christos # Redistribution and use in source and binary forms, with or without
      9  1.1  christos # modification, are permitted provided that the following conditions
     10  1.1  christos # are met:
     11  1.1  christos # 1. Redistributions of source code must retain the above copyright
     12  1.1  christos #    notice, this list of conditions and the following disclaimer.
     13  1.1  christos # 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  christos #    notice, this list of conditions and the following disclaimer in the
     15  1.1  christos #    documentation and/or other materials provided with the distribution.
     16  1.1  christos #
     17  1.1  christos # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18  1.1  christos # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  1.1  christos # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  1.1  christos # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21  1.1  christos # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  1.1  christos # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  1.1  christos # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  1.1  christos # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  1.1  christos # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26  1.1  christos # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  1.1  christos # POSSIBILITY OF SUCH DAMAGE.
     28  1.1  christos #
     29  1.2    rillig # rcs2netbsd:  convert a glibc source tree into a
     30  1.1  christos # netbsd rcs source tree, 
     31  1.1  christos #
     32  1.1  christos # Rough instructions for importing new rcs release:
     33  1.1  christos #
     34  1.1  christos #	$ cd /some/where/temporary
     35  1.1  christos #	$ tar xpfz /malloc/release/tar/file
     36  1.1  christos #	$ sh /usr/src/external/gpl2/rcs/rcs2netbsd malloc `pwd`
     37  1.1  christos #	$ cd `pwd`/src/external/gpl2/rcs/dist
     38  1.1  christos #	$ cvs import -m "Import rcs rcs x.y" src/external/gpl2/rcs/dist FSF rcs-x-y
     39  1.1  christos # merge sources according to instructions given
     40  1.1  christos # e.g. cvs -d cvs.netbsd.org:/cvsroot checkout -jrcs-1-19 -jrcs-1-19-1 src/gnu/dist/rcs
     41  1.1  christos 
     42  1.1  christos if [ $# -ne 2 ]; then echo "rcs2netbsd src dest"; exit 1; fi
     43  1.1  christos 
     44  1.1  christos r=$1
     45  1.1  christos d=$2/src/external/gpl2/rcs/dist
     46  1.1  christos 
     47  1.1  christos case "$d" in
     48  1.1  christos 	/*)
     49  1.1  christos 		;;
     50  1.1  christos 	*)
     51  1.1  christos 		d=`/bin/pwd`/$d
     52  1.1  christos 		;;
     53  1.1  christos esac
     54  1.1  christos 
     55  1.1  christos case "$r" in
     56  1.1  christos 	/*)
     57  1.1  christos 		;;
     58  1.1  christos 	*)
     59  1.1  christos 		r=`/bin/pwd`/$r
     60  1.1  christos 		;;
     61  1.1  christos esac
     62  1.1  christos 
     63  1.1  christos echo preparing directory $d
     64  1.1  christos rm -rf $d
     65  1.1  christos mkdir -p $d
     66  1.1  christos 
     67  1.1  christos ### Copy the files and directories
     68  1.1  christos echo copying $r to $d
     69  1.1  christos cd $r
     70  1.1  christos pax -rw * $d
     71  1.1  christos chmod -x $d/*
     72  1.1  christos 
     73  1.1  christos # cd to import directory
     74  1.1  christos cd $d
     75  1.1  christos 
     76  1.1  christos #
     77  1.1  christos 
     78  1.1  christos ### Remove the $'s around RCS tags
     79  1.1  christos cleantags $d
     80  1.1  christos 
     81  1.1  christos ### Add our NetBSD RCS Id
     82  1.1  christos find $d -type f -name '*.[chly]' -print | while read c; do
     83  1.1  christos 	sed 1q < $c | grep -q '\$NetBSD' || (
     84  1.1  christos echo "/*	\$NetBSD\$	*/" >/tmp/rcs3n$$
     85  1.1  christos echo "" >>/tmp/rcs3n$$
     86  1.1  christos cat $c  >> /tmp/rcs3n$$
     87  1.1  christos mv /tmp/rcs3n$$ $c && echo added NetBSD RCS tag to $c
     88  1.1  christos 	)
     89  1.1  christos done
     90  1.1  christos 
     91  1.1  christos find $d -type f -name '*.cpp' -print | while read c; do
     92  1.1  christos 	sed 1q < $c | grep -q '\$NetBSD' || (
     93  1.1  christos echo "/*	\$NetBSD\$	*/" >/tmp/rcs3n$$
     94  1.1  christos echo "" >>/tmp/rcs3n$$
     95  1.1  christos cat $c  >> /tmp/rcs3n$$
     96  1.1  christos mv /tmp/rcs3n$$ $c && echo added NetBSD RCS tag to $c
     97  1.1  christos 	)
     98  1.1  christos done
     99  1.1  christos 
    100  1.1  christos find $d -type f -name '*.[0-9]' -print | while read m; do
    101  1.1  christos 	sed 1q < $m | grep -q '\$NetBSD' || (
    102  1.1  christos echo ".\\\"	\$NetBSD\$" >/tmp/rcs2m$$
    103  1.1  christos echo ".\\\"" >>/tmp/rcs2m$$
    104  1.1  christos cat $m >> /tmp/rcs2m$$
    105  1.1  christos mv /tmp/rcs2m$$ $m && echo added NetBSD RCS tag to $m
    106  1.1  christos 	)
    107  1.1  christos done
    108  1.1  christos 
    109  1.1  christos find $d -type f -name '*.texi' -print | while read t; do
    110  1.1  christos         sed "2 s/^/@c \$NetBSD\$\\
    111  1.1  christos /" < $t > /tmp/rcs4t$$
    112  1.1  christos 	mv /tmp/rcs4t$$ $t && echo added NetBSD RCS tag to $t
    113  1.1  christos done
    114  1.1  christos 
    115  1.1  christos echo done
    116  1.1  christos 
    117  1.1  christos ### Clean up any CVS directories that might be around.
    118  1.1  christos echo "cleaning up CVS residue."
    119  1.1  christos (
    120  1.1  christos 	cd $d
    121  1.1  christos 	find . -type d -name "CVS" -print | xargs rm -r
    122  1.1  christos )
    123  1.1  christos echo done
    124  1.1  christos 
    125  1.1  christos ### Fixing file and directory permissions.
    126  1.1  christos echo "Fixing file/directory permissions."
    127  1.1  christos (
    128  1.1  christos 	cd $d
    129  1.1  christos 	find . -type f -print | xargs chmod u+rw,go+r
    130  1.1  christos 	find . -type d -print | xargs chmod u+rwx,go+rx
    131  1.1  christos )
    132  1.1  christos echo done
    133  1.1  christos 
    134  1.1  christos exit 0
    135