less2netbsd revision 1.7 1 1.4 tron #!/bin/sh
2 1.4 tron #
3 1.7 simonb # $NetBSD: less2netbsd,v 1.7 2023/10/06 06:05:07 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.7 simonb # Add "/* $NetBSD: less2netbsd,v 1.7 2023/10/06 06:05:07 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.1 tron PROGNAME=$(basename "$0")
58 1.6 simonb if [ $# -ne 2 ]; then
59 1.6 simonb echo "Usage: $PROGNAME src dest" >&2
60 1.1 tron exit 1
61 1.1 tron fi
62 1.6 simonb
63 1.6 simonb r=$1
64 1.6 simonb d=$2/src/external/bsd/less/dist
65 1.6 simonb
66 1.6 simonb case "$d" in
67 1.6 simonb /*)
68 1.6 simonb ;;
69 1.6 simonb *)
70 1.6 simonb d=`/bin/pwd`/$d
71 1.6 simonb ;;
72 1.6 simonb esac
73 1.6 simonb
74 1.6 simonb case "$r" in
75 1.6 simonb /*)
76 1.6 simonb ;;
77 1.6 simonb *)
78 1.6 simonb r=`/bin/pwd`/$r
79 1.6 simonb ;;
80 1.6 simonb esac
81 1.6 simonb
82 1.6 simonb # Start with clean target directory
83 1.6 simonb echo preparing directory $d
84 1.6 simonb rm -rf $d
85 1.6 simonb mkdir -p $d
86 1.1 tron
87 1.1 tron # Change to the source directory.
88 1.6 simonb if [ -d $r ] && cd $r; then
89 1.1 tron :
90 1.1 tron else
91 1.6 simonb echo "${PROGNAME}: cannot access directory \"$r\"." >&2
92 1.6 simonb exit 1
93 1.1 tron fi
94 1.1 tron
95 1.6 simonb # Copy the files and directories
96 1.6 simonb echo copying $r to $d
97 1.6 simonb cd $r
98 1.6 simonb pax -rwpp * $d
99 1.6 simonb
100 1.1 tron # Check whether the source directory looks sane.
101 1.1 tron CHECK_FILES="LICENSE configure less.h version.c"
102 1.6 simonb for FILENAME in $CHECK_FILES; do
103 1.6 simonb if [ ! -f "$FILENAME" ]; then
104 1.1 tron echo "${PROGNAME}: less distribution incomplete." >&2
105 1.1 tron exit
106 1.1 tron fi
107 1.1 tron done
108 1.1 tron
109 1.1 tron # Check whether the "configure" was run.
110 1.1 tron REQUIRED_HEADERS=defines.h
111 1.1 tron for FILENAME in $REQUIRED_HEADERS
112 1.1 tron do
113 1.6 simonb if [ -f "$FILENAME" ]; then
114 1.6 simonb echo "${PROGNAME}: \"./configure\" run too early, start again." >&2
115 1.6 simonb exit 1
116 1.1 tron fi
117 1.1 tron done
118 1.1 tron
119 1.1 tron # Fix the permissions.
120 1.6 simonb find . -type d -printx | xargs chmod 755
121 1.6 simonb find . -type f -printx | xargs chmod 644
122 1.1 tron chmod 755 configure
123 1.1 tron
124 1.1 tron # Remove files generated by "configure".
125 1.6 simonb REMOVE_FILES="Makefile config.log config.status"
126 1.1 tron rm -f $REMOVE_FILES
127 1.1 tron
128 1.6 simonb # Remove extra files/dirs that we don't want to import
129 1.6 simonb rm -rf lesstest
130 1.6 simonb
131 1.1 tron # Add NetBSD RCS Ids.
132 1.2 tron find . -type f -name "*.[ch]" -print |
133 1.1 tron while read FILENAME
134 1.1 tron do
135 1.6 simonb if ! grep -q '\$NetBSD' "$FILENAME"; then
136 1.1 tron NEW_FILENAME="${FILENAME}.new"
137 1.1 tron rm -f "${NEW_FILENAME}"
138 1.5 tron (echo "/* \$NetBSD\$ */"
139 1.5 tron echo ""
140 1.1 tron cat "$FILENAME") >"${NEW_FILENAME}"
141 1.1 tron mv -f "${NEW_FILENAME}" "$FILENAME"
142 1.1 tron fi
143 1.1 tron done
144 1.1 tron
145 1.2 tron # Remove formatted manual pages.
146 1.2 tron find . -type f -name "*.man" -delete
147 1.2 tron
148 1.2 tron # Rename unformatted manual pages.
149 1.2 tron find . -type f -name "*.nro" -print |
150 1.2 tron while read FILENAME
151 1.2 tron do
152 1.2 tron mv "$FILENAME" "${FILENAME%.nro}.1"
153 1.2 tron done
154 1.2 tron
155 1.1 tron # Determine the version number.
156 1.1 tron VERSION=$(sed -n -e 's#char version\[\] = "\(.*\)";#\1#p' version.c)
157 1.1 tron
158 1.1 tron # Print out information for the import.
159 1.1 tron cat <<EOF
160 1.1 tron You can import now.
161 1.1 tron
162 1.1 tron Path: src/external/bsd/less/dist
163 1.1 tron Vendortag: GREENWOODSOFTWARE
164 1.1 tron Releasetag: LESS-$VERSION
165 1.1 tron EOF
166 1.1 tron
167 1.1 tron exit 0
168