#!/usr/bin/perl # # poll-mirrors.pl # # This script is designed to poll download sites after posting a release # and print out notice as each becomes available. The RM can use this # script to delay the release announcement until the release can be # downloaded. # # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; use warnings; use Getopt::Long; use POSIX qw/strftime/; use LWP::UserAgent; my $rel_path; my $version; my $interval = 300; my $details = 0; my $result = GetOptions ("version=s" => \$version, "details!" => \$details, "path=s" => \$rel_path, "interval=i" => \$interval); my $usage = "" . "$0 -v version [ -i interval (seconds; default: 300) ] [ -details ]\n" . "$0 -p some/explicit/path [ -i interval (seconds; default: 300) ] [ -details ]\n" ; unless ($result) { print STDERR $usage; exit(1); } unless (defined($version) xor defined($rel_path)) { print STDERR "You must specify either -version or -path but not both\n$usage"; exit(1); } my $label; my $apache_url_suffix; my $maven_url; if (defined($version)) { if ($version !~ /^\d+(?:\.\d+)+/) { print STDERR "You must specify the release version as a number.\n$usage"; exit(1); } $label = $version; $apache_url_suffix = "lucene/java/$version/changes/Changes.html"; $maven_url = "http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/$version/lucene-core-$version.pom.asc"; } else { # path based $apache_url_suffix = $label = $rel_path; } my $previously_selected = select STDOUT; $| = 1; # turn off buffering of STDOUT, so status is printed immediately select $previously_selected; my $apache_mirrors_list_url = "http://www.apache.org/mirrors/"; my $agent = LWP::UserAgent->new(); $agent->timeout(2); my $maven_available = defined($maven_url) ? 0 : -999; my @apache_mirrors = (); my $apache_mirrors_list_page = $agent->get($apache_mirrors_list_url)->decoded_content; if (defined($apache_mirrors_list_page)) { #