xref: /netbsd-src/external/mpl/dhcp/dhcp2netbsd (revision 56e2dc54c361727ddc9248251f043840f68d71b4)
17863ba46Schristos#! /bin/sh
27863ba46Schristos#
3*56e2dc54Schristos#	$NetBSD: dhcp2netbsd,v 1.3 2020/08/03 21:10:56 christos Exp $
47863ba46Schristos#
57863ba46Schristos# Copyright (c) 2003, 2011 The NetBSD Foundation, Inc.
67863ba46Schristos# All rights reserved.
77863ba46Schristos#
87863ba46Schristos# Redistribution and use in source and binary forms, with or without
97863ba46Schristos# modification, are permitted provided that the following conditions
107863ba46Schristos# are met:
117863ba46Schristos# 1. Redistributions of source code must retain the above copyright
127863ba46Schristos#    notice, this list of conditions and the following disclaimer.
137863ba46Schristos# 2. Redistributions in binary form must reproduce the above copyright
147863ba46Schristos#    notice, this list of conditions and the following disclaimer in the
157863ba46Schristos#    documentation and/or other materials provided with the distribution.
167863ba46Schristos#
177863ba46Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
187863ba46Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
197863ba46Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
207863ba46Schristos# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
217863ba46Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
227863ba46Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
237863ba46Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
247863ba46Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
257863ba46Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
267863ba46Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
277863ba46Schristos# POSSIBILITY OF SUCH DAMAGE.
287863ba46Schristos#
297863ba46Schristos# dhcp2netbsd:  convert a dhcp source tree into a
307863ba46Schristos# format suitable for import.  Works on current dir.
317863ba46Schristos# You can run this only once if you want it to work.
327863ba46Schristos#
337863ba46Schristos# based on file2netbsd
347863ba46Schristos#
357863ba46SchristosPROG="$(basename "$0")"
367863ba46Schristos
377863ba46Schristosif [ -z "$1" ]
387863ba46Schristosthen
397863ba46Schristos	echo "Usage: $PROG <directory>" 1>&2
407863ba46Schristos	exit 1
417863ba46Schristosfi
427863ba46SchristosFILE="$1"
437863ba46Schristos
447863ba46Schristos### Wipe out stuff we don't want
457863ba46Schristosrm -fr bind
467863ba46Schristos
477863ba46Schristos### Remove the $'s around RCS tags
487863ba46Schristoscleantags "$FILE"
497863ba46Schristos
507863ba46Schristos### Add NetBSD RCS Id
517863ba46Schristosfind "$FILE" -type f -name '*.[chly]' -print | while read c; do
527863ba46Schristos	sed -e '1{/$NetBSD/!{i\
537863ba46Schristos/*	\$NetBSD\$	*/\
547863ba46Schristos
557863ba46Schristos};}' $c > /tmp/dhcp1$$
567863ba46Schristosmv /tmp/dhcp1$$ $c && echo did source mods for $c
577863ba46Schristosdone
587863ba46Schristos
597863ba46Schristosfind "$FILE" -type f -name '*.[cly]' -print | while read c; do
607863ba46Schristossed -e \
617863ba46Schristos'/:\/\/www.isc.org/,/^ \*\// {
627863ba46Schristos    /^ \*\//a\
637863ba46Schristos\
647863ba46Schristos#include <sys/cdefs.h>\
657863ba46Schristos__RCSID("\$NetBSD\$");
667863ba46Schristos}' $c > /tmp/dhcp1$$
677863ba46Schristosmv /tmp/dhcp1$$ $c && echo did source mods for $c
687863ba46Schristosdone
697863ba46Schristos
70*56e2dc54Schristosfor f in omapip/inet_addr.c omapip/iscprint.c server/dhcpv6.c \
717863ba46Schristos     server/dhcpleasequery.c server/ldap.c server/mdb6.c; do
727863ba46Schristos	c=$FILE/$f
737863ba46Schristos	sed -E -e \
747863ba46Schristos'/\* TH(E|IS) SOFTWARE/,/^ \*\// {
757863ba46Schristos    /^ \*\//a\
767863ba46Schristos\
777863ba46Schristos#include <sys/cdefs.h>\
787863ba46Schristos__RCSID("\$NetBSD\$");\
797863ba46Schristos
807863ba46Schristos}' $c > /tmp/dhcp1$$
817863ba46Schristos    mv /tmp/dhcp1$$ $c && echo did source mods for $c
827863ba46Schristosdone
837863ba46Schristos
847863ba46Schristos
857863ba46Schristos
867863ba46Schristos#### Add RCS tags to man pages
877863ba46Schristosfind "$FILE" -type f -name '*.[0-9]' -print | while read m; do
887863ba46Schristos	sed -e '1{/$NetBSD/!i\
897863ba46Schristos.\\"	\$NetBSD\$\
907863ba46Schristos.\\"
917863ba46Schristos
927863ba46Schristos}' $m > /tmp/dhcp2$$
937863ba46Schristosmv /tmp/dhcp2$$ $m && echo did manpage mods for $m
947863ba46Schristosdone
957863ba46Schristos
967863ba46Schristosecho done
977863ba46Schristos
987863ba46Schristosecho You can import now.  Use the following command:
99a41ce0a4Schristosecho cvs -d cvs.netbsd.org:/cvsroot import src/external/mpl/dhcp/dist ISC DHCPX_Y_Z
1007863ba46Schristos
1017863ba46Schristosexit 0
102