File: create-debian-man-refs.sh

package info (click to toggle)
sgml-data 2.0.11%2Bnmu1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,700 kB
  • sloc: xml: 1,377; perl: 115; makefile: 49; sh: 16
file content (33 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (7)
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
#!/bin/sh

set -e

man -u "please let there never be a man page with this name" > /dev/null 2>&1 \
    || true

echo <<EOF
<!-- File automatically generated by $0

        Debian Manual Page DocBook Reference Entities

     Use &man.<name>.<section>; to refer to these.  Should be valid in
     SGML or XML.

     This file is normally generated by the sgml-data postinst but you can
     re-run it at any time.
  -->
EOF

# take all man pages, the part before the dash, ignore any lines not
# starting with a letter and constituted of a word, space(s), and a
# word in parens

# FIXME: use the actual SGML/XML character limits
# FIXME: do it all in sed

whatis -w '*' |                  \
  sed -e 's/-.*$//; s/\[.*//;' | \
  grep '^[a-zA-Z0-9:]* ([a-zA-Z0-9:]\+)' | \
  sed -e 's/^\([^( ]*\) (\(.*\)).*$/<!ENTITY man.\1.\2 "<citerefentry><refentrytitle>\1<\/refentrytitle><manvolnum>\2<\/manvolnum><\/citerefentry>">/;'