19ff59f5fStron#!/bin/sh 29ff59f5fStron# 3*9f87808aSsimonb# $NetBSD: less2netbsd,v 1.7 2023/10/06 06:05:07 simonb Exp $ 407ba10b3Stron# 507ba10b3Stron# Copyright (c) 2011 The NetBSD Foundation, Inc. 607ba10b3Stron# All rights reserved. 707ba10b3Stron# 807ba10b3Stron# This code is derived from software contributed to The NetBSD Foundation 907ba10b3Stron# by Matthias Scheler. 1007ba10b3Stron# 1107ba10b3Stron# Redistribution and use in source and binary forms, with or without 1207ba10b3Stron# modification, are permitted provided that the following conditions 1307ba10b3Stron# are met: 1407ba10b3Stron# 1. Redistributions of source code must retain the above copyright 1507ba10b3Stron# notice, this list of conditions and the following disclaimer. 1607ba10b3Stron# 2. Redistributions in binary form must reproduce the above copyright 1707ba10b3Stron# notice, this list of conditions and the following disclaimer in the 1807ba10b3Stron# documentation and/or other materials provided with the distribution. 1907ba10b3Stron# 2007ba10b3Stron# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2107ba10b3Stron# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2207ba10b3Stron# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2307ba10b3Stron# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2407ba10b3Stron# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2507ba10b3Stron# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2607ba10b3Stron# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2707ba10b3Stron# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2807ba10b3Stron# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2907ba10b3Stron# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3007ba10b3Stron# POSSIBILITY OF SUCH DAMAGE. 3107ba10b3Stron# 3207ba10b3Stron 333b7a046fSsimonb# less2netbsd: Prepare a less source tree for import into the NetBSD 343b7a046fSsimonb# source repository, under src/external . 353b7a046fSsimonb# based on many other *2netbsd scripts 363b7a046fSsimonb# 373b7a046fSsimonb# Rough instructions for importing new less release: 383b7a046fSsimonb# 393b7a046fSsimonb# $ cd /some/where/temporary 403b7a046fSsimonb# $ tar xpfz /new/less/release/tar/file 413b7a046fSsimonb# $ sh /usr/src/external/bsd/less/less2netbsd less-xyz `pwd` 423b7a046fSsimonb# $ cd src/external/bsd/less/dist 433b7a046fSsimonb# $ cvs -d cvs.netbsd.org:/cvsroot import src/external/bsd/less/dist \ 443b7a046fSsimonb# GREENWOODSOFTWARE LESS-xyz 453b7a046fSsimonb# Enter the new NEWS portion as your commit message 46*9f87808aSsimonb# Check for any conflicts, merge, fix and commit them 473b7a046fSsimonb# $ cd ../../../../../less-xyz 483b7a046fSsimonb# $ ./configure 49*9f87808aSsimonb# Add "/* $NetBSD: less2netbsd,v 1.7 2023/10/06 06:05:07 simonb Exp $ */" to new defines.h 503b7a046fSsimonb# $ cp defines.h /usr/src/external/bsd/less/include 513b7a046fSsimonb# $ cd /usr/src/external/bsd/less 523b7a046fSsimonb# $ cvs update 533b7a046fSsimonb# $ cvs commit -m "Updated autoconf generated files for less xyz." 543b7a046fSsimonb# $ cd /some/where/temporary 553b7a046fSsimonb# ... and clean up the leftovers 5607ba10b3Stron 5707ba10b3StronPROGNAME=$(basename "$0") 583b7a046fSsimonbif [ $# -ne 2 ]; then 593b7a046fSsimonb echo "Usage: $PROGNAME src dest" >&2 6007ba10b3Stron exit 1 6107ba10b3Stronfi 623b7a046fSsimonb 633b7a046fSsimonbr=$1 643b7a046fSsimonbd=$2/src/external/bsd/less/dist 653b7a046fSsimonb 663b7a046fSsimonbcase "$d" in 673b7a046fSsimonb /*) 683b7a046fSsimonb ;; 693b7a046fSsimonb *) 703b7a046fSsimonb d=`/bin/pwd`/$d 713b7a046fSsimonb ;; 723b7a046fSsimonbesac 733b7a046fSsimonb 743b7a046fSsimonbcase "$r" in 753b7a046fSsimonb /*) 763b7a046fSsimonb ;; 773b7a046fSsimonb *) 783b7a046fSsimonb r=`/bin/pwd`/$r 793b7a046fSsimonb ;; 803b7a046fSsimonbesac 813b7a046fSsimonb 823b7a046fSsimonb# Start with clean target directory 833b7a046fSsimonbecho preparing directory $d 843b7a046fSsimonbrm -rf $d 853b7a046fSsimonbmkdir -p $d 8607ba10b3Stron 8707ba10b3Stron# Change to the source directory. 883b7a046fSsimonbif [ -d $r ] && cd $r; then 8907ba10b3Stron : 9007ba10b3Stronelse 913b7a046fSsimonb echo "${PROGNAME}: cannot access directory \"$r\"." >&2 923b7a046fSsimonb exit 1 9307ba10b3Stronfi 9407ba10b3Stron 953b7a046fSsimonb# Copy the files and directories 963b7a046fSsimonbecho copying $r to $d 973b7a046fSsimonbcd $r 983b7a046fSsimonbpax -rwpp * $d 993b7a046fSsimonb 10007ba10b3Stron# Check whether the source directory looks sane. 10107ba10b3StronCHECK_FILES="LICENSE configure less.h version.c" 1023b7a046fSsimonbfor FILENAME in $CHECK_FILES; do 1033b7a046fSsimonb if [ ! -f "$FILENAME" ]; then 10407ba10b3Stron echo "${PROGNAME}: less distribution incomplete." >&2 10507ba10b3Stron exit 10607ba10b3Stron fi 10707ba10b3Strondone 10807ba10b3Stron 10907ba10b3Stron# Check whether the "configure" was run. 11007ba10b3StronREQUIRED_HEADERS=defines.h 11107ba10b3Stronfor FILENAME in $REQUIRED_HEADERS 11207ba10b3Strondo 1133b7a046fSsimonb if [ -f "$FILENAME" ]; then 1143b7a046fSsimonb echo "${PROGNAME}: \"./configure\" run too early, start again." >&2 1153b7a046fSsimonb exit 1 11607ba10b3Stron fi 11707ba10b3Strondone 11807ba10b3Stron 11907ba10b3Stron# Fix the permissions. 1203b7a046fSsimonbfind . -type d -printx | xargs chmod 755 1213b7a046fSsimonbfind . -type f -printx | xargs chmod 644 12207ba10b3Stronchmod 755 configure 12307ba10b3Stron 12407ba10b3Stron# Remove files generated by "configure". 1253b7a046fSsimonbREMOVE_FILES="Makefile config.log config.status" 12607ba10b3Stronrm -f $REMOVE_FILES 12707ba10b3Stron 1283b7a046fSsimonb# Remove extra files/dirs that we don't want to import 1293b7a046fSsimonbrm -rf lesstest 1303b7a046fSsimonb 13107ba10b3Stron# Add NetBSD RCS Ids. 13268becaceStronfind . -type f -name "*.[ch]" -print | 13307ba10b3Stronwhile read FILENAME 13407ba10b3Strondo 1353b7a046fSsimonb if ! grep -q '\$NetBSD' "$FILENAME"; then 13607ba10b3Stron NEW_FILENAME="${FILENAME}.new" 13707ba10b3Stron rm -f "${NEW_FILENAME}" 13841350e18Stron (echo "/* \$NetBSD\$ */" 13941350e18Stron echo "" 14007ba10b3Stron cat "$FILENAME") >"${NEW_FILENAME}" 14107ba10b3Stron mv -f "${NEW_FILENAME}" "$FILENAME" 14207ba10b3Stron fi 14307ba10b3Strondone 14407ba10b3Stron 14568becaceStron# Remove formatted manual pages. 14668becaceStronfind . -type f -name "*.man" -delete 14768becaceStron 14868becaceStron# Rename unformatted manual pages. 14968becaceStronfind . -type f -name "*.nro" -print | 15068becaceStronwhile read FILENAME 15168becaceStrondo 15268becaceStron mv "$FILENAME" "${FILENAME%.nro}.1" 15368becaceStrondone 15468becaceStron 15507ba10b3Stron# Determine the version number. 15607ba10b3StronVERSION=$(sed -n -e 's#char version\[\] = "\(.*\)";#\1#p' version.c) 15707ba10b3Stron 15807ba10b3Stron# Print out information for the import. 15907ba10b3Stroncat <<EOF 16007ba10b3StronYou can import now. 16107ba10b3Stron 16207ba10b3StronPath: src/external/bsd/less/dist 16307ba10b3StronVendortag: GREENWOODSOFTWARE 16407ba10b3StronReleasetag: LESS-$VERSION 16507ba10b3StronEOF 16607ba10b3Stron 16707ba10b3Stronexit 0 168