mkreadme_osol.pl revision 20440d374537378b3a70ad0e68114ae064baa8f7
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Generate README.opensolaris from a template for inclusion in a
# delivery wad.
# Usage: mkreadme_osol README.opensolaris < template
#
use strict;
use warnings;
#
# Timeout and retry settings for wget. Allow one retry for the
# occasional glitch, but don't wait longer than 5 minutes (so as not
# to hold up the build).
#
my $timeout = 150;
my $tries = 2;
#
# Markers in the web pages that we download.
#
my $readme_fn = shift || die "missing README filepath\n";
my %content;
if (! $ENV{"HTTP_PROXY"}) {
if ($ENV{"http_proxy"}) {
} else {
}
}
if (! $ENV{"http_proxy"}) {
}
#
# Make a pass through the input file and download any web pages that
# are included by reference.
#
foreach (@lines) {
chomp;
if (/^<!-- #include (.+) -->$/) {
my $url = $1;
print "Getting $url\n";
# Download the page into $content{$url}.
die "$url: invalid or empty URI.\n";
}
#
# Clean up the downloaded contents: remove carriage
# returns, strip out content that is outside the
# delimiter tags, convert HTML-encoded characters back
# into plain text.
#
my $l;
# Work forwards to find start.
while (defined ($l = shift @c)) {
if ($l =~ /$begin_data/) {
last;
}
}
if (! defined $l) {
print "Warning: content start delimiter not found\n";
} else {
# Work backwards to find end.
while (defined ($l = pop @c)) {
if ($l =~ /$end_data/) {
last;
}
}
if (! defined $l) {
print "Warning: content end delimiter ",
"not found\n";
}
}
}
}
#
# Make a second pass through the input file. Pass most text on
# verbatim; replace #include directives with the content that was
# downloaded by the previous pass.
#
foreach (@lines) {
if (/^<!-- #include (.+) -->$/ && exists($content{$1})) {
} else {
print README_OUT "$_\n";
}
}
print README_OUT "\n\n";
close(README_OUT);