less2netbsd revision 1.7 1 #!/bin/sh
2 #
3 # $NetBSD: less2netbsd,v 1.7 2023/10/06 06:05:07 simonb 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: Prepare a less source tree for import into the NetBSD
34 # source repository, under src/external .
35 # based on many other *2netbsd scripts
36 #
37 # Rough instructions for importing new less release:
38 #
39 # $ cd /some/where/temporary
40 # $ tar xpfz /new/less/release/tar/file
41 # $ sh /usr/src/external/bsd/less/less2netbsd less-xyz `pwd`
42 # $ cd src/external/bsd/less/dist
43 # $ cvs -d cvs.netbsd.org:/cvsroot import src/external/bsd/less/dist \
44 # GREENWOODSOFTWARE LESS-xyz
45 # Enter the new NEWS portion as your commit message
46 # Check for any conflicts, merge, fix and commit them
47 # $ cd ../../../../../less-xyz
48 # $ ./configure
49 # Add "/* $NetBSD: less2netbsd,v 1.7 2023/10/06 06:05:07 simonb Exp $ */" to new defines.h
50 # $ cp defines.h /usr/src/external/bsd/less/include
51 # $ cd /usr/src/external/bsd/less
52 # $ cvs update
53 # $ cvs commit -m "Updated autoconf generated files for less xyz."
54 # $ cd /some/where/temporary
55 # ... and clean up the leftovers
56
57 PROGNAME=$(basename "$0")
58 if [ $# -ne 2 ]; then
59 echo "Usage: $PROGNAME src dest" >&2
60 exit 1
61 fi
62
63 r=$1
64 d=$2/src/external/bsd/less/dist
65
66 case "$d" in
67 /*)
68 ;;
69 *)
70 d=`/bin/pwd`/$d
71 ;;
72 esac
73
74 case "$r" in
75 /*)
76 ;;
77 *)
78 r=`/bin/pwd`/$r
79 ;;
80 esac
81
82 # Start with clean target directory
83 echo preparing directory $d
84 rm -rf $d
85 mkdir -p $d
86
87 # Change to the source directory.
88 if [ -d $r ] && cd $r; then
89 :
90 else
91 echo "${PROGNAME}: cannot access directory \"$r\"." >&2
92 exit 1
93 fi
94
95 # Copy the files and directories
96 echo copying $r to $d
97 cd $r
98 pax -rwpp * $d
99
100 # Check whether the source directory looks sane.
101 CHECK_FILES="LICENSE configure less.h version.c"
102 for FILENAME in $CHECK_FILES; do
103 if [ ! -f "$FILENAME" ]; then
104 echo "${PROGNAME}: less distribution incomplete." >&2
105 exit
106 fi
107 done
108
109 # Check whether the "configure" was run.
110 REQUIRED_HEADERS=defines.h
111 for FILENAME in $REQUIRED_HEADERS
112 do
113 if [ -f "$FILENAME" ]; then
114 echo "${PROGNAME}: \"./configure\" run too early, start again." >&2
115 exit 1
116 fi
117 done
118
119 # Fix the permissions.
120 find . -type d -printx | xargs chmod 755
121 find . -type f -printx | xargs chmod 644
122 chmod 755 configure
123
124 # Remove files generated by "configure".
125 REMOVE_FILES="Makefile config.log config.status"
126 rm -f $REMOVE_FILES
127
128 # Remove extra files/dirs that we don't want to import
129 rm -rf lesstest
130
131 # Add NetBSD RCS Ids.
132 find . -type f -name "*.[ch]" -print |
133 while read FILENAME
134 do
135 if ! grep -q '\$NetBSD' "$FILENAME"; then
136 NEW_FILENAME="${FILENAME}.new"
137 rm -f "${NEW_FILENAME}"
138 (echo "/* \$NetBSD\$ */"
139 echo ""
140 cat "$FILENAME") >"${NEW_FILENAME}"
141 mv -f "${NEW_FILENAME}" "$FILENAME"
142 fi
143 done
144
145 # Remove formatted manual pages.
146 find . -type f -name "*.man" -delete
147
148 # Rename unformatted manual pages.
149 find . -type f -name "*.nro" -print |
150 while read FILENAME
151 do
152 mv "$FILENAME" "${FILENAME%.nro}.1"
153 done
154
155 # Determine the version number.
156 VERSION=$(sed -n -e 's#char version\[\] = "\(.*\)";#\1#p' version.c)
157
158 # Print out information for the import.
159 cat <<EOF
160 You can import now.
161
162 Path: src/external/bsd/less/dist
163 Vendortag: GREENWOODSOFTWARE
164 Releasetag: LESS-$VERSION
165 EOF
166
167 exit 0
168