| 1 | package CPANPLUS::Dist::Debora::Package::RPM; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use 5.016; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | our $VERSION = '0.019'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use parent qw(CPANPLUS::Dist::Debora::Package); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use File::Path qw(remove_tree); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use File::Spec::Functions qw(catdir catfile); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use File::Temp qw(tempdir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use POSIX qw(uname); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Text::Template 1.22 qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Text::Wrap qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | use CPANPLUS::Dist::Debora::Util | ||||||||||||||||||||||||||||
| 24 | 4 | ▶ | qw(can_run run slurp_utf8 spew_utf8 is_testing); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use CPANPLUS::Error qw(error); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Add some package names. | ||||||||||||||||||||||||||||
| 28 | 4 | my %OBSOLETES_FOR = ( | |||||||||||||||||||||||||||
| 29 | 'ack' => [qw(perl-App-Ack)], | ||||||||||||||||||||||||||||
| 30 | 'Alien-Build' => [qw{ | ||||||||||||||||||||||||||||
| 31 | perl-Alien-Base | ||||||||||||||||||||||||||||
| 32 | perl-Alien-Build-Plugin-Decode-HTML | ||||||||||||||||||||||||||||
| 33 | perl-Alien-Build-Plugin-Decode-Mojo | ||||||||||||||||||||||||||||
| 34 | perl-Alien-Build-tests | ||||||||||||||||||||||||||||
| 35 | }], | ||||||||||||||||||||||||||||
| 36 | 'App-Licensecheck' => [qw(perl-App-Licensecheck)], | ||||||||||||||||||||||||||||
| 37 | 'App-perlbrew' => [qw(perl-App-perlbrew)], | ||||||||||||||||||||||||||||
| 38 | 'Catalyst-Runtime' => [qw{perl-Catalyst-Runtime-scripts}], | ||||||||||||||||||||||||||||
| 39 | 'Encode' => [qw{perl-Encode-devel perl-encoding}], | ||||||||||||||||||||||||||||
| 40 | 'Module-CoreList' => [qw{perl-Module-CoreList-tools}], | ||||||||||||||||||||||||||||
| 41 | 'Mojolicious' => [qw(perl-Test-Mojo)], | ||||||||||||||||||||||||||||
| 42 | 'Perl-Critic' => [qw(perl-Test-Perl-Critic-Policy)], | ||||||||||||||||||||||||||||
| 43 | 'perl-ldap' => [qw(perl-LDAP)], | ||||||||||||||||||||||||||||
| 44 | 'Perl-Tidy' => [qw(perltidy)], | ||||||||||||||||||||||||||||
| 45 | 'TermReadKey' => [qw(perl-TermReadKey)], | ||||||||||||||||||||||||||||
| 46 | 'Razor2-Client-Agent' => | ||||||||||||||||||||||||||||
| 47 | [qw(perl-Razor-Agent perl-razor-agents razor-agents)], | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Add additional capabilities to some packages. | ||||||||||||||||||||||||||||
| 51 | 4 | my %PROVIDES_FOR = ( | |||||||||||||||||||||||||||
| 52 | 'libwww-perl' => [qw{ | ||||||||||||||||||||||||||||
| 53 | perl(LWP::Debug::TraceHTTP::Socket) | ||||||||||||||||||||||||||||
| 54 | perl(LWP::Protocol::http::Socket) | ||||||||||||||||||||||||||||
| 55 | perl(LWP::Protocol::http::SocketMethods) | ||||||||||||||||||||||||||||
| 56 | }], | ||||||||||||||||||||||||||||
| 57 | 'Moose' => [qw{perl(Moose::Conflicts)}], | ||||||||||||||||||||||||||||
| 58 | 'Package-Stash' => [qw{perl(Package::Stash::Conflicts)}], | ||||||||||||||||||||||||||||
| 59 | 'XS-Parse-Keyword' => [qw{perl(:XS_Parse_Keyword_ABI_2)}], | ||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 2 | ▶ | sub format_priority { | ||||||||||||||||||||||||||
|
Subroutine
format_priority: called CC=4 SCAR=19.2
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | my @commands = qw(rpm rpmbuild tar); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 2 | my $priority = 0; | |||||||||||||||||||||||||||
| 68 | 2 | ▶ | if (@commands == grep { can_run($_) } @commands) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | $priority = 1; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (-f '/etc/redhat-release' || -d '/usr/lib/rpm/suse') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f "/etc/redhat-release" or -d "/usr/lib/rpm/suse"
MC/DC0%0/2
-f "/etc/redhat-release" or -d "/usr/lib/rpm/suse"
-f "/etc/redhat-release"
-d "/usr/lib/rpm/suse"
Truth table0%0/3
A or B
A= -f "/etc/redhat-release"B= -d "/usr/lib/rpm/suse"
| |||||||||||||||||||||||||||||
| 71 | 0 | $priority = 2; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 2 | return $priority; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 0 | my ($self, %options) = @_; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | my $builddir = $self->builddir; | |||||||||||||||||||||||||||
| 82 | 0 | my $outputdir = $self->outputdir; | |||||||||||||||||||||||||||
| 83 | 0 | my $rpmdir = $self->rpmdir; | |||||||||||||||||||||||||||
| 84 | 0 | my $sourcedir = $self->sourcedir; | |||||||||||||||||||||||||||
| 85 | 0 | my $specfile = catfile($outputdir, $self->name . '.spec'); | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my $buildrootdir = tempdir('buildrootXXXX', DIR => $outputdir); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | my @rpmbuild_cmd = ( | |||||||||||||||||||||||||||
| 90 | 'rpmbuild', '-bb', | ||||||||||||||||||||||||||||
| 91 | '-D', "_builddir $builddir", | ||||||||||||||||||||||||||||
| 92 | '-D', "_rpmdir $rpmdir", | ||||||||||||||||||||||||||||
| 93 | '-D', "_sourcedir $sourcedir", | ||||||||||||||||||||||||||||
| 94 | '-D', "_buildrootdir $buildrootdir", | ||||||||||||||||||||||||||||
| 95 | '-D', 'source_date_epoch_from_changelog 0', | ||||||||||||||||||||||||||||
| 96 | '-D', 'use_source_date_epoch_as_buildtime 1', | ||||||||||||||||||||||||||||
| 97 | '-D', 'clamp_mtime_to_source_date_epoch 1', | ||||||||||||||||||||||||||||
| 98 | '--build-in-place', | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($self->installdirs eq 'site') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | my $prefix = $Config{siteprefix}; | |||||||||||||||||||||||||||
| 103 | 0 | my $datadir = catdir($prefix, 'share'); | |||||||||||||||||||||||||||
| 104 | 0 | push @rpmbuild_cmd, '-D', "_datadir $datadir"; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | push @rpmbuild_cmd, $specfile; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | my $ok = 0; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | my $spec = $self->spec; | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (!$spec) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | error('Could not render the spec file'); | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | else { | ||||||||||||||||||||||||||||
| 116 | 0 | $ok = spew_utf8($specfile, $spec); | |||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | error("Could not create '$specfile': $OS_ERROR"); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ($ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | local $ENV{SOURCE_DATE_EPOCH} = $ENV{SOURCE_DATE_EPOCH} | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | // $self->last_modification; | ||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{"SOURCE_DATE_EPOCH"} // $self->last_modification
MC/DC0%0/2
$ENV{"SOURCE_DATE_EPOCH"} // $self->last_modification
$ENV{"SOURCE_DATE_EPOCH"}
$self->last_modification
Truth table0%0/3
A // B
A= $ENV{"SOURCE_DATE_EPOCH"}B= $self->last_modification
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | $ok = run( | ||||||||||||||||||||||||||||
| 127 | command => \@rpmbuild_cmd, | ||||||||||||||||||||||||||||
| 128 | dir => $builddir, | ||||||||||||||||||||||||||||
| 129 | verbose => $options{verbose}, | ||||||||||||||||||||||||||||
| 130 | 0 | ); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | remove_tree($buildrootdir); | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | return $ok; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub install { | ||||||||||||||||||||||||||
|
Subroutine
install: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 139 | 0 | my ($self, %options) = @_; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # We always pass "--force" to rpm. The CPANPLUS option "force" is more | ||||||||||||||||||||||||||||
| 142 | # annoying than useful and thus not used here. | ||||||||||||||||||||||||||||
| 143 | 0 | my $sudo_cmd = $self->sudo_cmd; | |||||||||||||||||||||||||||
| 144 | 0 | my @install_cmd = ($sudo_cmd, qw(rpm --upgrade --force --verbose --nosignature)); | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if (is_testing) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | @install_cmd = qw(rpm -qlvp); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | push @install_cmd, $self->outputname; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | my $ok = run(command => \@install_cmd, verbose => $options{verbose}); | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | return $ok; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | ▶ | sub outputname { | ||||||||||||||||||||||||||
|
Subroutine
outputname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | my $outputname = $self->_read( | ||||||||||||||||||||||||||||
| 161 | 'outputname', | ||||||||||||||||||||||||||||
| 162 | 1 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 163 | 1 | catfile($self->rpmdir, $self->arch, | |||||||||||||||||||||||||||
| 164 | $self->name . q{-} | ||||||||||||||||||||||||||||
| 165 | . $self->version . q{-} | ||||||||||||||||||||||||||||
| 166 | . $self->release . q{.} | ||||||||||||||||||||||||||||
| 167 | . $self->arch | ||||||||||||||||||||||||||||
| 168 | . q{.rpm}); | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | 1 | ); | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 1 | return $outputname; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub license { | ||||||||||||||||||||||||||
|
Subroutine
license: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 1 | my $license = $self->SUPER::license; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | # Fedora's rpmlint expects the licenses in reversed order. | ||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if ($license eq 'Artistic-1.0-Perl OR GPL-1.0-or-later') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 1 | $license = 'GPL-1.0-or-later OR Artistic-1.0-Perl'; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 1 | return $license; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 1 | ▶ | sub rpmdir { | ||||||||||||||||||||||||||
|
Subroutine
rpmdir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 1 | ▶ | my $rpmdir = $self->_read('rpmdir', sub { $self->_get_rpmdir }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 1 | return $rpmdir; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 2 | ▶ | sub arch { | ||||||||||||||||||||||||||
|
Subroutine
arch: called CC=1 SCAR=0.8
Pod
documented
| |||||||||||||||||||||||||||||
| 197 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | my $arch = $self->_read( | ||||||||||||||||||||||||||||
| 200 | 'arch', | ||||||||||||||||||||||||||||
| 201 | 1 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||
| 202 | 1 | ▶ | $self->is_noarch ? 'noarch' : $self->rpm_eval('%{?_arch}') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->rpm_eval("%{?_arch}") or (uname())[4]
MC/DC0%0/2
$self->rpm_eval("%{?_arch}") or (uname())[4]
$self->rpm_eval("%{?_arch}")
(uname())[4]
Truth table0%0/3
A or B
A= $self->rpm_eval("%{?_arch}")B= (uname())[4]
| |||||||||||||||||||||||||||||
| 203 | || (uname)[4]; | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | 2 | ); | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 2 | return $arch; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 1 | ▶ | sub dist { | ||||||||||||||||||||||||||
|
Subroutine
dist: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 1 | ▶ | my $dist = $self->_read('dist', sub { $self->rpm_eval('%{?dist}') }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 1 | return $dist; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 3 | ▶ | sub release { | ||||||||||||||||||||||||||
|
Subroutine
release: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 219 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | my $release | ||||||||||||||||||||||||||||
| 222 | 3 | ▶ | = $self->_read('release', sub { $self->build_number . $self->dist }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 3 | return $release; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 1 | ▶ | sub epoch { | ||||||||||||||||||||||||||
|
Subroutine
epoch: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 228 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 1 | ▶ | my $epoch = $self->_read('epoch', sub { $self->_get_epoch }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 1 | return $epoch; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 1 | ▶ | sub distribution { | ||||||||||||||||||||||||||
|
Subroutine
distribution: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | my $distribution | ||||||||||||||||||||||||||||
| 239 | 1 | ▶ | = $self->_read('distribution', sub { $self->_get_distribution }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 1 | return $distribution; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 1 | ▶ | sub provides { | ||||||||||||||||||||||||||
|
Subroutine
provides: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 245 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 1 | my $dist_name = $self->dist_name; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 1 | my @provides; | |||||||||||||||||||||||||||
| 250 | 1 | ▶ | if (exists $PROVIDES_FOR{$dist_name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 0 | push @provides, @{$PROVIDES_FOR{$dist_name}}; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 1 | return \@provides; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 1 | ▶ | sub obsoletes { | ||||||||||||||||||||||||||
|
Subroutine
obsoletes: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 258 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 1 | my $dist_name = $self->dist_name; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 1 | my @obsoletes; | |||||||||||||||||||||||||||
| 263 | 1 | ▶ | if (exists $OBSOLETES_FOR{$dist_name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | push @obsoletes, @{$OBSOLETES_FOR{$dist_name}}; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 1 | return \@obsoletes; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 24 | ▶ | sub _escape { | ||||||||||||||||||||||||||
|
Subroutine
_escape: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 271 | 24 | my ($self, $text) = @_; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 24 | ▶ | if ($text) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 24 | $text =~ s{%}{%%}xmsg; | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | # Insert a non-visible space before "#" characters at the start of | ||||||||||||||||||||||||||||
| 277 | # a line so that RPM doesn't interpret such lines as comments. | ||||||||||||||||||||||||||||
| 278 | 24 | $text =~ s{^ (\h*) [#]}{$1\N{U+200B}#}xmsg; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 24 | return $text; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 12 | ▶ | sub _glob_escape { | ||||||||||||||||||||||||||
|
Subroutine
_glob_escape: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 285 | 12 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 12 | $filename =~ s{([%*?\[\]\\])}{[$1]}xmsg; | |||||||||||||||||||||||||||
| 288 | 12 | $filename =~ s{[ '{}]}{?}xmsg; | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 12 | return $filename; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 1 | ▶ | sub _date { | ||||||||||||||||||||||||||
|
Subroutine
_date: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 294 | 1 | my ($self, $timestamp) = @_; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 1 | my ($week_day, $month, $day, $time, $year) = split q{ }, | |||||||||||||||||||||||||||
| 297 | scalar gmtime $timestamp; | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 1 | my $date = sprintf '%s %s %02d %s', $week_day, $month, $day, $year; | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 1 | return $date; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 1 | ▶ | sub _fill_in { | ||||||||||||||||||||||||||
|
Subroutine
_fill_in: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 305 | 1 | my ($self, $template, %vars) = @_; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | my $text = $template->fill_in( | ||||||||||||||||||||||||||||
| 308 | STRICT => 1, | ||||||||||||||||||||||||||||
| 309 | HASH => { | ||||||||||||||||||||||||||||
| 310 | 24 | ▶ | escape => \sub { $self->_escape(@_) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 311 | 12 | ▶ | glob_escape => \sub { $self->_glob_escape(@_) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 312 | 1 | package => \$self, | |||||||||||||||||||||||||||
| 313 | date => $self->_date($self->last_modification), | ||||||||||||||||||||||||||||
| 314 | %vars | ||||||||||||||||||||||||||||
| 315 | }, | ||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 1 | return $text; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 1 | ▶ | sub spec { | ||||||||||||||||||||||||||
|
Subroutine
spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 322 | 1 | my ($self, %vars) = @_; | |||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | 1 | my $template = Text::Template->new( | |||||||||||||||||||||||||||
| 325 | DELIMITERS => ['[%', '%]'], | ||||||||||||||||||||||||||||
| 326 | TYPE => 'STRING', | ||||||||||||||||||||||||||||
| 327 | SOURCE => <<'END_TEMPLATE'); | ||||||||||||||||||||||||||||
| 328 | Name: [% $escape->($package->name) %] | ||||||||||||||||||||||||||||
| 329 | Version: [% $escape->($package->version) %] | ||||||||||||||||||||||||||||
| 330 | Release: [% $escape->($package->release) %] | ||||||||||||||||||||||||||||
| 331 | Summary: [% $escape->($package->summary) %] | ||||||||||||||||||||||||||||
| 332 | License: [% $escape->($package->license) %] | ||||||||||||||||||||||||||||
| 333 | Packager: [% $escape->($package->packager) %] | ||||||||||||||||||||||||||||
| 334 | Vendor: [% $escape->($package->vendor) %] | ||||||||||||||||||||||||||||
| 335 | URL: [% $escape->($package->url) %] | ||||||||||||||||||||||||||||
| 336 | [% | ||||||||||||||||||||||||||||
| 337 | use Config; | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | my $perl_version = $Config{version}; | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | my $has_shared_objects = (@{$package->shared_objects} > 0); | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | my $epoch = $package->epoch; | ||||||||||||||||||||||||||||
| 344 | if ($epoch) { | ||||||||||||||||||||||||||||
| 345 | $OUT .= 'Epoch: ' . $escape->($epoch). "\n"; | ||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | my $distribution = $package->distribution; | ||||||||||||||||||||||||||||
| 349 | if ($distribution) { | ||||||||||||||||||||||||||||
| 350 | $OUT .= '%global distribution '. $escape->($distribution) . "\n"; | ||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | if ($package->is_noarch) { | ||||||||||||||||||||||||||||
| 354 | $OUT .= "BuildArch: noarch\n"; | ||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | # See "Renaming/Replacing or Removing Existing Packages" in the Fedora | ||||||||||||||||||||||||||||
| 358 | # documentation. | ||||||||||||||||||||||||||||
| 359 | my $evr = $package->version . q{-} . $package->release; | ||||||||||||||||||||||||||||
| 360 | if ($epoch) { | ||||||||||||||||||||||||||||
| 361 | $evr = $epoch . q{:} . $package->version; | ||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | my $escaped_evr = $escape->($evr); | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | for my $name (@{$package->provides}) { | ||||||||||||||||||||||||||||
| 366 | $OUT .= sprintf "Provides: %s\n", $escape->($name); | ||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | for my $name (@{$package->obsoletes}) { | ||||||||||||||||||||||||||||
| 370 | $OUT .= sprintf "Provides: %s = %s\n", $escape->($name), $escaped_evr; | ||||||||||||||||||||||||||||
| 371 | $OUT .= sprintf "Obsoletes: %s < %s\n", $escape->($name), $escaped_evr; | ||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | $OUT .= "AutoProv: 1\n"; | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | # /usr/lib/rpm/perl.req finds too many circular, internal and optional | ||||||||||||||||||||||||||||
| 377 | # dependencies, but we have to add shared library dependencies to | ||||||||||||||||||||||||||||
| 378 | # architecture-dependent Perl distributions. | ||||||||||||||||||||||||||||
| 379 | if ($package->is_noarch) { | ||||||||||||||||||||||||||||
| 380 | $OUT .= "AutoReq: 0\n"; | ||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | else { | ||||||||||||||||||||||||||||
| 383 | $OUT .= "%global _enable_debug_packages 0\n"; | ||||||||||||||||||||||||||||
| 384 | $OUT .= "%global __perl_requires /bin/true\n"; | ||||||||||||||||||||||||||||
| 385 | $OUT .= "%global __perllib_requires /bin/true\n"; | ||||||||||||||||||||||||||||
| 386 | $OUT .= "%global __perltest_requires /bin/true\n"; | ||||||||||||||||||||||||||||
| 387 | $OUT .= "AutoReq: 1\n"; | ||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | $OUT .= "%if 0%{?fedora} > 0 || 0%{?rhel} > 0\n"; | ||||||||||||||||||||||||||||
| 391 | if ($has_shared_objects) { | ||||||||||||||||||||||||||||
| 392 | $OUT .= 'Requires: perl(:MODULE_COMPAT_' . $escape->($perl_version) . ")\n"; | ||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | else { | ||||||||||||||||||||||||||||
| 395 | $OUT .= "Requires: perl-libs\n"; | ||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | $OUT .= "%endif\n"; | ||||||||||||||||||||||||||||
| 398 | for my $dependency (@{$package->dependencies}) { | ||||||||||||||||||||||||||||
| 399 | if ($dependency->{is_module}) { | ||||||||||||||||||||||||||||
| 400 | $OUT .= 'Requires: perl(' . $escape->($dependency->{module_name}) . ')'; | ||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | else { | ||||||||||||||||||||||||||||
| 403 | $OUT .= 'Requires: $escape->($dependency->{package_name})'; | ||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | if ($dependency->{version}) { | ||||||||||||||||||||||||||||
| 406 | $OUT .= ' >= ' . $escape->($dependency->{version}); | ||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | $OUT .= "\n"; | ||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | $OUT .= "%{?perl_requires}\n"; | ||||||||||||||||||||||||||||
| 411 | q{}; | ||||||||||||||||||||||||||||
| 412 | %] | ||||||||||||||||||||||||||||
| 413 | %{?perl_default_filter} | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | %description | ||||||||||||||||||||||||||||
| 416 | [% | ||||||||||||||||||||||||||||
| 417 | local $Text::Wrap::unexpand = 0; | ||||||||||||||||||||||||||||
| 418 | $escape->(Text::Wrap::wrap(q{}, q{}, $package->description)) | ||||||||||||||||||||||||||||
| 419 | %] | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | %prep | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | %build | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | %check | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | %install | ||||||||||||||||||||||||||||
| 428 | [% | ||||||||||||||||||||||||||||
| 429 | for my $so (@{$package->shared_objects}) { | ||||||||||||||||||||||||||||
| 430 | $OUT .= "%if %{defined __strip}\n"; | ||||||||||||||||||||||||||||
| 431 | $OUT .= "%{__strip} -g '" . $escape->($so) . "'\n"; | ||||||||||||||||||||||||||||
| 432 | $OUT .= "%endif\n"; | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | %] | ||||||||||||||||||||||||||||
| 435 | tar -C '[% $escape->($package->stagingdir) %]' -cf - . | tar -C %{buildroot} -xf - | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | %clean | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | %files | ||||||||||||||||||||||||||||
| 440 | %defattr(-, root, root) | ||||||||||||||||||||||||||||
| 441 | [% | ||||||||||||||||||||||||||||
| 442 | my %format = ( | ||||||||||||||||||||||||||||
| 443 | 'changelog' => '%%doc %s', | ||||||||||||||||||||||||||||
| 444 | 'config' => '%%config(noreplace) %s', | ||||||||||||||||||||||||||||
| 445 | 'dir' => '%%dir %s', | ||||||||||||||||||||||||||||
| 446 | 'doc' => '%%doc %s', | ||||||||||||||||||||||||||||
| 447 | 'license' => '%%license %s', | ||||||||||||||||||||||||||||
| 448 | 'man' => '%s*', | ||||||||||||||||||||||||||||
| 449 | ); | ||||||||||||||||||||||||||||
| 450 | for my $file (@{$package->files}) { | ||||||||||||||||||||||||||||
| 451 | my $name = $file->{name}; | ||||||||||||||||||||||||||||
| 452 | my $type = $file->{type}; | ||||||||||||||||||||||||||||
| 453 | if (exists $format{$type}) { | ||||||||||||||||||||||||||||
| 454 | $OUT .= sprintf $format{$type}, $glob_escape->($name); | ||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | else { | ||||||||||||||||||||||||||||
| 457 | $OUT .= $glob_escape->($name); | ||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | $OUT .= "\n"; | ||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | q{}; | ||||||||||||||||||||||||||||
| 462 | %] | ||||||||||||||||||||||||||||
| 463 | %changelog | ||||||||||||||||||||||||||||
| 464 | * [% $date %] [% $escape->($package->packager) %] - [% $escape->($package->version) %]-[% $escape->($package->build_number) %] | ||||||||||||||||||||||||||||
| 465 | - Package [% $escape->($package->dist_name) %] [% $escape->($package->version) %] | ||||||||||||||||||||||||||||
| 466 | END_TEMPLATE | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 1 | my $text = $self->_fill_in($template, %vars); | |||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 1 | return $text; | |||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 1 | ▶ | sub _get_rpmdir { | ||||||||||||||||||||||||||
|
Subroutine
_get_rpmdir: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||
| 474 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | 1 | my $topdir = $self->rpm_eval('%{?_topdir}'); | |||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 1 | ▶ | if (!$topdir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | 1 | my $homedir = $ENV{HOME}; | |||||||||||||||||||||||||||
| 480 | 1 | ▶ | if ($homedir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | 1 | $topdir = catdir($homedir, 'rpmbuild'); | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 1 | ▶ | if (!$topdir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 486 | 0 | $topdir = $self->outputdir; | |||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | 1 | my $rpmdir = catdir($topdir, 'RPMS'); | |||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 1 | return $rpmdir; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 1 | ▶ | sub _get_epoch_from_env { | ||||||||||||||||||||||||||
|
Subroutine
_get_epoch_from_env: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||
| 495 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | 1 | my $epoch = 0; | |||||||||||||||||||||||||||
| 498 | 1 | ▶ | if (defined $ENV{EPOCH} && $ENV{EPOCH} =~ m{\A \d+ \z}xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ENV{"EPOCH"} and $ENV{"EPOCH"} =~ /\A \d+ \z/msux
MC/DC0%0/2
defined $ENV{"EPOCH"} and $ENV{"EPOCH"} =~ /\A \d+ \z/msux
defined $ENV{"EPOCH"}
$ENV{"EPOCH"} =~ /\A \d+ \z/msux
Truth table33%1/3
A and B
A= defined $ENV{"EPOCH"}B= $ENV{"EPOCH"} =~ /\A \d+ \z/msux
| |||||||||||||||||||||||||||||
| 499 | 0 | $epoch = $ENV{EPOCH}; | |||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | 1 | return $epoch; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | 1 | ▶ | sub _get_epoch_from_system { | ||||||||||||||||||||||||||
|
Subroutine
_get_epoch_from_system: called CC=4 SCAR=21.7
| |||||||||||||||||||||||||||||
| 506 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 1 | my $epoch = 0; | |||||||||||||||||||||||||||
| 509 | 1 | my $rpm_cmd = $self->rpm_cmd; | |||||||||||||||||||||||||||
| 510 | 1 | ▶ | if ($rpm_cmd) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 511 | 0 | my @query_cmd = ($rpm_cmd, '-q', '--qf', '%{EPOCH}', $self->name); | |||||||||||||||||||||||||||
| 512 | 0 | my $output = q{}; | |||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | my $ok = run( | ||||||||||||||||||||||||||||
| 515 | command => \@query_cmd, | ||||||||||||||||||||||||||||
| 516 | buffer => \$output, | ||||||||||||||||||||||||||||
| 517 | 0 | ▶ | on_error => sub { } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 518 | 0 | ); | |||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ($ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 520 | 0 | chomp $output; | |||||||||||||||||||||||||||
| 521 | 0 | ▶ | if ($output =~ m{\A \d+ \z}xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 522 | 0 | $epoch = $output; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 1 | return $epoch; | |||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 1 | ▶ | sub _get_epoch { | ||||||||||||||||||||||||||
|
Subroutine
_get_epoch: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 531 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 1 | my $epoch_env = $self->_get_epoch_from_env; | |||||||||||||||||||||||||||
| 534 | 1 | my $epoch_sys = $self->_get_epoch_from_system; | |||||||||||||||||||||||||||
| 535 | 1 | ▶ | my $epoch = $epoch_env > $epoch_sys ? $epoch_env : $epoch_sys; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 1 | return $epoch; | |||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 1 | ▶ | sub _get_distribution { | ||||||||||||||||||||||||||
|
Subroutine
_get_distribution: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||
| 541 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | # Values with escaped characters are deliberately ignored. | ||||||||||||||||||||||||||||
| 544 | 1 | my $BRACKETED_REST = qr{[(] [^\\"]*}xms; | |||||||||||||||||||||||||||
| 545 | 1 | my $PRETTY_NAME | |||||||||||||||||||||||||||
| 546 | = qr{^ PRETTY_NAME = " ([^\\"]+?) \h* (?:$BRACKETED_REST)? " $}xms; | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 1 | my $distribution = $self->rpm_eval('%{?distribution}'); | |||||||||||||||||||||||||||
| 549 | 1 | ▶ | if (!$distribution) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 550 | OS_RELEASE: | ||||||||||||||||||||||||||||
| 551 | 1 | for my $filename (grep {-f} qw(/etc/os-release /usr/lib/os-release)) { | |||||||||||||||||||||||||||
| 552 | 1 | my $os_release = eval { slurp_utf8($filename) }; | |||||||||||||||||||||||||||
| 553 | 1 | ▶ | if ($os_release && $os_release =~ $PRETTY_NAME) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$os_release and $os_release =~ /$PRETTY_NAME/u
MC/DC0%0/2
$os_release and $os_release =~ /$PRETTY_NAME/u
$os_release
$os_release =~ /$PRETTY_NAME/u
Truth table33%1/3
A and B
A= $os_releaseB= $os_release =~ /$PRETTY_NAME/u
| |||||||||||||||||||||||||||||
| 554 | 1 | $distribution = $1; | |||||||||||||||||||||||||||
| 555 | 1 | last OS_RELEASE; | |||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 1 | return $distribution; | |||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | 4 | 1; | |||||||||||||||||||||||||||
| 564 | __END__ | ||||||||||||||||||||||||||||