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