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