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