#! /usr/bin/perl -w
use strict;
die "Missing args\n" if $#ARGV < 0;
my $SRCDIR = $ARGV[0]; shift;
chdir $SRCDIR || die "Can't chdir $SRCDIR, $!";
my @tarballs =
sort grep /openssl-\d+\.\d+\.\d+[a-z]*\.tar\.gz$/,
glob("openssl-*.tar.gz");
my %series = ();
foreach(@tarballs) {
my ($version, $serie) = /^openssl-((\d+\.\d+\.\d+)[a-z]*)\./;
$series{$serie} = $_;
}
my $latest = $series{ (reverse sort keys %series)[0] };
print <<"EOF";
######################################################################
# Please do NOT edit this file directly!
# Instead, edit bin/mk-latest in the master branch of openssl-web.git
#####
RewriteEngine on
RewriteBase /source
# First, rewrite all the 'latest' URLs
RewriteRule ^latest.tar.gz\$ $latest [L,R=302,NC]
EOF
foreach (sort keys %series) {
my $rule = "openssl-$_-latest.tar.gz";
#don't bother: $rule =~ s|\.|\\.|g;
my $target = $series{$_};
print "RewriteRule ^$rule\$ $target [L,R=302,NC]\n";
}
print <<\EOF;
# Old distro's are in subdirs.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(openssl-0\.9\.\d.*) old/0.9.x/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(openssl-(\d+\.\d+\.\d+).*) old/$2/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^openssl-(fips.*) old/fips/openssl-$1 [L]
RemoveEncoding .gz
RemoveEncoding .gz
RemoveEncoding .gz
RemoveEncoding .gz
EOF