Home | History | Annotate | Line # | Download | only in groff
      1 #! /bin/sh
      2 #
      3 #	$NetBSD: groff2netbsd,v 1.2 2024/09/08 09:36:46 rillig Exp $
      4 #
      5 # Copyright (c) 2001-2003 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 # groff2netbsd:  convert a groff source tree into a
     30 # netbsd groff source tree, under basesrc/dist,
     31 # based on bind2netbsd by Bernd Ernesti and changes by Simon Burge
     32 #
     33 # Rough instructions for importing new groff release:
     34 #
     35 #	$ cd /some/where/temporary
     36 #	$ tar xpfz /new/groff/release/tar/file
     37 #	$ sh /usr/src/external/gpl2/groff/groff2netbsd groff-1.x.y `pwd`
     38 #	$ cd `pwd`/src/external/gpl2/groff/dist
     39 #	$ cvs import -m "Import groff 1.x.y" src/external/gpl2/groff/dist FSF groff-1-x-y
     40 # merge sources according to instructions given
     41 # e.g. cvs -d cvs.netbsd.org:/cvsroot checkout -jgroff-1-19 -jgroff-1-19-1 src/gnu/dist/groff
     42 #	$ cd ../../../groff-1.x.y
     43 #	$ run ./configure
     44 # merge newly generated src/include/config.h with 
     45 # /usr/src/gnu/usr.bin/groff/include/config.h; compare VARIABLES in Makefile
     46 # with those in /usr/src/gnu/usr.bin/groff/Makefile.inc
     47 #	$ cd ..
     48 #	$ rm -r gnusrc groff-1.x.y
     49 #	$ cd /usr/src/gnu/usr.bin/groff
     50 #	$ cvs commit -m "Updated autoconf generated files for groff 1.x.y."
     51 #
     52 #	- check makefiles to see if any extra sources have been added.
     53 #	- update distrib/sets if necessary.
     54 
     55 if [ $# -ne 2 ]; then echo "groff2netbsd src dest"; exit 1; fi
     56 
     57 r=$1
     58 d=$2/src/external/gpl2/groff/dist
     59 
     60 case "$d" in
     61 	/*)
     62 		;;
     63 	*)
     64 		d=`/bin/pwd`/$d
     65 		;;
     66 esac
     67 
     68 case "$r" in
     69 	/*)
     70 		;;
     71 	*)
     72 		r=`/bin/pwd`/$r
     73 		;;
     74 esac
     75 
     76 echo preparing directory $d
     77 rm -rf $d
     78 mkdir -p $d
     79 
     80 ### Copy the files and directories
     81 echo copying $r to $d
     82 cd $r
     83 pax -rw * $d
     84 
     85 # cd to import directory
     86 cd $d
     87 
     88 ### Remove the $'s around RCS tags
     89 cleantags $d
     90 
     91 ### Add our NetBSD RCS Id
     92 find $d -type f -name '*.[chly]' -print | while read c; do
     93 	sed 1q < $c | grep -q '\$NetBSD' || (
     94 echo "/*	\$NetBSD\$	*/" >/tmp/groff3n$$
     95 echo "" >>/tmp/groff3n$$
     96 cat $c  >> /tmp/groff3n$$
     97 mv /tmp/groff3n$$ $c && echo added NetBSD RCS tag to $c
     98 	)
     99 done
    100 
    101 find $d -type f -name '*.cpp' -print | while read c; do
    102 	sed 1q < $c | grep -q '\$NetBSD' || (
    103 echo "/*	\$NetBSD\$	*/" >/tmp/groff3n$$
    104 echo "" >>/tmp/groff3n$$
    105 cat $c  >> /tmp/groff3n$$
    106 mv /tmp/groff3n$$ $c && echo added NetBSD RCS tag to $c
    107 	)
    108 done
    109 
    110 find $d -type f -name '*.[0-9]' -print | while read m; do
    111 	sed 1q < $m | grep -q '\$NetBSD' || (
    112 echo ".\\\"	\$NetBSD\$" >/tmp/groff2m$$
    113 echo ".\\\"" >>/tmp/groff2m$$
    114 cat $m >> /tmp/groff2m$$
    115 mv /tmp/groff2m$$ $m && echo added NetBSD RCS tag to $m
    116 	)
    117 done
    118 
    119 find $d -type f -name '*.texi' -print | while read t; do
    120         sed "2 s/^/@c \$NetBSD\$\\
    121 /" < $t > /tmp/groff4t$$
    122 	mv /tmp/groff4t$$ $t && echo added NetBSD RCS tag to $t
    123 done
    124 
    125 echo done
    126 
    127 ### Clean up any CVS directories that might be around.
    128 echo "cleaning up CVS residue."
    129 (
    130 	cd $d
    131 	find . -type d -name "CVS" -print | xargs rm -r
    132 )
    133 echo done
    134 
    135 ### Fixing file and directory permissions.
    136 echo "Fixing file/directory permissions."
    137 (
    138 	cd $d
    139 	find . -type f -print | xargs chmod u+rw,go+r
    140 	find . -type d -print | xargs chmod u+rwx,go+rx
    141 )
    142 echo done
    143 
    144 exit 0
    145