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