less2netbsd revision 1.4 1 #!/bin/sh
2 #
3 # $NetBSD: less2netbsd,v 1.4 2011/07/03 23:22:37 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
36 PROGNAME=$(basename "$0")
37 if [ $# -ne 1 ]
38 then
39 echo "Usage: $PROGNAME <dir>" >&2
40 exit 1
41 fi
42 DIRNAME="$1"
43
44 # Change to the source directory.
45 if [ -d "$DIRNAME" ] && cd "$DIRNAME"
46 then
47 :
48 else
49 echo "${PROGNAME}: cannot access directory \"$DIRNAME\"." >&2
50 exit
51 fi
52
53 # Check whether the source directory looks sane.
54 CHECK_FILES="LICENSE configure less.h version.c"
55 for FILENAME in $CHECK_FILES
56 do
57 if [ ! -f "$FILENAME" ]
58 then
59 echo "${PROGNAME}: less distribution incomplete." >&2
60 exit
61 fi
62 done
63
64 # Check whether the "configure" was run.
65 REQUIRED_HEADERS=defines.h
66 for FILENAME in $REQUIRED_HEADERS
67 do
68 if [ ! -f "$FILENAME" ]
69 then
70 echo "${PROGNAME}: Please run \"./configure\"." >&2
71 exit
72 fi
73 done
74
75 # Fix the permissions.
76 find . -type d -print0 | xargs -0 chmod 755
77 find . -type f -print0 | xargs -0 chmod 644
78 chmod 755 configure
79
80 # Remove files generated by "configure".
81 REMOVE_FILES="Makefile config.log config.status configure.lineno"
82 rm -f $REMOVE_FILES
83
84 # Add NetBSD RCS Ids.
85 find . -type f -name "*.[ch]" -print |
86 while read FILENAME
87 do
88 if ! grep -q '\$NetBSD' "$FILENAME"
89 then
90 NEW_FILENAME="${FILENAME}.new"
91 rm -f "${NEW_FILENAME}"
92 (echo '/* $NetBSD: less2netbsd,v 1.4 2011/07/03 23:22:37 tron Exp $ */'
93 echo ''
94 cat "$FILENAME") >"${NEW_FILENAME}"
95 mv -f "${NEW_FILENAME}" "$FILENAME"
96 fi
97 done
98
99 # Remove formatted manual pages.
100 find . -type f -name "*.man" -delete
101
102 # Rename unformatted manual pages.
103 find . -type f -name "*.nro" -print |
104 while read FILENAME
105 do
106 mv "$FILENAME" "${FILENAME%.nro}.1"
107 done
108
109 # Determine the version number.
110 VERSION=$(sed -n -e 's#char version\[\] = "\(.*\)";#\1#p' version.c)
111
112 # Print out information for the import.
113 cat <<EOF
114 You can import now.
115
116 Path: src/external/bsd/less/dist
117 Vendortag: GREENWOODSOFTWARE
118 Releasetag: LESS-$VERSION
119 EOF
120
121 exit 0
122