BuildCommand/Submitter/PkgSubmit.pm

filter: Statementstmt 54.6% 35 / 64 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 2 totaltotal 48.8% 44 / 90 CC 5 SCAR 22.7
CC
5
Cov
48%
run
30.0
__ANON__
2.0
build_config
2.0
CRAP 9.6
« Builder.pm ↑ Summary PidFile.pm »
1 package PkgForge::BuildCommand::Submitter::PkgSubmit; # -*-perl-*-
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 our $VERSION = '1.1.10';
12  
13 1 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use IPC::Run ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 Readonly my $PKGSUBMIT => '/usr/sbin/pkgsubmit';
18  
19 0 ▶use overload q{""} => sub { shift->stringify };
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
20  
21 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use MooseX::Types::Moose qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 with 'PkgForge::BuildCommand::Submitter';
25  
26 has '+tools' => (
27 0 ▶ default => sub { [$PKGSUBMIT] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 1 );
29  
30 1 has '+architecture' => (
31 required => 1,
32 );
33  
34 1 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 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 __PACKAGE__->meta->make_immutable;
45  
46 0 ▶sub build_config {
Subroutine build_config: not called CC=1 SCAR=6.9
Pod undocumented
47 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 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod undocumented
55 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;
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 ▶ if ( $files_count > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($files_count > 0) 0 0 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 ) };
78  
79 0 ▶ if ( !$ok || $EVAL_ERROR ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ok or $PkgForge::BuildCommand::Submitter::PkgSubmit::EVAL_ERROR) { } 0 0 0
Condition0%0/3
not $ok or $PkgForge::BuildCommand::Submitter::PkgSubmit::EVAL_ERROR
l!l&&r!l&&!r
000
MC/DC0%0/2
not $ok or $PkgForge::BuildCommand::Submitter::PkgSubmit::EVAL_ERROR
not $ok $PkgForge::BuildCommand::Submitter::PkgSubmit::EVAL_ERROR
Truth table0%0/3
not(A) or B
A= not $okB= $PkgForge::BuildCommand::Submitter::PkgSubmit::EVAL_ERROR
ABresult
1X1
011
000
80 0 ▶ $logger->error($EVAL_ERROR) if $EVAL_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
if $PkgForge::BuildCommand::Submitter::PkgSubmit::EVAL_ERROR 0 0 0
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 1;
93 __END__
« Builder.pm ↑ Summary PidFile.pm »