summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2019-10-21 12:34:42 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2019-10-21 12:37:17 +0200
commita58e5a4da9312e93f79610be85311e8e5f9839c7 (patch)
tree596ea3b1e0fea5efe03ffc3e3df7a7856dc7f2f8
parent6de78ad00952e888fb5e60e77a763016352edcae (diff)
downloadslackbuilder-a58e5a4da9312e93f79610be85311e8e5f9839c7.tar.gz
slackbuilder-a58e5a4da9312e93f79610be85311e8e5f9839c7.tar.bz2
Accept remote directory as a valid request.
* lib/SlackBuild/Request/Loader/url.pm (Load): Parse remote directory listing and extract the .SlackBuild names from it. If any is found, use its base name as the name of the project and the original request as slackbuild_uri. * lib/SlackBuild/URI.pm (get): New method.
-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.