[csw-devel] SF.net SVN: gar:[2640] csw/mgar/gar
wbonnet at users.sourceforge.net
wbonnet at users.sourceforge.net
Thu Dec 18 00:40:05 CET 2008
Revision: 2640
http://gar.svn.sourceforge.net/gar/?rev=2640&view=rev
Author: wbonnet
Date: 2008-12-17 23:40:05 +0000 (Wed, 17 Dec 2008)
Log Message:
-----------
Port to upstream_watch v2 SF download page support
Modified Paths:
--------------
csw/mgar/gar/v1/bin/upstream_watch
csw/mgar/gar/v2/bin/upstream_watch
Modified: csw/mgar/gar/v1/bin/upstream_watch
===================================================================
--- csw/mgar/gar/v1/bin/upstream_watch 2008-12-17 23:39:14 UTC (rev 2639)
+++ csw/mgar/gar/v1/bin/upstream_watch 2008-12-17 23:40:05 UTC (rev 2640)
@@ -186,7 +186,7 @@
$file_list = get_file_list_wget_sourceforge ($url);
} else {
$file_list = get_file_list_lftp ($url);
-}
+ }
foreach my $file (@{$file_list}) {
if ($file =~ /^$file_pattern$/) {
Modified: csw/mgar/gar/v2/bin/upstream_watch
===================================================================
--- csw/mgar/gar/v2/bin/upstream_watch 2008-12-17 23:39:14 UTC (rev 2639)
+++ csw/mgar/gar/v2/bin/upstream_watch 2008-12-17 23:40:05 UTC (rev 2640)
@@ -108,11 +108,64 @@
return \@file_list;
}
+sub get_file_list_wget_sourceforge
+{
+ my $url = shift;
+ my @file_list;
+
+ my $http_proxy_cmd = "";
+ my $wget_command ="wget";
+ my $filename = "";
+
+ # lftp doesn't seem to obey the _PROXY env variable
+ # we must manually set them
+ $http_proxy_cmd = "set http:proxy $ENV{HTTP_PROXY};" if exists $ENV{HTTP_PROXY};
+ $http_proxy_cmd = "set http:proxy $ENV{http_proxy};" if exists $ENV{http_proxy};
+ $wget_command = "$http_proxy_cmd ; wget --proxy=on" if exists $ENV{http_proxy_cmd};
+
+ open (my $FH, "$wget_command -qO- $url 2>/dev/null | grep class | grep selected | grep li | grep Download | ");
+
+ if (my $line = <$FH>) {
+ my @cols = split (/"/, $line);
+ $filename = $cols[3];
+ chomp ($filename);
+ }
+ else {
+ close ($FH);
+ return \@file_list;
+ }
+
+ close ($FH);
+
+ $url = "http://downloads.sourceforge.net" . $filename;
+ open ($FH, "$wget_command -qO- $url 2>/dev/null | grep $filename | grep package_id= | grep release_id | ");
+
+ if (my $line = <$FH>) {
+ my @cols = split (/>/, $line);
+ my $filename = $cols[2];
+ chomp ($filename);
+ @cols = split (/</, $filename);
+ $filename = $cols[0];
+ chomp ($filename);
+ push (@file_list, $filename);
+ }
+ else {
+ close ($FH);
+ return \@file_list;
+ }
+
+ close ($FH);
+
+ return \@file_list;
+}
+
my $help;
my @urls;
+my $use_sf = 0;
Getopt::Long::Configure ("no_ignore_case");
GetOptions("h|help" => \$help,
+ "s|use_sf=i" => \$use_sf,
"u|url=s@" => \@urls);
if ($help) {
@@ -126,9 +179,14 @@
my $newest_version = 0;
my $newest_file = "";
+ my $file_list ;
foreach my $url (@urls) {
- my $file_list = get_file_list_lftp ($url);
+ if ($use_sf != 0) {
+ $file_list = get_file_list_wget_sourceforge ($url);
+ } else {
+ $file_list = get_file_list_lftp ($url);
+ }
foreach my $file (@{$file_list}) {
if ($file =~ /^$file_pattern$/) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list