diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /scripts/split-man |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'scripts/split-man')
-rwxr-xr-x | scripts/split-man | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/scripts/split-man b/scripts/split-man new file mode 100755 index 000000000000..03897fe6a75d --- /dev/null +++ b/scripts/split-man | |||
@@ -0,0 +1,112 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use strict; | ||
4 | |||
5 | ## Copyright (C) Michael Still (mikal@stillhq.com) | ||
6 | ## Released under the terms of the GNU GPL | ||
7 | ## | ||
8 | ## Hoon through the specified DocBook SGML file, and split out the | ||
9 | ## man pages. These can then be processed into groff format, and | ||
10 | ## installed if desired... | ||
11 | ## | ||
12 | ## Arguements: $1 -- the name of the sgml file | ||
13 | ## $2 -- the directory to put the generated SGML files in | ||
14 | ## $3 -- kernel version | ||
15 | |||
16 | my($SGML, $REF, $front, $refdata, $mode, $filename); | ||
17 | |||
18 | if(($ARGV[0] eq "") || ($ARGV[1] eq "") || ($ARGV[2] eq "")){ | ||
19 | die "Usage: split-man <sgml file> <output dir> <kernel version>\n"; | ||
20 | } | ||
21 | |||
22 | open SGML, "< $ARGV[0]" or die "Could not open input file \"$ARGV[0]\"\n"; | ||
23 | if( ! -d "$ARGV[1]" ){ | ||
24 | die "Output directory \"$ARGV[1]\" does not exist\n"; | ||
25 | } | ||
26 | |||
27 | # Possible modes: | ||
28 | # 0: Looking for input I care about | ||
29 | # 1: Inside book front matter | ||
30 | # 2: Inside a refentry | ||
31 | # 3: Inside a refentry, and we know the filename | ||
32 | |||
33 | $mode = 0; | ||
34 | $refdata = ""; | ||
35 | $front = ""; | ||
36 | while(<SGML>){ | ||
37 | # Starting modes | ||
38 | if(/<bookinfo>/ || /<docinfo>/){ | ||
39 | $mode = 1; | ||
40 | } | ||
41 | elsif(/<refentry>/){ | ||
42 | $mode = 2; | ||
43 | } | ||
44 | elsif(/<refentrytitle><phrase[^>]*>([^<]*)<.*$/){ | ||
45 | $mode = 3; | ||
46 | $filename = $1; | ||
47 | |||
48 | $filename =~ s/struct //; | ||
49 | $filename =~ s/typedef //; | ||
50 | |||
51 | print "Found manpage for $filename\n"; | ||
52 | open REF, "> $ARGV[1]/$filename.sgml" or | ||
53 | die "Couldn't open output file \"$ARGV[1]/$filename.sgml\": $!\n"; | ||
54 | print REF <<EOF; | ||
55 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN"> | ||
56 | |||
57 | <!-- BEGINFRONTTAG: The following is front matter for the parent book --> | ||
58 | $front | ||
59 | <!-- ENDFRONTTAG: End front matter --> | ||
60 | |||
61 | $refdata | ||
62 | EOF | ||
63 | $refdata = ""; | ||
64 | } | ||
65 | |||
66 | # Extraction | ||
67 | if($mode == 1){ | ||
68 | chomp $_; | ||
69 | $front = "$front<!-- $_ -->\n"; | ||
70 | } | ||
71 | elsif($mode == 2){ | ||
72 | $refdata = "$refdata$_"; | ||
73 | } | ||
74 | elsif($mode == 3){ | ||
75 | # There are some fixups which need to be applied | ||
76 | if(/<\/refmeta>/){ | ||
77 | print REF "<manvolnum>9</manvolnum>\n"; | ||
78 | } | ||
79 | if(/<\/refentry>/){ | ||
80 | print REF <<EOF; | ||
81 | <refsect1><title>About this document</title> | ||
82 | <para> | ||
83 | This documentation was generated with kernel version $ARGV[2]. | ||
84 | </para> | ||
85 | </refsect1> | ||
86 | EOF | ||
87 | } | ||
88 | |||
89 | # For some reason, we title the synopsis twice in the main DocBook | ||
90 | if(! /<title>Synopsis<\/title>/){ | ||
91 | if(/<refentrytitle>/){ | ||
92 | s/struct //; | ||
93 | s/typedef //; | ||
94 | } | ||
95 | |||
96 | print REF "$_"; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | # Ending modes | ||
101 | if(/<\/bookinfo>/ || /<\/docinfo>/){ | ||
102 | $mode = 0; | ||
103 | } | ||
104 | elsif(/<\/refentry>/){ | ||
105 | $mode = 0; | ||
106 | close REF; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | # And make sure we don't process this unnessesarily | ||
111 | $ARGV[0] =~ s/\.sgml/.9/; | ||
112 | `touch $ARGV[0]`; | ||