[openssl-commits] [web] master update
Rich Salz
rsalz at openssl.org
Wed Aug 19 16:40:16 UTC 2015
The branch master has been updated
via c4cd68f249965cf0578c19e489b486105a1d040b (commit)
from 08e91ab70c9dbf61204aaf92251e1259bf67225c (commit)
- Log -----------------------------------------------------------------
commit c4cd68f249965cf0578c19e489b486105a1d040b
Author: Rich Salz <rsalz at akamai.com>
Date: Wed Aug 19 12:38:24 2015 -0400
Add manpage scripts
-----------------------------------------------------------------------
Summary of changes:
Makefile | 16 +++--
bin/getnames.pl | 30 ---------
bin/mk-manpages | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++
bin/run-pod2html.sh | 45 -------------
4 files changed, 192 insertions(+), 79 deletions(-)
delete mode 100644 bin/getnames.pl
create mode 100755 bin/mk-manpages
delete mode 100755 bin/run-pod2html.sh
diff --git a/Makefile b/Makefile
index 2b2942d..2421530 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,10 @@
##
## Build procedure for www.openssl.org
+## Checkouts.
+CHECKOUTS = /var/cache/openssl/checkouts/openssl
## Snapshot directory
-SNAP = /var/cache/openssl/checkouts/openssl
+SNAP = $(CHECKOUST)/openssl
## Where releases are found.
RELEASEDIR = /var/www/openssl/source
@@ -31,17 +33,23 @@ relupd: all
echo " sudo -u openssl -H make"; \
exit 1; \
fi
- cd $(SNAP)/.. ; for dir in openssl* ; do \
+ cd $(CHECKOUTS) ; for dir in openssl* ; do \
echo Updating $$dir ; ( cd $$dir ; git pull $(QUIET) ) ; \
done
git pull $(QUIET)
- $(MAKE)
+ $(MAKE) all manpages
+
+manpages:
+ ./bin/mk-manpages $(CHECKOUTS)/master master doc
+ #./bin/mk-manpages $(CHECKOUTS)/openssl-1.0.2-stable 1.0.2 doc
+ #./bin/mk-manpages $(CHECKOUTS)/openssl-1.0.1-stable 1.0.1 doc
+ #./bin/mk-manpages $(CHECKOUTS)/openssl-1.0.0-stable 1.0.0 doc
+ #./bin/mk-manpages $(CHECKOUTS)/openssl-0.9.8-stable 0.9.8 doc
# Legacy targets
hack-source_htaccess: all
simple: all
generated: all
-manpages: all
rebuild: all
clean:
diff --git a/bin/getnames.pl b/bin/getnames.pl
deleted file mode 100644
index 58ee6d0..0000000
--- a/bin/getnames.pl
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-my $func = $ARGV[0];
-$func =~ s/\.pod//;
-$func =~ s at .*/@@;
-
-open(FH, $ARGV[0]) || die "Can't open $ARGV[1], $!";
-$/ = ""; # Eat a paragraph at once.
-while (<FH>) {
- chop;
- s/\n/ /gm;
- if (/^=head1 /) {
- $name = 0;
- } elsif ($name) {
- if (/ - /) {
- s/ - .*//;
- s/,\s+/,/g;
- s/\s+,/,/g;
- s/^\s+//g;
- s/\s+$//g;
- s/\s/_/g;
- push @words, split ',';
- }
- }
- if (/^=head1 *NAME *$/) {
- $name = 1;
- }
-}
-
-print join("\n", grep { $_ ne $func } @words),"\n";
diff --git a/bin/mk-manpages b/bin/mk-manpages
new file mode 100755
index 0000000..506ab57
--- /dev/null
+++ b/bin/mk-manpages
@@ -0,0 +1,180 @@
+#! /usr/bin/perl -w
+
+use strict;
+use Pod::Html;
+use Pod::Simple::XHTML;
+
+my @releases = ( 'master', '1.0.2', '1.0.1', '1.0.1', '0.9.8');
+my %relmap = map { $_ => 1 } @releases;
+my @sections = ( 'apps', 'crypto', 'ssl' );
+
+# Remove all files from a manpage subtree, and leave only
+# the index and the section subdirs.
+sub
+cleanup()
+{
+ my ( $wwwdir, $release ) = @_;
+ my $dir = "$wwwdir/man$release";
+ die "No $dir/index.html" unless -f "$dir/index.html";
+ foreach my $sect ( @sections ) {
+ mkdir "$dir/$sect" unless -d "$dir/$sect";
+ foreach my $f ( glob("$dir/$sect/*") ) {
+ unlink $f || warn "Can't unlink $f, $!";
+ }
+ }
+}
+
+
+## Generate a manpage.
+sub
+genhtml()
+{
+ my ( $release, $section, $filename, $title, $file ) = @_;
+ my $header = <<EOFH;
+<!DOCTYPE html>
+<html lang="en">
+<!--#include virtual="/inc/head.inc" -->
+<body>
+ <!--#include virtual="/inc/banner.inc" -->
+ <div id="main">
+ <div id="content">
+ <div class="blog-index">
+ <article>
+ <header><h2>$title</h2></header>
+ <div class="entry-content">
+ <p>
+
+EOFH
+ my $sidebar = <<EOS;
+<aside class="sidebar">
+ <section>
+ <h1><a href="/docs/manpages.html">All Versions</a></h1>
+ <ul>
+EOS
+ foreach my $v ( @releases ) {
+ if ( $release eq $v ) {
+ $sidebar .=
+"<li><a href=\"/docs/man$v/$section/$file.html\"><em>this branch</em></a></li>
+";
+ } else {
+ $sidebar .=
+"<li><a href=\"/docs/man$v/$section/$file.html\">$v</a></li>\n";
+ }
+ }
+ $sidebar .= <<EOS;
+ </ul>
+ </section>
+</aside>
+EOS
+ my $footer = <<EOFT;
+ </p>
+ </div>
+ <footer>
+ You are here: <a href="/">Home</a>
+ : <a href="/docs">Docs</a>
+ : <a href="/docs/manpages.html">Manpages</a>
+ : <a href="/docs/man$release">$release</a>
+ : <a href="/docs/man$release/$section">$section</a>
+ : <a href="/docs/man$release/$section/$file.html">$file</a>
+ <br/><a href="/sitemap.txt">Sitemap</a>
+ </footer>
+ </article>
+ </div>
+ $sidebar
+ </div>
+ </div>
+ <!--#include virtual="/inc/footer.inc" -->
+</body>
+</html>
+EOFT
+
+ open(my $fh, $filename) || die "Can't open $filename, $!";
+ my $infile = do { local $/; <$fh>; };
+ # L<asdf...|qwer...> ==> L<qwer>
+ $infile =~ s/L<[^|>]*\|([^>]+)>/L<$1>/g;
+ # L<asdf(x)> --> L<asdf>
+ $infile =~ s/L<([^>]+)\(\d\)>/L<$1>/g;
+
+ my $out;
+ my $pod = Pod::Simple::XHTML->new;
+ $pod->html_h_level(3);
+# $pod->index(1);
+ $pod->perldoc_url_prefix("https://www.openssl.org/docs/man$release/$section/");
+ $pod->perldoc_url_postfix(".html");
+ $pod->html_header($header);
+ $pod->html_footer($footer);
+# $pod->force_title("TILETITLETITLE");
+# $pod->backlink(1);
+ $pod->output_string(\$out);
+ $pod->parse_string_document($infile);
+ return $out;
+}
+
+# Return all the OTHER names in a manpage.
+sub
+getnames()
+{
+ my ( $infile, $basename ) = @_;
+ my @words = ();
+ open(my $fh, "<", $infile) || die "Can't open $infile, $!";
+ {
+ local $/ = "";
+ my $found = 0;
+ while ( <$fh> ) {
+ chop;
+ s/\n/ /gm;
+ if (/^=head1 /) {
+ $found = 0;
+ } elsif ( $found ) {
+ if (/ - /) {
+ s/ - .*//;
+ s/,\s+/,/g;
+ s/\s+,/,/g;
+ s/^\s+//g;
+ s/\s+$//g;
+ s/\s/_/g;
+ push @words, split ',';
+ }
+ }
+ if (/^=head1\s*NAME\s*$/) {
+ $found = 1;
+ }
+ }
+ }
+ return grep { $_ ne $basename } @words;
+}
+
+die "Mssing args\n" if $#ARGV < 2;
+
+# Verify source dir.
+my $SRCDIR = shift || die "Source dir missing";
+die "No source directory $SRCDIR" unless -d $SRCDIR;
+foreach my $sect ( @sections ) {
+ my $dir = "$SRCDIR/doc/$sect";
+ die "No directory $dir" unless -d $dir;
+}
+# Verify release.
+my $RELEASE = shift || die "RELEASE missing";
+die "Unknown release $RELEASE" unless defined $relmap{$RELEASE};
+# Cleanup and verify the destination.
+my $WWWDIR = shift || die "Destination missing";
+die "No destination directory $WWWDIR" unless -d $WWWDIR;
+&cleanup($WWWDIR, $RELEASE);
+
+foreach my $sect ( @sections ) {
+ foreach my $filename ( glob("$SRCDIR/doc/$sect/*.pod") ) {
+ my $basename = $filename;
+ $basename =~ s at .*/@@;
+ $basename =~ s at .pod@@;
+ my $out = &genhtml ($RELEASE, $sect, $filename, "???", $basename);
+ my $outfile = "$WWWDIR/man$RELEASE/$sect/$basename.html";
+ open(my $fh, ">", $outfile) || die "Can't open $outfile, $!";
+ print $fh $out || die "Can't print $outfile, $!";
+ close($fh) || die "Can't close $outfile, $!";
+ my @altnames = &getnames($filename, $basename);
+ foreach my $alt ( @altnames ) {
+ my $target = "$WWWDIR/man$RELEASE/$sect/$alt.html";
+ link $outfile, $target || die "Can't link $outfile,$target, $!";
+ }
+ }
+}
diff --git a/bin/run-pod2html.sh b/bin/run-pod2html.sh
deleted file mode 100755
index 0f96a4f..0000000
--- a/bin/run-pod2html.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/sh
-SRC=$1
-DEST=docs
-HERE=`/bin/pwd`
-
-# Somewhere between perl version 5.15 and 5.18, pod2html stopped extracting the
-# title from the pod file's NAME section. When that's the case, we need to do
-# that work ourselves and give pod2html the extracted title with --title. --title
-# isn't available in earlier perl verions, so we need to test the behaviour to
-# decide how to act.
-#
-extract_title=false
-pod2html_testtext="=cut
-
-=head1 NAME
-
-foo - bar
-
-=head1 SYNOPSIS
-"
-if echo "$pod2html_testtext" | pod2html | grep -q '^<title></title>$'; then
- extract_title=true
-fi
-#
-# Test done.
-
-for SUB in apps crypto ssl; do
- DIR=$DEST/$SUB
- rm -rf $DIR
- mkdir -p $DIR
- for IN in $SRC/$SUB/*.pod; do
- FN=`basename $IN .pod`
- title_arg=''
- if $extract_title; then
- title_arg="--title=`cat $IN | sed -e '1,/^=head1 NAME/d' -e '/^=/,$d' -e '/^\s*$/d'`"
- fi
- cat $IN \
- | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
- | pod2html --podroot=$SRC --css=/manpage.css --htmlroot=/docs --podpath=$SUB:apps:crypto:ssl "$title_arg" \
- | sed -r 's/<!DOCTYPE.*//g' > $DIR/$FN.html
- for L in `perl $HERE/getnames.pl $IN` ; do
- ln $DIR/$FN.html $DIR/$L.html || echo FAIL $DIR/$FN.html $DIR/$L.html
- done
- done
-done
More information about the openssl-commits
mailing list