diff options
Diffstat (limited to 'scripts/makeman')
| -rwxr-xr-x | scripts/makeman | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/scripts/makeman b/scripts/makeman deleted file mode 100755 index db3af647ee17..000000000000 --- a/scripts/makeman +++ /dev/null | |||
| @@ -1,185 +0,0 @@ | |||
| 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 | ## A script to make or install the manpages extracted by split-man | ||
| 9 | ## | ||
| 10 | ## Arguements: $1 -- the word "convert" or "install" | ||
| 11 | ## $2 -- the directory containing the SGML files for the manpages | ||
| 12 | ## $3 -- the filename which contained the sgmldoc output | ||
| 13 | ## (I need this so I know which manpages to convert) | ||
| 14 | |||
| 15 | my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename, $tmpdir); | ||
| 16 | |||
| 17 | if($ARGV[0] eq ""){ | ||
| 18 | die "Usage: makeman [convert | install] <dir> <file>\n"; | ||
| 19 | } | ||
| 20 | |||
| 21 | if( ! -d "$ARGV[1]" ){ | ||
| 22 | die "Output directory \"$ARGV[1]\" does not exist\n"; | ||
| 23 | } | ||
| 24 | |||
| 25 | if($ENV{"TMPDIR"} ne ""){ | ||
| 26 | $tmpdir = $ENV{"TMPDIR"}; | ||
| 27 | } | ||
| 28 | else{ | ||
| 29 | $tmpdir = "/tmp"; | ||
| 30 | } | ||
| 31 | |||
| 32 | if($ARGV[0] eq "convert"){ | ||
| 33 | open LISTING, "grep \"<refentrytitle>\" $ARGV[2] |"; | ||
| 34 | while(<LISTING>){ | ||
| 35 | s/<\/.*$//; | ||
| 36 | s/^.*>//; | ||
| 37 | s/\.sgml//; | ||
| 38 | s/struct //; | ||
| 39 | s/typedef //; | ||
| 40 | |||
| 41 | chomp; | ||
| 42 | $filename = $_; | ||
| 43 | print "Processing $filename\n"; | ||
| 44 | |||
| 45 | # Open the input file to extract the front matter, generate the man page, | ||
| 46 | # and open it, and the rearrange everything until it is happy | ||
| 47 | open INPUT, "< $ARGV[1]/$filename.sgml"; | ||
| 48 | $front = ""; | ||
| 49 | $mode = 0; | ||
| 50 | |||
| 51 | # The modes used here are: | ||
| 52 | # mode = 0 | ||
| 53 | # <!-- BEGINFRONTTAG --> | ||
| 54 | # <!-- <bookinfo> mode = 1 | ||
| 55 | # <!-- <legalnotice> mode = 2 | ||
| 56 | # <!-- ...GPL or whatever... | ||
| 57 | # <!-- </legalnotice> mode = 4 | ||
| 58 | # <!-- </bookinfo> mode = 3 | ||
| 59 | # <!-- ENDFRONTTAG --> | ||
| 60 | # | ||
| 61 | # ...doco... | ||
| 62 | |||
| 63 | # I know that some of the if statements in this while loop are in a funny | ||
| 64 | # order, but that is deliberate... | ||
| 65 | while(<INPUT>){ | ||
| 66 | if($mode > 0){ | ||
| 67 | s/<!-- //; | ||
| 68 | s/ -->//; | ||
| 69 | s/<docinfo>//i; | ||
| 70 | s<\/docinfo>//i; | ||
| 71 | s/^[ \t]*//i; | ||
| 72 | } | ||
| 73 | |||
| 74 | if($mode == 2){ | ||
| 75 | if(/<para>/i){ | ||
| 76 | } | ||
| 77 | elsif(/<\/para>/i){ | ||
| 78 | $front = "$front.\\\" \n"; | ||
| 79 | } | ||
| 80 | elsif(/<\/legalnotice>/i){ | ||
| 81 | $mode = 4; | ||
| 82 | } | ||
| 83 | elsif(/^[ \t]*$/){ | ||
| 84 | } | ||
| 85 | else{ | ||
| 86 | $front = "$front.\\\" $_"; | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | if($mode == 1){ | ||
| 91 | if(/<title>(.*)<\/title>/i){ | ||
| 92 | $front = "$front.\\\" This documentation was generated from the book titled \"$1\", which is part of the Linux kernel source.\n.\\\" \n"; | ||
| 93 | } | ||
| 94 | elsif(/<legalnotice>/i){ | ||
| 95 | $front = "$front.\\\" This documentation comes with the following legal notice:\n.\\\" \n"; | ||
| 96 | $mode = 2; | ||
| 97 | } | ||
| 98 | |||
| 99 | elsif(/<author>/i){ | ||
| 100 | $front = "$front.\\\" Documentation by: "; | ||
| 101 | } | ||
| 102 | elsif(/<firstname>(.*)<\/firstname>/i){ | ||
| 103 | $front = "$front$1 "; | ||
| 104 | } | ||
| 105 | elsif(/<surname>(.*)<\/surname>/i){ | ||
| 106 | $front = "$front$1 "; | ||
| 107 | } | ||
| 108 | elsif(/<email>(.*)<\/email>/i){ | ||
| 109 | $front = "$front($1)"; | ||
| 110 | } | ||
| 111 | elsif(/\/author>/i){ | ||
| 112 | $front = "$front\n"; | ||
| 113 | } | ||
| 114 | |||
| 115 | elsif(/<copyright>/i){ | ||
| 116 | $front = "$front.\\\" Documentation copyright: "; | ||
| 117 | } | ||
| 118 | elsif(/<holder>(.*)<\/holder>/i){ | ||
| 119 | $front = "$front$1 "; | ||
| 120 | } | ||
| 121 | elsif(/<year>(.*)<\/year>/i){ | ||
| 122 | $front = "$front$1 "; | ||
| 123 | } | ||
| 124 | elsif(/\/copyright>/i){ | ||
| 125 | $front = "$front\n"; | ||
| 126 | } | ||
| 127 | |||
| 128 | elsif(/^[ \t]*$/ | ||
| 129 | || /<affiliation>/i | ||
| 130 | || /<\/affiliation>/i | ||
| 131 | || /<address>/i | ||
| 132 | || /<\/address>/i | ||
| 133 | || /<authorgroup>/i | ||
| 134 | || /<\/authorgroup>/i | ||
| 135 | || /<\/legalnotice>/i | ||
| 136 | || /<date>/i | ||
| 137 | || /<\/date>/i | ||
| 138 | || /<edition>/i | ||
| 139 | || /<\/edition>/i | ||
| 140 | || /<pubdate>/i | ||
| 141 | || /<\/pubdate>/i){ | ||
| 142 | } | ||
| 143 | else{ | ||
| 144 | print "Unknown tag in manpage conversion: $_"; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | if($mode == 0){ | ||
| 149 | if(/<bookinfo>/i){ | ||
| 150 | $mode = 1; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | if($mode == 4){ | ||
| 155 | if(/<\/bookinfo>/i){ | ||
| 156 | $mode = 3; | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
| 160 | close INPUT; | ||
| 161 | |||
| 162 | system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 $tmpdir/$$.9\n"); | ||
| 163 | open GENERATED, "< $tmpdir/$$.9"; | ||
| 164 | open OUTPUT, "> $ARGV[1]/$filename.9"; | ||
| 165 | |||
| 166 | print OUTPUT "$front"; | ||
| 167 | print OUTPUT ".\\\" For comments on the formatting of this manpage, please contact Michael Still <mikal\@stillhq.com>\n\n"; | ||
| 168 | while(<GENERATED>){ | ||
| 169 | print OUTPUT "$_"; | ||
| 170 | } | ||
| 171 | close OUTPUT; | ||
| 172 | close GENERATED; | ||
| 173 | |||
| 174 | system("gzip -f $ARGV[1]/$filename.9\n"); | ||
| 175 | unlink("$tmpdir/$$.9"); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | elsif($ARGV[0] eq "install"){ | ||
| 179 | system("mkdir -p /usr/local/man/man9/; install $ARGV[1]/*.9.gz /usr/local/man/man9/"); | ||
| 180 | } | ||
| 181 | else{ | ||
| 182 | die "Usage: makeman [convert | install] <dir> <file>\n"; | ||
| 183 | } | ||
| 184 | |||
| 185 | print "Done\n"; | ||
