summaryrefslogtreecommitdiffabout
path: root/slackbuilder
blob: 0c09da38668e97f844e8b85037d058459ea1979a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
#! -*- perl -*-
eval 'exec perl -x -wS $0 ${1+"$@"}'
    if 0;
# This file is part of slackbuilder
# Copyright (C) 2017-2019 Sergey Poznyakoff
#
# Slackbuilder is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Slackbuilder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with slackbuilder.  If not, see <http://www.gnu.org/licenses/>. */

use strict;
use warnings;
use Data::Dumper;
use Pod::Usage;
use Pod::Man;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
use File::Basename;
use File::Spec;
use Unix::Sysexits;
use SlackBuilder;
use Net::SBo;
use JSON;

use constant {
    EX_FAIL => 1
};

my $progname = basename($0);
my $progdescr = "Slackware package builder";

sub abend {
    my $code = shift;
    print STDERR "$progname: " if defined($progname);
    print STDERR "@_\n";
    exit $code;
}

my %sbargs;
GetOptions("h" => sub {
               pod2usage(-message => "$progname: $progdescr",
			 -exitstatus => EX_OK);
	   },
	   "help" => sub {
	       pod2usage(-exitstatus => EX_OK, -verbose => 2);
	   },
	   "usage" => sub {
	       pod2usage(-exitstatus => EX_OK, -verbose => 0);
	   },
	   "verbose|v+" => \$sbargs{verbose},
	   "image|i=s" => \$sbargs{image},
	   "rootdir|C=s" => \$sbargs{image}
    ) or exit(EX_USAGE);

abend(EX_USAGE, "bad number of arguments") unless @ARGV == 1;
my $builder = new SlackBuilder(%sbargs);
$builder->run($ARGV[0]);
if ($builder->errors) {
    $builder->logger->warn("there are messages in the following categories: ".join(', ', $builder->errors->categories));
}
if ($builder->is_success) {
    if ($builder->output_files == 0) {
	print STDERR "Build exited successfully, but no output files were generated\n";
	exit EX_FAIL;
    }
    print "OK. File list:\n";
    foreach my $f ($builder->output_files) {
	print "$f\n";
    }
    exit(EX_OK);
} else {
    exit($builder->errno);
}

Return to:

Send suggestions and report system problems to the System administrator.