xref: /netbsd/external/bsd/am-utils/dist/amd2netbsd (revision 6550d01e)
1#! /bin/sh
2#
3#	$NetBSD: amd2netbsd,v 1.2 2009/03/20 20:30:52 christos Exp $
4#
5# Copyright (c) 2000 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# amd2netbsd:  convert an amd source tree into a
30# netbsd amd source tree, under src/dist,
31# based on bind2netbsd by Bernd Ernesti and changes by Simon Burge
32#
33# Rough instructions for importing new amd release:
34#
35#	$ cd /some/where/temporary
36#	$ tar xpfz /new/amd/release/tar/file
37#	$ sh /usr/src/external/bsd/am-utils/dist/amd2netbsd am-utils-6.x.y `pwd`
38#	$ cd src/dist/am-utils
39#	$ cvs -d cvs.netbsd.org:/cvsroot import -m "Import am-utils 6.x.y" src/external/bsd/am-utils/dist ezk am-utils-6-x-y
40#	$ cd ../../../am-utils-6.x.y
41#	$ run ./configure
42# merge newly generated config.h with /usr/src/usr.sbin/amd/include/config.h
43# very carefully, since autoconfig seems to be broken (at least in 6.0.4)
44#	$ cd ..
45#	$ rm -r src am-utils-6.x.y
46#	$ cd /usr/src/usr.sbin/amd
47#	$ cvs commit -m "Updated autoconf generated files for am-utils 6.x.y."
48#
49#	- check makefiles to see if any extra sources have been added.
50#	- update distrib/sets if necessary.
51
52if [ $# -ne 2 ]; then echo "amd2netbsd src dest"; exit 1; fi
53
54r=$1
55d=$2/src/external/bsd/am-utils/dist
56
57case "$d" in
58	/*)
59		;;
60	*)
61		d=`/bin/pwd`/$d
62		;;
63esac
64
65case "$r" in
66	/*)
67		;;
68	*)
69		r=`/bin/pwd`/$r
70		;;
71esac
72
73echo preparing directory $d
74rm -rf $d
75mkdir -p $d
76
77### Copy the files and directories
78echo copying $r to $d
79cd $r
80pax -rw * $d
81
82echo removing unneeded directories and files
83
84### Remove unneeded files
85cd $d
86rm -f doc/am-utils.dvi doc/am-utils.info* doc/am-utils.ps
87
88### Remove the $'s around RCS tags
89find $d -type f -print | xargs egrep -l '\$(Id|Created|Header)' | while read f; do
90	sed -e 's/\$\(Id.*\) \$/\1/' \
91	    -e 's/\$\(Created.*\) \$/\1/' \
92	    -e 's/\$\(Header.*\) \$/\1/' \
93	    < $f > /tmp/amd1f$$ && mv /tmp/amd1f$$ $f && \
94	echo removed \$RCS tag from $f
95done
96
97### Add our NetBSD RCS Id
98find $d -type f -name '*.[chly]' -print | while read c; do
99	sed 1q < $c | grep -q '\$NetBSD' || (
100echo "/*	\$NetBSD\$	*/" >/tmp/amd3n$$
101echo "" >>/tmp/amd3n$$
102cat $c  >> /tmp/amd3n$$
103mv /tmp/amd3n$$ $c && echo added NetBSD RCS tag to $c
104	)
105done
106
107find $d -type f -name '*.[0-9]' -print | while read m; do
108	sed 1q < $m | grep -q '\$NetBSD' || (
109echo ".\\\"	\$NetBSD\$" >/tmp/amd2m$$
110echo ".\\\"" >>/tmp/amd2m$$
111cat $m >> /tmp/amd2m$$
112mv /tmp/amd2m$$ $m && echo added NetBSD RCS tag to $m
113	)
114done
115
116find $d -type f -name '*.texi' -print | while read t; do
117        sed "2 s/^/@c \$NetBSD\$\\
118/" < $t > /tmp/amd4t$$
119	mv /tmp/amd4t$$ $t && echo added NetBSD RCS tag to $t
120done
121
122echo done
123
124### Clean up any CVS directories that might be around.
125echo "cleaning up CVS residue."
126(
127	cd $d
128	find . -type d -name "CVS" -print | xargs rm -r
129)
130echo done
131
132### Fixing file and directory permissions.
133echo "Fixing file/directory permissions."
134(
135	cd $d
136	find . -type f -print | xargs chmod u+rw,go+r
137	find . -type d -print | xargs chmod u+rwx,go+rx
138)
139echo done
140
141exit 0
142