xref: /netbsd-src/external/bsd/less/less2netbsd (revision 07ba10b37c6136dcdd42720125ed95820bc0802c)
1#
2# Copyright (c) 2011 The NetBSD Foundation, Inc.
3# All rights reserved.
4#
5# This code is derived from software contributed to The NetBSD Foundation
6# by Matthias Scheler.
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
30# less2netbsd:
31# Prepare a less source tree for import into the NetBSD source repository.
32
33PROGNAME=$(basename "$0")
34if [ $# -ne 1 ]
35then
36	echo "Usage: $PROGNAME <dir>" >&2
37	exit 1
38fi
39DIRNAME="$1"
40
41# Change to the source directory.
42if [ -d "$DIRNAME" ] && cd "$DIRNAME"
43then
44	:
45else
46	echo "${PROGNAME}: cannot access directory \"$DIRNAME\"." >&2
47	exit
48fi
49
50# Check whether the source directory looks sane.
51CHECK_FILES="LICENSE configure less.h version.c"
52for FILENAME in $CHECK_FILES
53do
54	if [ ! -f "$FILENAME" ]
55	then
56		echo "${PROGNAME}: less distribution incomplete." >&2
57		exit
58	fi
59done
60
61# Check whether the "configure" was run.
62REQUIRED_HEADERS=defines.h
63for FILENAME in $REQUIRED_HEADERS
64do
65	if [ ! -f "$FILENAME" ]
66	then
67		echo "${PROGNAME}: Please run \"./configure\"." >&2
68		exit
69	fi
70done
71
72# Fix the permissions.
73find . -type d -print0 | xargs -0 chmod 755
74find . -type f -print0 | xargs -0 chmod 644
75chmod 755 configure
76
77# Remove files generated by "configure".
78REMOVE_FILES="Makefile config.log config.status configure.lineno"
79rm -f $REMOVE_FILES
80
81# Add NetBSD RCS Ids.
82find . -type f -name "*.[ch]" |
83while read FILENAME
84do
85	if ! grep -q '\$NetBSD' "$FILENAME"
86	then
87		NEW_FILENAME="${FILENAME}.new"
88		rm -f "${NEW_FILENAME}"
89		(echo '/*	$NetBSD	*/'
90		 echo ''
91		 cat "$FILENAME") >"${NEW_FILENAME}"
92		mv -f "${NEW_FILENAME}" "$FILENAME"
93	fi
94done
95
96# Determine the version number.
97VERSION=$(sed -n -e 's#char version\[\] = "\(.*\)";#\1#p' version.c)
98
99# Print out information for the import.
100cat <<EOF
101You can import now.
102
103Path:		src/external/bsd/less/dist
104Vendortag:	GREENWOODSOFTWARE
105Releasetag:	LESS-$VERSION
106EOF
107
108exit 0
109