summaryrefslogtreecommitdiff
path: root/mkmanpages
blob: cc10eb14bc1a3b9423b2bccb3c05e052e7f66cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash

# Copyright 1997,1999,2001,2002,2004,2009,2010 Alain Knaff.
# This file is part of mtools.
#
# Mtools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mtools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mtools.  If not, see <http://www.gnu.org/licenses/>.

# TODO
VERSION=`cat version.texi | awk '$2 == "VERSION" {print $3}'`
UPDATED=`cat version.texi | awk '$2 == "UPDATED" {print $3 " " $4}'`

# extracts the manpage for a given command out of a texinfo doc
unset LANG

date=`date +%d%b%y`
package="mtools-"`grep mversion patchlevel.c | sed 's/^.*"\(.*\)";/\1/'`

infile=/tmp/infile.$$

extract()
{
  command=$1
  echo extracting $command
  outfile=`echo $command | tr '[A-Z]' '[a-z]'`.1
  exec 4>&1
  exec >$outfile

  echo \'\\\" t
# '
  echo .TH\ $command\ 1\ \"$date\" $package
  echo .SH Name
  egrep -i "^$command " cmdname | fgrep -v '#'
  #echo ".SH Description"
  
  cat man-warning.texi mtools.texi man-warning-end.texi |
  egrep -v '@end copying|@copying|@insertcopying' |
  sed \
   -e "/^@c\(omment\)\? skipskipskip/,/^@node $command/d" \
   -e "/^@node [^,]*, [^,]*, $command, Commands$/,/^@bye/d" \
   -e "/^@node [^,]*, [^,]*, Commands/,/^@bye/d" \
   -e 's/^@section/@chapter/' \
   -e 's/^@subs/@s/' \
   -e 's/^@chapter.*$/@chapter Description/' \
   -e 's/^@section/@chapter/' \
   -e 's/^@subs/@s/' \
   -e 's/^@c\(omment\)\? xMANoptions/@chapter Options/' \
   -e "s/^@c\(omment\)\? MAN/@MAN/"  |
  texi2roff -ma  |
  sed -f strip-pp.sed |
  sed -e '/^\.iX/d'
  exec 1>&4
#  echo ".SH See Also"
#  echo "Mtools' texinfo doc"
}


for name in `fgrep -v '#' cmdname | cut -f1 -d\  ` ; do
  extract $name
done

rm -f mtools.tmpl.1
exec >mtools.tmpl.1
echo \'\\\" t
# '
echo .TH mtools 1 \"$date\" $package
echo .SH Name
echo "mtools - utilities to access DOS disks in Unix."
cat mtools.texi |
  egrep -v '@end copying|@copying|@insertcopying' |
	sed \
	 -e "1,/^@c\(omment\)\? MANstart 1/d" \
	 -e '/^@c\(omment\)\? MANskip 1/,/^@c\(omment\)\? MANend-skip 1/d' \
	 -e '/^@c\(omment\)\? MANend-skip 5/d' \
	 -e '/^@c\(omment\)\? MANend 5/d' \
	 -e "s/^@c\(omment\)\? MAN/@MAN/" \
	 -e "s/@value{VERSION}/$VERSION/g" \
	 -e "s%@value{SYSCONFDIR}%SYSCONFDIR%g" |
	texi2roff -ma  |
	sed -f strip-pp.sed |
	sed -e '/^\.iX/d'

echo .SH See also
echo floppyd_installtest
echo mattrib
echo mbadblocks
echo mcd
echo mclasserase
echo mcopy
echo mdel
echo mdeltree
echo mdir
echo mdu
echo mformat
echo minfo
echo mkmanifest
echo mlabel
echo mmd
echo mmount
echo mmove
echo mrd
echo mren
echo mshortname
echo mshowfat
echo mtoolstest
echo mtype

rm -f mtools.tmpl.5
exec >mtools.tmpl.5
echo \'\\\" t
# '
echo .TH mtools 5 \"$date\" "MTOOLS" "MTOOLS"
echo .SH Name
echo "mtools.conf - mtools configuration files"
cat mtools.texi |
  egrep -v '@end copying|@copying|@insertcopying' |
	sed \
		-e '1d' \
		-e '/^@c\(omment\)\? MANskip 5/,/^@c\(omment\)\? MANend-skip 5/d' \
	        -e '/^@c\(omment\)\? MANend-skip 1/d' \
	        -e '/^@c\(omment\)\? MANskip 1/d' \
		-e "s/^@c\(omment\)\? MAN/@MAN/"  \
		-e "/@include/ d" \
		-e "s/@value{VERSION}/$VERSION/g" \
		-e "s/@value{UPDATED}/$UPDATED/g" \
		-e "s%@value{SYSCONFDIR}%SYSCONFDIR%g" \
		-e "/@top/d" \
		-e "/@format/d" \
		-e "/@end format/d" \
		-e "/@ifnottex/d" \
		-e "/@end ifnottex/d" |
	texi2roff -ma  |
	sed -f strip-pp.sed |
	sed -e '/^\.iX/d' -e 's/\.SS Description/.SH Description/'

echo .SH See also
echo mtools