summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2019-03-21 09:23:53 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2019-03-21 09:23:53 (GMT)
commit4014ea72424c52d945c1cadfb47f100f192f6923 (patch) (side-by-side diff)
tree69faea5fb85c98406a4cd4c516b0edd6770d0ee6
parenta9845d6973ca7271437a6fbc659f48cd1100add3 (diff)
downloadslackbuilder-4014ea72424c52d945c1cadfb47f100f192f6923.tar.gz
slackbuilder-4014ea72424c52d945c1cadfb47f100f192f6923.tar.bz2
Decode the request in SlackBuilder->run, if needed.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/SlackBuilder.pm19
-rwxr-xr-xslackbuilder13
2 files changed, 18 insertions, 14 deletions
diff --git a/lib/SlackBuilder.pm b/lib/SlackBuilder.pm
index 924a847..00a1228 100644
--- a/lib/SlackBuilder.pm
+++ b/lib/SlackBuilder.pm
@@ -6,6 +6,7 @@ use SlackBuild::Config;
use SlackBuild::URI;
use SlackBuild::Archive;
use SlackBuild::Registry;
+use SlackBuild::Request;
use SlackBuild::Rc;
use File::Spec;
use File::Basename;
@@ -14,6 +15,7 @@ use File::Copy;
use POSIX::Run::Capture qw(:all);
use POSIX qw(:sys_wait_h strerror uname);
use Log::Log4perl qw(:levels);
+use Try::Tiny;
use Carp;
use constant {
@@ -260,11 +262,24 @@ sub run {
my ($self, $req) = @_;
$self->clear;
+
+ if (!ref($req)) {
+ my $name = $req;
+ $req = try {
+ new SlackBuild::Request($name)
+ } catch {
+ my $err = (split /\n/)[0];
+ $err =~ s{\s+at .* line \d+\.$}{};
+ $self->error("$name: $err");
+ return $self->errno(E_SYNTAX);
+ };
+ }
+
unless ($req->package) {
- $self->error("package: not present");
+ $self->error("package: not present in request");
}
unless ($req->slackbuild_uri) {
- $self->error("slackbuild_uri: not present");
+ $self->error("slackbuild_uri: not present in request");
}
if ($self->errors) {
return $self->errno(E_SYNTAX);
diff --git a/slackbuilder b/slackbuilder
index 36f7bdb..5ec4fd0 100755
--- a/slackbuilder
+++ b/slackbuilder
@@ -9,10 +9,8 @@ use File::Basename;
use File::Spec;
use Unix::Sysexits;
use SlackBuilder;
-use SlackBuild::Request;
use Net::SBo;
use JSON;
-use Try::Tiny;
use constant {
EX_FAIL => 1
@@ -45,17 +43,8 @@ GetOptions("h" => sub {
) or exit(EX_USAGE);
abend(EX_USAGE, "bad number of arguments") unless @ARGV == 1;
-my $reqname = shift @ARGV;
-my $req = try {
- new SlackBuild::Request($reqname)
-} catch {
- my $err = (split /\n/)[0];
- $err =~ s{\s+at .* line \d+\.$}{};
- abend(EX_NOINPUT, "$reqname: $err")
-};
-
my $builder = new SlackBuilder(%sbargs);
-$builder->run($req);
+$builder->run($ARGV[0]);
if ($builder->is_success) {
if ($builder->output_files == 0) {
print STDERR "Build exited successfully, but no output files were generated\n";

Return to:

Send suggestions and report system problems to the System administrator.