1835f6802SDirk Vogt#! /bin/sh 2835f6802SDirk Vogt# 3*84d9c625SLionel Sambuc# $NetBSD: file2netbsd,v 1.5 2013/01/04 15:34:47 christos Exp $ 4835f6802SDirk Vogt# 5835f6802SDirk Vogt# Copyright (c) 2003, 2011 The NetBSD Foundation, Inc. 6835f6802SDirk Vogt# All rights reserved. 7835f6802SDirk Vogt# 8835f6802SDirk Vogt# Redistribution and use in source and binary forms, with or without 9835f6802SDirk Vogt# modification, are permitted provided that the following conditions 10835f6802SDirk Vogt# are met: 11835f6802SDirk Vogt# 1. Redistributions of source code must retain the above copyright 12835f6802SDirk Vogt# notice, this list of conditions and the following disclaimer. 13835f6802SDirk Vogt# 2. Redistributions in binary form must reproduce the above copyright 14835f6802SDirk Vogt# notice, this list of conditions and the following disclaimer in the 15835f6802SDirk Vogt# documentation and/or other materials provided with the distribution. 16835f6802SDirk Vogt# 17835f6802SDirk Vogt# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18835f6802SDirk Vogt# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19835f6802SDirk Vogt# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20835f6802SDirk Vogt# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21835f6802SDirk Vogt# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22835f6802SDirk Vogt# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23835f6802SDirk Vogt# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24835f6802SDirk Vogt# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25835f6802SDirk Vogt# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26835f6802SDirk Vogt# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27835f6802SDirk Vogt# POSSIBILITY OF SUCH DAMAGE. 28835f6802SDirk Vogt# 29835f6802SDirk Vogt# file2netbsd: convert a file source tree into a 30835f6802SDirk Vogt# format suitable for import. Works on current dir. 31835f6802SDirk Vogt# You can run this only once if you want it to work. 32835f6802SDirk Vogt# 33835f6802SDirk Vogt# based on texinfo2netbsd 34835f6802SDirk Vogt# 35835f6802SDirk VogtPROG="$(basename "$0")" 36835f6802SDirk Vogt 37835f6802SDirk Vogtif [ -z "$1" ] 38835f6802SDirk Vogtthen 39835f6802SDirk Vogt echo "Usage: $PROG <directory>" 1>&2 40835f6802SDirk Vogt exit 1 41835f6802SDirk Vogtfi 42835f6802SDirk VogtFILE="$1" 43835f6802SDirk Vogt 44*84d9c625SLionel Sambucfile_vers="$(awk -F',' '/AC_INIT\(/ { print $2 }' "$FILE/configure.ac" | tr -d '[' | tr -d ']' | tr -d ' ')" 45*84d9c625SLionel Sambuc 46*84d9c625SLionel Sambuccase $file_vers in 47*84d9c625SLionel Sambuc[0-9].[0-9][0-9]) ;; 48*84d9c625SLionel Sambuc*) echo "$PROG: Cannot determine file version: $file_vers" 1>&2 49*84d9c625SLionel Sambuc exit 1;; 50*84d9c625SLionel Sambucesac 51835f6802SDirk Vogt 52835f6802SDirk Vogt### Wipe out stuff we don't want 53835f6802SDirk Vogtfind "$FILE" -name .cvsignore -delete 54835f6802SDirk Vogt 55835f6802SDirk Vogt### Remove the $'s around RCS tags 56d19d7d58SLionel Sambuccleantags "$FILE" 57835f6802SDirk Vogt 58835f6802SDirk Vogt### Add NetBSD RCS Id 59835f6802SDirk Vogtfind "$FILE" -type f -name '*.[chly]' -print | while read c; do 60835f6802SDirk Vogt sed -e '1{/$NetBSD/!{i\ 61835f6802SDirk Vogt/* \$NetBSD\$ */\ 62835f6802SDirk Vogt 63835f6802SDirk Vogt};} 64835f6802SDirk Vogt/#ifndef[ ]lint/{N;/FILE_RCSID/s/\n/\ 65835f6802SDirk Vogt#if 0\ 66835f6802SDirk Vogt/ 67835f6802SDirk Vogta\ 68835f6802SDirk Vogt#else\ 69835f6802SDirk Vogt__RCSID("\$NetBSD\$");\ 70835f6802SDirk Vogt#endif 71835f6802SDirk Vogt}' $c > /tmp/file3$$ 72835f6802SDirk Vogtmv /tmp/file3$$ $c && echo did source mods for $c 73835f6802SDirk Vogtdone 74835f6802SDirk Vogt 75835f6802SDirk Vogt#### Move files to proper names 76*84d9c625SLionel Sambucmv -f $FILE/doc/file.man $FILE/doc/file.1 77*84d9c625SLionel Sambucmv -f $FILE/doc/libmagic.man $FILE/doc/libmagic.3 78*84d9c625SLionel Sambucmv -f $FILE/doc/magic.man $FILE/doc/magic.5 79835f6802SDirk Vogt 80835f6802SDirk Vogt#### Add RCS tags to man pages 81835f6802SDirk Vogtfind "$FILE" -type f -name '*.[0-9]' -print | while read m; do 82835f6802SDirk Vogt sed -e '1{/$NetBSD/!i\ 83835f6802SDirk Vogt.\\" \$NetBSD\$\ 84835f6802SDirk Vogt.\\" 85835f6802SDirk Vogt 86835f6802SDirk Vogt}' -e 's/__CSECTION__/1/g' \ 87835f6802SDirk Vogt -e 's/__FSECTION__/5/g' \ 88835f6802SDirk Vogt -e 's/__VERSION__/'"${file_vers}/g" \ 89835f6802SDirk Vogt -e 's,__MAGIC__,/usr/share/misc/magic,g' \ 90835f6802SDirk Vogt $m > /tmp/file4$$ 91835f6802SDirk Vogtmv /tmp/file4$$ $m && echo did manpage mods for $m 92835f6802SDirk Vogtdone 93835f6802SDirk Vogt 94835f6802SDirk Vogt#### de-"capsize" the magdir 95*84d9c625SLionel Sambucmv $FILE/magic/Magdir $FILE/magic/magdir 96835f6802SDirk Vogt 97835f6802SDirk Vogt#### Make building easier, don't build magic and doc 98835f6802SDirk Vogtecho '/^SUBDIRS/ 99835f6802SDirk Vogtt. 100835f6802SDirk Vogts/^/#/ 101835f6802SDirk Vogt- 102835f6802SDirk Vogts/ magic.*// 103835f6802SDirk Vogtwq' | ed Makefile.in > /dev/null 2>&1 104835f6802SDirk Vogt 105835f6802SDirk Vogtecho done 106835f6802SDirk Vogt 107835f6802SDirk Vogtecho You can import now. Use the following command: 108d19d7d58SLionel Sambucecho cvs -d cvs.netbsd.org:/cvsroot import src/external/bsd/file/dist CHRISTOS FILE${file_vers%.*}_${file_vers#*.} 109835f6802SDirk Vogt 110835f6802SDirk Vogtexit 0 111