xref: /minix3/external/bsd/less/less2netbsd (revision f7cf2976020bea4fd5cba55555e1b09b71a26953)
1#!/bin/sh
2#
3#	$NetBSD: less2netbsd,v 1.5 2011/07/03 23:25:01 tron Exp $
4#
5# Copyright (c) 2011 The NetBSD Foundation, Inc.
6# All rights reserved.
7#
8# This code is derived from software contributed to The NetBSD Foundation
9# by Matthias Scheler.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions
13# are met:
14# 1. Redistributions of source code must retain the above copyright
15#    notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright
17#    notice, this list of conditions and the following disclaimer in the
18#    documentation and/or other materials provided with the distribution.
19#
20# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30# POSSIBILITY OF SUCH DAMAGE.
31#
32
33# less2netbsd:
34# Prepare a less source tree for import into the NetBSD source repository.
35
36PROGNAME=$(basename "$0")
37if [ $# -ne 1 ]
38then
39	echo "Usage: $PROGNAME <dir>" >&2
40	exit 1
41fi
42DIRNAME="$1"
43
44# Change to the source directory.
45if [ -d "$DIRNAME" ] && cd "$DIRNAME"
46then
47	:
48else
49	echo "${PROGNAME}: cannot access directory \"$DIRNAME\"." >&2
50	exit
51fi
52
53# Check whether the source directory looks sane.
54CHECK_FILES="LICENSE configure less.h version.c"
55for FILENAME in $CHECK_FILES
56do
57	if [ ! -f "$FILENAME" ]
58	then
59		echo "${PROGNAME}: less distribution incomplete." >&2
60		exit
61	fi
62done
63
64# Check whether the "configure" was run.
65REQUIRED_HEADERS=defines.h
66for FILENAME in $REQUIRED_HEADERS
67do
68	if [ ! -f "$FILENAME" ]
69	then
70		echo "${PROGNAME}: Please run \"./configure\"." >&2
71		exit
72	fi
73done
74
75# Fix the permissions.
76find . -type d -print0 | xargs -0 chmod 755
77find . -type f -print0 | xargs -0 chmod 644
78chmod 755 configure
79
80# Remove files generated by "configure".
81REMOVE_FILES="Makefile config.log config.status configure.lineno"
82rm -f $REMOVE_FILES
83
84# Add NetBSD RCS Ids.
85find . -type f -name "*.[ch]" -print |
86while read FILENAME
87do
88	if ! grep -q '\$NetBSD' "$FILENAME"
89	then
90		NEW_FILENAME="${FILENAME}.new"
91		rm -f "${NEW_FILENAME}"
92		(echo "/*	\$NetBSD\$	*/"
93		 echo ""
94		 cat "$FILENAME") >"${NEW_FILENAME}"
95		mv -f "${NEW_FILENAME}" "$FILENAME"
96	fi
97done
98
99# Remove formatted manual pages.
100find . -type f -name "*.man" -delete
101
102# Rename unformatted manual pages.
103find . -type f -name "*.nro" -print |
104while read FILENAME
105do
106	mv "$FILENAME" "${FILENAME%.nro}.1"
107done
108
109# Determine the version number.
110VERSION=$(sed -n -e 's#char version\[\] = "\(.*\)";#\1#p' version.c)
111
112# Print out information for the import.
113cat <<EOF
114You can import now.
115
116Path:		src/external/bsd/less/dist
117Vendortag:	GREENWOODSOFTWARE
118Releasetag:	LESS-$VERSION
119EOF
120
121exit 0
122