11594e4f0Schristos#! /bin/sh 21594e4f0Schristos# 3*1c5b5b41Schristos# $NetBSD: file2netbsd,v 1.5 2013/01/04 15:34:47 christos Exp $ 41594e4f0Schristos# 51594e4f0Schristos# Copyright (c) 2003, 2011 The NetBSD Foundation, Inc. 61594e4f0Schristos# All rights reserved. 71594e4f0Schristos# 81594e4f0Schristos# Redistribution and use in source and binary forms, with or without 91594e4f0Schristos# modification, are permitted provided that the following conditions 101594e4f0Schristos# are met: 111594e4f0Schristos# 1. Redistributions of source code must retain the above copyright 121594e4f0Schristos# notice, this list of conditions and the following disclaimer. 131594e4f0Schristos# 2. Redistributions in binary form must reproduce the above copyright 141594e4f0Schristos# notice, this list of conditions and the following disclaimer in the 151594e4f0Schristos# documentation and/or other materials provided with the distribution. 161594e4f0Schristos# 171594e4f0Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 181594e4f0Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 191594e4f0Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 201594e4f0Schristos# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 211594e4f0Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 221594e4f0Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 231594e4f0Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 241594e4f0Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 251594e4f0Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 261594e4f0Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 271594e4f0Schristos# POSSIBILITY OF SUCH DAMAGE. 281594e4f0Schristos# 291594e4f0Schristos# file2netbsd: convert a file source tree into a 301594e4f0Schristos# format suitable for import. Works on current dir. 311594e4f0Schristos# You can run this only once if you want it to work. 321594e4f0Schristos# 331594e4f0Schristos# based on texinfo2netbsd 341594e4f0Schristos# 351594e4f0SchristosPROG="$(basename "$0")" 361594e4f0Schristos 371594e4f0Schristosif [ -z "$1" ] 381594e4f0Schristosthen 391594e4f0Schristos echo "Usage: $PROG <directory>" 1>&2 401594e4f0Schristos exit 1 411594e4f0Schristosfi 421594e4f0SchristosFILE="$1" 431594e4f0Schristos 44*1c5b5b41Schristosfile_vers="$(awk -F',' '/AC_INIT\(/ { print $2 }' "$FILE/configure.ac" | tr -d '[' | tr -d ']' | tr -d ' ')" 45*1c5b5b41Schristos 46*1c5b5b41Schristoscase $file_vers in 47*1c5b5b41Schristos[0-9].[0-9][0-9]) ;; 48*1c5b5b41Schristos*) echo "$PROG: Cannot determine file version: $file_vers" 1>&2 49*1c5b5b41Schristos exit 1;; 50*1c5b5b41Schristosesac 511594e4f0Schristos 521594e4f0Schristos### Wipe out stuff we don't want 531594e4f0Schristosfind "$FILE" -name .cvsignore -delete 541594e4f0Schristos 551594e4f0Schristos### Remove the $'s around RCS tags 560e7bd658Schristoscleantags "$FILE" 571594e4f0Schristos 581594e4f0Schristos### Add NetBSD RCS Id 591594e4f0Schristosfind "$FILE" -type f -name '*.[chly]' -print | while read c; do 601594e4f0Schristos sed -e '1{/$NetBSD/!{i\ 611594e4f0Schristos/* \$NetBSD\$ */\ 621594e4f0Schristos 631594e4f0Schristos};} 641594e4f0Schristos/#ifndef[ ]lint/{N;/FILE_RCSID/s/\n/\ 651594e4f0Schristos#if 0\ 661594e4f0Schristos/ 671594e4f0Schristosa\ 681594e4f0Schristos#else\ 691594e4f0Schristos__RCSID("\$NetBSD\$");\ 701594e4f0Schristos#endif 711594e4f0Schristos}' $c > /tmp/file3$$ 721594e4f0Schristosmv /tmp/file3$$ $c && echo did source mods for $c 731594e4f0Schristosdone 741594e4f0Schristos 751594e4f0Schristos#### Move files to proper names 7684d8cf07Schristosmv -f $FILE/doc/file.man $FILE/doc/file.1 7784d8cf07Schristosmv -f $FILE/doc/libmagic.man $FILE/doc/libmagic.3 7884d8cf07Schristosmv -f $FILE/doc/magic.man $FILE/doc/magic.5 791594e4f0Schristos 801594e4f0Schristos#### Add RCS tags to man pages 811594e4f0Schristosfind "$FILE" -type f -name '*.[0-9]' -print | while read m; do 821594e4f0Schristos sed -e '1{/$NetBSD/!i\ 831594e4f0Schristos.\\" \$NetBSD\$\ 841594e4f0Schristos.\\" 851594e4f0Schristos 861594e4f0Schristos}' -e 's/__CSECTION__/1/g' \ 871594e4f0Schristos -e 's/__FSECTION__/5/g' \ 881594e4f0Schristos -e 's/__VERSION__/'"${file_vers}/g" \ 891594e4f0Schristos -e 's,__MAGIC__,/usr/share/misc/magic,g' \ 901594e4f0Schristos $m > /tmp/file4$$ 911594e4f0Schristosmv /tmp/file4$$ $m && echo did manpage mods for $m 921594e4f0Schristosdone 931594e4f0Schristos 941594e4f0Schristos#### de-"capsize" the magdir 9584d8cf07Schristosmv $FILE/magic/Magdir $FILE/magic/magdir 961594e4f0Schristos 971594e4f0Schristos#### Make building easier, don't build magic and doc 981594e4f0Schristosecho '/^SUBDIRS/ 991594e4f0Schristost. 1001594e4f0Schristoss/^/#/ 1011594e4f0Schristos- 1021594e4f0Schristoss/ magic.*// 1031594e4f0Schristoswq' | ed Makefile.in > /dev/null 2>&1 1041594e4f0Schristos 1051594e4f0Schristosecho done 1061594e4f0Schristos 1071594e4f0Schristosecho You can import now. Use the following command: 1080e7bd658Schristosecho cvs -d cvs.netbsd.org:/cvsroot import src/external/bsd/file/dist CHRISTOS FILE${file_vers%.*}_${file_vers#*.} 1091594e4f0Schristos 1101594e4f0Schristosexit 0 111