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