| 1 | # $Id$ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package Youri::Package::RPM; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | Youri::Package::RPM - Base class for all RPM-based package implementation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | This bases class factorize code between various RPM-based package | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | implementation. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use base 'Youri::Package'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use version; our $VERSION = qv('0.2.1'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use UNIVERSAL::require; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | =head2 get_wrapper_class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | Returns the name of a class corresponding to currently available perl RPM | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | bindings: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =item C<Youri::Package::RPM::RPM4> if RPM4 is available | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | =item C<Youri::Package::RPM::RPM> if RPM is available | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =item C<Youri::Package::RPM::URPM> if URPM is available | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | This allow to write binding-independant code, by using | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | methods of this class instead of using bindings-specific | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =item set_verbosity | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | =item install_srpm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =item add_macro | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | =item expand_macro | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =item new_header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =item new_spec | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =item new_transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | =head2 set_verbosity | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | This method calls underlying binding corresponding function. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | =head2 install_srpm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | This method calls underlying binding corresponding function. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | =head2 add_macro | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | This method calls underlying binding corresponding function. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | =head2 expand_macro | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | This method calls underlying binding corresponding function. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =head2 new_header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | This method calls the constructor of the underlying binding Header class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =head2 new_spec | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | This method calls the constructor of the underlying binding Spec class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =head2 new_transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | This method calls the constructor of the underlying binding Transaction class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub get_wrapper_class { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_wrapper_class: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (RPM4->require()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | Youri::Package::RPM::RPM4->require(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return 'Youri::Package::RPM::RPM4'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if (RPM->require()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | Youri::Package::RPM::RPM->require(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return 'Youri::Package::RPM::RPM'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (URPM->require()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | Youri::Package::RPM::URPM->require(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return 'Youri::Package::RPM::URPM'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | croak "No RPM bindings available"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub get_pattern { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_pattern: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ($class, $name, $version, $release, $arch) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | return $class->get_unquoted_pattern( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $name ? quotemeta($name) : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | $version ? quotemeta($version) : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | $release ? quotemeta($release) : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $arch ? quotemeta($arch) : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub get_unquoted_pattern { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_unquoted_pattern: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my ($class, $name, $version, $release, $arch) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | ($name ? $name : '[\w-]+' ). | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | '-' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ($version ? $version : '[^-]+' ). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | '-' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ($release ? $release : '[^-]+' ). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | '\.' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ($arch ? $arch : '\w+' ). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | '\.rpm'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub as_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return $self->{_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub is_debug { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_debug: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $name = $self->get_name(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $group = $self->get_tag('group'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # debug packages names must end in -debug or -debuginfo or -debugsource | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $group eq 'Development/Debug' && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$group eq 'Development/Debug' && ($name =~ /-debug$/ || $name =~ /-debuginfo$/ || $name =~ /-debugsource$/)
$name =~ /-debug$/ or $name =~ /-debuginfo$/ or $name =~ /-debugsource$/
$name =~ /-debug$/ or $name =~ /-debuginfo$/
MC/DC0%0/4
$group eq 'Development/Debug' && ($name =~ /-debug$/ || $name =~ /-debuginfo$/ || $name =~ /-debugsource$/)
$group eq 'Development/Debug'
$name =~ /-debug$/
$name =~ /-debuginfo$/
$name =~ /-debugsource$/
Truth table0%0/5
A && B or C or D
A= $group eq 'Development/Debug'B= $name =~ /-debug$/C= $name =~ /-debuginfo$/D= $name =~ /-debugsource$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ($name =~ /-debug$/ || $name =~ /-debuginfo$/ || $name =~ /-debugsource$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||