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