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