line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PkgForge::BuildCommand::Submitter::PkgSubmit; # -*-perl-*- |
2
|
1
|
|
|
1
|
|
2104
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# $Id: PkgSubmit.pm.in 16799 2011-04-22 11:52:09Z squinney@INF.ED.AC.UK $ |
6
|
|
|
|
|
|
|
# $Source:$ |
7
|
|
|
|
|
|
|
# $Revision: 16799 $ |
8
|
|
|
|
|
|
|
# $HeadURL: https://svn.lcfg.org/svn/source/tags/PkgForge-Server/PkgForge_Server_1_1_10/lib/PkgForge/BuildCommand/Submitter/PkgSubmit.pm.in $ |
9
|
|
|
|
|
|
|
# $Date: 2011-04-22 12:52:09 +0100 (Fri, 22 Apr 2011) $ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.1.10'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
14
|
1
|
|
|
1
|
|
419
|
use IPC::Run (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
15
|
1
|
|
|
1
|
|
757
|
use Readonly; |
|
1
|
|
|
|
|
2589
|
|
|
1
|
|
|
|
|
68
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Readonly my $PKGSUBMIT => '/usr/sbin/pkgsubmit'; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use overload q{""} => sub { shift->stringify }; |
|
1
|
|
|
0
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
|
0
|
|
|
|
|
0
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
1501
|
use Moose; |
|
1
|
|
|
|
|
642920
|
|
|
1
|
|
|
|
|
13
|
|
22
|
1
|
|
|
1
|
|
9967
|
use MooseX::Types::Moose qw(Str); |
|
1
|
|
|
|
|
79994
|
|
|
1
|
|
|
|
|
14
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
with 'PkgForge::BuildCommand::Submitter'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has '+tools' => ( |
27
|
|
|
|
|
|
|
default => sub { [$PKGSUBMIT] }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has '+architecture' => ( |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'config' => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => Str, |
37
|
|
|
|
|
|
|
required => 1, |
38
|
|
|
|
|
|
|
builder => 'build_config', |
39
|
|
|
|
|
|
|
lazy => 1, |
40
|
|
|
|
|
|
|
documentation => 'The pkgsubmit configuration file which should be used', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
13170
|
no Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub build_config { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my $platform = $self->platform; |
49
|
0
|
|
|
|
|
|
my $arch = $self->architecture; |
50
|
0
|
|
|
|
|
|
my $config = $platform . q{-} . $arch . '.conf'; |
51
|
0
|
|
|
|
|
|
return $config; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub run { |
55
|
0
|
|
|
0
|
0
|
|
my ( $self, $job, $buildinfo, $buildlog ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $logger = $buildlog->logger; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $config = $self->config; |
60
|
0
|
|
|
|
|
|
my $bucket = $job->bucket; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my @files = $buildinfo->products_list; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Should not be necessary but just in case... |
65
|
0
|
|
|
|
|
|
@files = grep { m/\.rpm$/ } @files; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $id = join q{/}, $self->platform, $self->architecture, $bucket; |
68
|
0
|
|
|
|
|
|
my $files_count = scalar @files; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $success = 1; |
71
|
0
|
0
|
|
|
|
|
if ( $files_count > 0 ) { |
72
|
0
|
|
|
|
|
|
my @cmd = ( $PKGSUBMIT, '-x', '-f', $config, '-B', $bucket, @files ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$logger->debug("Will run command '@cmd'"); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $pkgsubmit_out; |
77
|
0
|
|
|
|
|
|
my $ok = eval { IPC::Run::run( \@cmd, \undef, '>&', \$pkgsubmit_out ) }; |
|
0
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
0
|
|
|
|
if ( !$ok || $EVAL_ERROR ) { |
80
|
0
|
0
|
|
|
|
|
$logger->error($EVAL_ERROR) if $EVAL_ERROR; |
81
|
0
|
|
|
|
|
|
$logger->error("Failed to run pkgsubmit: $pkgsubmit_out"); |
82
|
0
|
|
|
|
|
|
$success = 0; |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
|
$logger->info("Successfully submitted $files_count packages for '$id'"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return $success; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |