1#!/bin/bash 2 3# Copyright 1997,1999,2001,2002,2004,2009 Alain Knaff. 4# This file is part of mtools. 5# 6# Mtools is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10# 11# Mtools is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with Mtools. If not, see <http://www.gnu.org/licenses/>. 18 19# TODO 20VERSION=`cat version.texi | awk '$2 == "VERSION" {print $3}'` 21UPDATED=`cat version.texi | awk '$2 == "UPDATED" {print $3 " " $4}'` 22 23# extracts the manpage for a given command out of a texinfo doc 24unset LANG 25 26date=`date +%d%b%y` 27package="mtools-"`grep mversion patchlevel.c | sed 's/^.*"\(.*\)";/\1/'` 28 29infile=/tmp/infile.$$ 30 31extract() 32{ 33 echo extracting $name 34 command=$1 35 outfile=`echo $command | tr '[A-Z]' '[a-z]'`.1 36 37 echo \'\\\" t >>$outfile 38# ' 39 echo .TH\ $command\ 1\ \"$date\" $package >$outfile 40 echo .SH Name >>$outfile 41 grep -i $command cmdname | fgrep -v '#' >>$outfile 42 #echo ".SH Description" >>$outfile 43 44 cat man-warning.texi mtools.texi man-warning-end.texi | 45 egrep -v '@end copying|@copying|@insertcopying' | 46 sed \ 47 -e "/^@c\(omment\)\? skipskipskip/,/^@node $command/d" \ 48 -e "/^@node [^,]*, [^,]*, $command, Commands$/,/^@bye/d" \ 49 -e "/^@node [^,]*, [^,]*, Commands/,/^@bye/d" \ 50 -e 's/^@section/@chapter/' \ 51 -e 's/^@subs/@s/' \ 52 -e 's/^@chapter.*$/@chapter Description/' \ 53 -e 's/^@section/@chapter/' \ 54 -e 's/^@subs/@s/' \ 55 -e 's/^@c\(omment\)\? xMANoptions/@chapter Options/' \ 56 -e "s/^@c\(omment\)\? MAN/@MAN/" | 57 texi2roff -ma | 58 sed -f strip-pp.sed >>$outfile 59# echo ".SH See Also" >>$outfile 60# echo "Mtools' texinfo doc" >>$outfile 61} 62 63 64for name in `fgrep -v '#' cmdname | cut -f1 -d\ ` ; do 65 extract $name 66done 67 68echo \'\\\" t >mtools.1 69# ' 70echo .TH mtools.1 3 \"$date\" $package >>mtools.1 71echo .SH Name >>mtools.1 72echo "mtools - utilities to access DOS disks in Unix." >>mtools.1 73cat mtools.texi | 74 egrep -v '@end copying|@copying|@insertcopying' | 75 sed \ 76 -e "1,/^@c\(omment\)\? MANstart 1/d" \ 77 -e '/^@c\(omment\)\? MANskip 1/,/^@c\(omment\)\? MANend-skip 1/d' \ 78 -e '/^@c\(omment\)\? MANend-skip 5/d' \ 79 -e '/^@c\(omment\)\? MANend 5/d' \ 80 -e "s/^@c\(omment\)\? MAN/@MAN/" \ 81 -e "s/@value{VERSION}/$VERSION/g" | 82 texi2roff -ma | 83 sed -f strip-pp.sed >>mtools.1 84 85echo .SH See also >>mtools.1 86echo floppyd_installtest >>mtools.1 87echo mattrib >>mtools.1 88echo mbadblocks >>mtools.1 89echo mcd >>mtools.1 90echo mclasserase >>mclasserase.1 91echo mcopy >>mtools.1 92echo mdel >>mtools.1 93echo mdeltree >>mtools.1 94echo mdir >>mtools.1 95echo mdu >>mtools.1 96echo mformat >>mtools.1 97echo minfo >>mtools.1 98echo mkmanifest >>mtools.1 99echo mlabel >>mtools.1 100echo mmd >>mtools.1 101echo mmount >>mtools.1 102echo mmove >>mtools.1 103echo mrd >>mtools.1 104echo mren >>mtools.1 105echo mtoolstest >>mtools.1 106echo mtype >>mtools.1 107 108echo \'\\\" t >mtools.5 109# ' 110echo .TH mtools.1 3 \"$date\" "MTOOLS" "MTOOLS" >>mtools.5 111echo .SH Name >>mtools.5 112echo "mtools.conf - mtools configuration files" >>mtools.5 113cat mtools.texi | 114 egrep -v '@end copying|@copying|@insertcopying' | 115 sed \ 116 -e '1d' \ 117 -e '/^@c\(omment\)\? MANskip 5/,/^@c\(omment\)\? MANend-skip 5/d' \ 118 -e '/^@c\(omment\)\? MANend-skip 1/d' \ 119 -e '/^@c\(omment\)\? MANskip 1/d' \ 120 -e "s/^@c\(omment\)\? MAN/@MAN/" \ 121 -e "/@include/ d" \ 122 -e "s/@value{VERSION}/$VERSION/g" \ 123 -e "s/@value{UPDATED}/$UPDATED/g" \ 124 -e "/@top/d" \ 125 -e "/@format/d" \ 126 -e "/@end format/d" \ 127 -e "/@ifnottex/d" \ 128 -e "/@end ifnottex/d" | 129 texi2roff -ma | 130 sed -f strip-pp.sed | 131 sed 's/\.SS Description/.SH Description/' >>mtools.5 132 133echo .SH See also >>mtools.5 134echo mtools >>mtools.5 135