summaryrefslogtreecommitdiffabout
path: root/lib/SlackBuild/Request/Auto.pm
Side-by-side diff
Diffstat (limited to 'lib/SlackBuild/Request/Auto.pm') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/SlackBuild/Request/Auto.pm106
1 files changed, 0 insertions, 106 deletions
diff --git a/lib/SlackBuild/Request/Auto.pm b/lib/SlackBuild/Request/Auto.pm
deleted file mode 100644
index 576d39d..0000000
--- a/lib/SlackBuild/Request/Auto.pm
+++ b/dev/null
@@ -1,106 +0,0 @@
-package SlackBuild::Request::Auto;
-use strict;
-use warnings;
-use parent 'SlackBuild::Request';
-use File::Basename;
-use File::Spec;
-use Net::SBo;
-use JSON;
-use YAML;
-use Carp;
-
-sub req {
- my ($class, $reqname) = @_;
- my $req;
-
- if (-f $reqname) {
- local $/ = undef;
- open(my $fd, $reqname) or croak "can't open file $reqname: $!";
- my $string = <$fd>;
- close $fd;
- if ($string =~ /^\{/) {
- return decode_json($string);
- }
- return YAML::Load($string);
- }
-
- if (-d $reqname) {
- if (my $file =
- (glob File::Spec->catfile($reqname, '*.SlackBuild'))[0]) {
- my ($package,$path,$suffix) = fileparse($file, '.SlackBuild');
- return { package => $package, slackbuild_uri => $path };
- }
- }
-
- 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 };
- }
- if ($uri->scheme eq 'sbo') {
- return { package => $uri->package, slackbuild_uri => $reqname }
- }
- }
-
- if (my ($dir,$commit) = Net::SBo->new->find($reqname)) {
- return { package => $reqname, slackbuild_uri => "sbo://$commit/$dir"};
- }
-
- croak "unrecognized request type";
-}
-
-sub new {
- my ($class, $arg) = @_;
- return $class->SUPER::new(__PACKAGE__->req($arg));
-}
-
-1;
-__END__
-
-=head1 NAME
-
-SlackBuild::Request::Auto - automatic request convertor for SlackBuilder
-
-=head1 SYNOPSIS
-
- $req = new SlackBuild::Request::Auto($arg)
-
-=head1 DESCRIPTION
-
-Attempts to recognize the format of I<$arg> and convert it to the SlackBuilder
-build request.
-
-Argument can be any of:
-
-=over 4
-
-=item Name of an existing file
-
-The file is read and parsed as a JSON request file.
-
-=item Name of an existing directory
-
-If it contains a file B<*.SlackBuild>, a request referring to files
-in this directory is returned.
-
-=item A http, https, ftp, or ftps URL to a tar file
-
-The file component of the URL must end with B<.tar>, followed with a
-compression suffix (B<.gz>, B<.xz>, or B<.bz2>). The archive must contain
-at least the B<*.SlackBuild> file.
-
-Example:
-
- https://slackbuilds.org/slackbuilds/14.2/system/mailutils.tar.gz
-
-=item An SBo URL
-
-Example:
-
- sbo://HEAD/system/mailutils
-
-=back
-
-=cut
-

Return to:

Send suggestions and report system problems to the System administrator.