summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/SlackBuild/Request/Loader/url.pm29
-rw-r--r--lib/SlackBuild/URI.pm14
2 files changed, 39 insertions, 4 deletions
diff --git a/lib/SlackBuild/Request/Loader/url.pm b/lib/SlackBuild/Request/Loader/url.pm
index eb5945c..875832c 100644
--- a/lib/SlackBuild/Request/Loader/url.pm
+++ b/lib/SlackBuild/Request/Loader/url.pm
@@ -24,10 +24,31 @@ our $PRIORITY = 30;
sub Load {
my ($class, $reqname) = @_;
if ($reqname =~ m{^\w+://}) {
- my $uri = new URI($reqname);
- if ($uri->scheme =~ m{^(?:http|ftp)s?}
- && $uri->path =~ m{.*/(.+?)\.tar(?:\.(?:[xgl]z|bz2))?}x) {
- return { package => $1, slackbuild_uri => $reqname };
+ my $uri = new SlackBuild::URI($reqname);
+ if ($uri->scheme =~ m{^(?:http|ftp)s?}) {
+ if ($uri->path =~ m{.*/(.+?)\.tar(?:\.(?:[xgl]z|bz2))?}x) {
+ return { package => $1, slackbuild_uri => $reqname };
+ }
+ if (my $string = $uri->get) {
+ my @pkg;
+ my $p = HTML::Parser->new(
+ api_version => 3,
+ start_h => [
+ sub {
+ my ($attr) = @_;
+ if ($attr->{href}
+ && $attr->{href} =~ /(.+)\.SlackBuild$/) {
+ push @pkg, $1;
+ }
+ },
+ 'attr'
+ ]);
+ $p->report_tags(qw(a));
+ $p->parse($string);
+ if (@pkg) {
+ return { package => $pkg[0], slackbuild_uri => $reqname }
+ }
+ }
}
if ($uri->scheme eq 'sbo' && $uri->package) {
return { package => $uri->package, slackbuild_uri => $reqname }
diff --git a/lib/SlackBuild/URI.pm b/lib/SlackBuild/URI.pm
index ddfd79b..217bedf 100644
--- a/lib/SlackBuild/URI.pm
+++ b/lib/SlackBuild/URI.pm
@@ -102,4 +102,18 @@ sub download {
return $result;
}
+sub get {
+ my $self = shift;
+ my $scheme = $self->scheme;
+ require "LWP/Protocol/$scheme.pm";
+ my $ua = LWP::UserAgent->new();
+ $ua->agent("Slackbuilder/$SlackBuilder::VERSION");
+ my $response = $ua->get($self->as_string);
+ if ($response->is_success) {
+ return $response->decoded_content;
+ } else {
+ $self->logger->error("$self: " . $response->status_line);
+ }
+}
+
1;

Return to:

Send suggestions and report system problems to the System administrator.