| 1 | # | ||||||||||||||||||||||||||||||||||||||
| 2 | # This file is part of App-Magpie | ||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2011 by Jerome Quelin. | ||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use 5.012; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | package App::Magpie::Action::FixSpec; | ||||||||||||||||||||||||||||||||||||||
| 14 | # ABSTRACT: fixspec command implementation | ||||||||||||||||||||||||||||||||||||||
| 15 | 1 | $App::Magpie::Action::FixSpec::VERSION = '2.010'; | |||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Parse::CPAN::Meta 1.4401; # load_file | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Text::Padding; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | 1 | with 'App::Magpie::Role::Logging'; | |||||||||||||||||||||||||||||||||||||
| 22 | 1 | with 'App::Magpie::Role::RunningCommand'; | |||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=31 SCAR=68.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | # check if there's a spec file to update... | ||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $specdir = path("SPECS"); | |||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | -e $specdir or $self->log_fatal("cannot find a SPECS directory, aborting"); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 32 | my @specfiles = | ||||||||||||||||||||||||||||||||||||||
| 33 | 0 | grep { /\.spec$/ } | |||||||||||||||||||||||||||||||||||||
| 34 | $specdir->children; | ||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | scalar(@specfiles) > 0 | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 36 | or $self->log_fatal("could not find a spec file, aborting"); | ||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | scalar(@specfiles) < 2 | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 38 | or $self->log_fatal("more than one spec file found, aborting"); | ||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $specfile = shift @specfiles; | |||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $spec = $specfile->slurp; | |||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->log( "fixing $specfile" ); | |||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | # extracting tarball | ||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $self->log_debug( "removing previous BUILD directory" ); | |||||||||||||||||||||||||||||||||||||
| 45 | 0 | path( "BUILD" )->remove_tree( { safe => 0 } ); | |||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->log_debug( "extracting tarball" ); | |||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self->run_command( "bm -lp" ); # first just extract tarball | |||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my $distdir = path( glob "BUILD/*" ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $has_makefile_pl = $distdir->child("Makefile.PL")->exists; | |||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $has_build_pl = $distdir->child("Build.PL")->exists; | |||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( $spec =~ /Makefile.PL/ && !$has_makefile_pl ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$spec =~ /Makefile.PL/u and not $has_makefile_pl
MC/DC0%0/2
$spec =~ /Makefile.PL/u and not $has_makefile_pl
$spec =~ /Makefile.PL/u
not $has_makefile_pl
Truth table0%0/3
A and not(B)
A= $spec =~ /Makefile.PL/uB= not $has_makefile_pl
| |||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->log( "module converted to use Build.PL only" ); | |||||||||||||||||||||||||||||||||||||
| 53 | 0 | $spec =~ s{%\{?__perl\}? Makefile.PL INSTALLDIRS=vendor}{%__perl Build.PL --installdirs=vendor}; | |||||||||||||||||||||||||||||||||||||
| 54 | 0 | $spec =~ s{^%?make$}{./Build CFLAGS="%{optflags}"}m; | |||||||||||||||||||||||||||||||||||||
| 55 | 0 | $spec =~ s{%?make test}{./Build test}; | |||||||||||||||||||||||||||||||||||||
| 56 | 0 | $spec =~ s{%makeinstall_std}{./Build install --destdir=%{buildroot}}; | |||||||||||||||||||||||||||||||||||||
| 57 | # writing down new spec file | ||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->log_debug( "writing updated spec file" ); | |||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $fh = $specfile->openw; | |||||||||||||||||||||||||||||||||||||
| 60 | 0 | $fh->print($spec); | |||||||||||||||||||||||||||||||||||||
| 61 | 0 | $fh->close; | |||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ( $spec =~ /Build.PL/ && !$has_build_pl ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$spec =~ /Build.PL/u and not $has_build_pl
MC/DC0%0/2
$spec =~ /Build.PL/u and not $has_build_pl
$spec =~ /Build.PL/u
not $has_build_pl
Truth table0%0/3
A and not(B)
A= $spec =~ /Build.PL/uB= not $has_build_pl
| |||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->log( "module converted to use Makefile.PL only" ); | |||||||||||||||||||||||||||||||||||||
| 65 | 0 | $spec =~ s{%\{?__perl\}? Build.PL (--)?installdirs=vendor}{%__perl Makefile.PL INSTALLDIRS=vendor}; | |||||||||||||||||||||||||||||||||||||
| 66 | 0 | $spec =~ s{./Build( CFLAGS="%\{optflags\}")?$}{%make}m; | |||||||||||||||||||||||||||||||||||||
| 67 | 0 | $spec =~ s{./Build test}{%make test}; | |||||||||||||||||||||||||||||||||||||
| 68 | 0 | $spec =~ s{./Build install.*}{%makeinstall_std}; | |||||||||||||||||||||||||||||||||||||
| 69 | # writing down new spec file | ||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->log_debug( "writing updated spec file" ); | |||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $fh = $specfile->openw; | |||||||||||||||||||||||||||||||||||||
| 72 | 0 | $fh->print($spec); | |||||||||||||||||||||||||||||||||||||
| 73 | 0 | $fh->close; | |||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->log_debug( "generating MYMETA" ); | |||||||||||||||||||||||||||||||||||||
| 77 | 0 | path( "BUILD" )->remove_tree( { safe => 0 } ); | |||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->run_command( "bm -lc" ); # run -c to make sure MYMETA is generated | |||||||||||||||||||||||||||||||||||||
| 79 | 0 | $distdir = path( glob "BUILD/*" ); | |||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $metafile; | |||||||||||||||||||||||||||||||||||||
| 81 | 0 | foreach my $meta ( "MYMETA.json", "MYMETA.yml", "META.json", "META.yml" ) { | |||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | next unless -e $distdir->child( $meta ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $metafile = $distdir->child( $meta ); | |||||||||||||||||||||||||||||||||||||
| 84 | 0 | last; | |||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | # cleaning spec file | ||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->log_debug( "adding %{?perl_default_filter}" ); | |||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $spec =~ s/^Name:/%{?perl_default_filter}\n\nName:/msi if $spec !~ /perl_default_filter/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $self->log_debug( "removing mandriva macros" ); | |||||||||||||||||||||||||||||||||||||
| 92 | 0 | $spec =~ s/^%if %\{mdkversion\}.*?^%endif$//msi; | |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $self->log_debug( "removing buildroot, not needed anymore" ); | |||||||||||||||||||||||||||||||||||||
| 95 | 0 | $spec =~ s/^buildroot:.*\n//mi; | |||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->log_debug( "trimming empty end lines" ); | |||||||||||||||||||||||||||||||||||||
| 98 | 0 | $spec =~ s/\n+\z//; | |||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||
| 100 | # splitting up build-/requires | ||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->log_debug( "splitting (build-)requires one per line" ); | |||||||||||||||||||||||||||||||||||||
| 102 | 0 | $spec =~ s{^((?:build)?requires):\s*(.*)$}{ | |||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $key = $1; my $value = $2; my $str; | |||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $str .= $key . ": $1\n" while $value =~ m{(\S+(\s*[>=<]+\s*\S+)?)\s*}g; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $str; | |||||||||||||||||||||||||||||||||||||
| 106 | }mgie; | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | # fetching buildrequires from meta file | ||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( defined $metafile ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $self->log_debug( "using META file to get buildrequires" ); | |||||||||||||||||||||||||||||||||||||
| 111 | 0 | $spec =~ s{^buildrequires:\s*perl\(.*\).*$}{}mgi; | |||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $meta = Parse::CPAN::Meta->load_file( $metafile ); | |||||||||||||||||||||||||||||||||||||
| 113 | 0 | my %br_from_meta; | |||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( $meta->{"meta-spec"}{version} < 2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 115 | %br_from_meta = ( | ||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | %{ $meta->{configure_requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{"configure_requires"} // {}
MC/DC0%0/1
$meta->{"configure_requires"} // {}
$meta->{"configure_requires"}
Truth table0%0/2
A
A= $meta->{"configure_requires"}
| |||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | %{ $meta->{build_requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{"build_requires"} // {}
MC/DC0%0/1
$meta->{"build_requires"} // {}
$meta->{"build_requires"}
Truth table0%0/2
A
A= $meta->{"build_requires"}
| |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | %{ $meta->{test_requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{"test_requires"} // {}
MC/DC0%0/1
$meta->{"test_requires"} // {}
$meta->{"test_requires"}
Truth table0%0/2
A
A= $meta->{"test_requires"}
| |||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | %{ $meta->{requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{"requires"} // {}
MC/DC0%0/1
$meta->{"requires"} // {}
$meta->{"requires"}
Truth table0%0/2
A
A= $meta->{"requires"}
| |||||||||||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||||||||||
| 121 | } else { | ||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $prereqs = $meta->{prereqs}; | |||||||||||||||||||||||||||||||||||||
| 123 | %br_from_meta = ( | ||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | %{ $prereqs->{configure}{requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prereqs->{"configure"}{"requires"} // {}
MC/DC0%0/1
$prereqs->{"configure"}{"requires"} // {}
$prereqs->{"configure"}{"requires"}
Truth table0%0/2
A
A= $prereqs->{"configure"}{"requires"}
| |||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | %{ $prereqs->{build}{requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prereqs->{"build"}{"requires"} // {}
MC/DC0%0/1
$prereqs->{"build"}{"requires"} // {}
$prereqs->{"build"}{"requires"}
Truth table0%0/2
A
A= $prereqs->{"build"}{"requires"}
| |||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | %{ $prereqs->{test}{requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prereqs->{"test"}{"requires"} // {}
MC/DC0%0/1
$prereqs->{"test"}{"requires"} // {}
$prereqs->{"test"}{"requires"}
Truth table0%0/2
A
A= $prereqs->{"test"}{"requires"}
| |||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | %{ $prereqs->{runtime}{requires} // {} }, | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prereqs->{"runtime"}{"requires"} // {}
MC/DC0%0/1
$prereqs->{"runtime"}{"requires"} // {}
$prereqs->{"runtime"}{"requires"}
Truth table0%0/2
A
A= $prereqs->{"runtime"}{"requires"}
| |||||||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $rpmbr; | |||||||||||||||||||||||||||||||||||||
| 132 | 0 | foreach my $br ( sort keys %br_from_meta ) { | |||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | next if $br eq 'perl'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $version = $br_from_meta{$br}; | |||||||||||||||||||||||||||||||||||||
| 135 | 0 | $rpmbr .= "BuildRequires: perl($br)"; | |||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ( $version != 0 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $rpmvers = qx{ rpm -E "%perl_convert_version $version" }; | |||||||||||||||||||||||||||||||||||||
| 138 | 0 | $rpmbr .= " >= $rpmvers"; | |||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $rpmbr .= "\n"; | |||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ( $spec =~ /buildrequires/i ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $spec =~ s{^(buildrequires:.*)$}{$rpmbr$1}mi; | |||||||||||||||||||||||||||||||||||||
| 145 | } elsif ( $spec =~ /buildarch/i ) { | ||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $spec =~ s{^(buildarch.*)$}{$rpmbr$1}mi; | |||||||||||||||||||||||||||||||||||||
| 147 | } else { | ||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $spec =~ s{^(source.*)$}{$1\n\n$rpmbr}mi; | |||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $spec =~ s{^((?:build)?requires:.*)\n+}{$1\n}mgi; | |||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||
| 154 | # lining up / padding | ||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $pad = Text::Padding->new; | |||||||||||||||||||||||||||||||||||||
| 156 | 0 | $self->log_debug( "lining up categories" ); | |||||||||||||||||||||||||||||||||||||
| 157 | 0 | $spec =~ | |||||||||||||||||||||||||||||||||||||
| 158 | s{^(Name|Version|Release|Epoch|Summary|License|Group|Url|Source\d*|Patch\d*|BuildArch|Requires|Obsoletes|Provides):\s*} | ||||||||||||||||||||||||||||||||||||||
| 159 | 0 | { $pad->left( ucfirst(lc($1)) . ":", 12 ) }mgie; | |||||||||||||||||||||||||||||||||||||
| 160 | 0 | $spec =~ s{^source:}{Source0:}mgi; | |||||||||||||||||||||||||||||||||||||
| 161 | 0 | $spec =~ s{^patch:}{Patch0:}mgi; | |||||||||||||||||||||||||||||||||||||
| 162 | 0 | $spec =~ s{^buildrequires:}{BuildRequires:}mgi; | |||||||||||||||||||||||||||||||||||||
| 163 | 0 | $spec =~ s{^buildarch:}{BuildArch:}mgi; | |||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||
| 165 | # Module::Build::Tiny compatibility | ||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->log_debug( "adding Module::Build::Tiny compatibility" ); | |||||||||||||||||||||||||||||||||||||
| 167 | 0 | $spec =~ s{Build.PL installdirs=vendor}{Build.PL --installdirs=vendor}; | |||||||||||||||||||||||||||||||||||||
| 168 | 0 | $spec =~ s{Build install destdir=%\{buildroot\}}{Build install --destdir=%{buildroot}}; | |||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||
| 170 | # removing default %defattr | ||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->log_debug( "removing default %defattr" ); | |||||||||||||||||||||||||||||||||||||
| 172 | 0 | $spec =~ s{^%defattr\(-,root,root\)\n?}{}mgi; | |||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||
| 174 | # removing default %clean section | ||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->log_debug( "removing default %clean" ); | |||||||||||||||||||||||||||||||||||||
| 176 | 0 | $spec =~ s{%clean\s*\n(.* && )?(rm|%\{?_?_?rm\}?)\s+-rf\s+(%\{?buildroot\}?|\$buildroot)\s*\n?}{}i; | |||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||
| 178 | # removing %buildroot cleaning in %install | ||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->log_debug( "removing %buildroot cleaning in %install" ); | |||||||||||||||||||||||||||||||||||||
| 180 | 0 | $spec =~ s{%install\s*\n(.* && )?(rm|%\{?_?_?rm\}?)\s+-rf\s+(%\{?buildroot\}?|\$buildroot)\s*\n?}{%install\n}i; | |||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||
| 182 | # updating %doc | ||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->log_debug( "fetching documentation files" ); | |||||||||||||||||||||||||||||||||||||
| 184 | my @docfiles = | ||||||||||||||||||||||||||||||||||||||
| 185 | sort | ||||||||||||||||||||||||||||||||||||||
| 186 | grep { | ||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | ( /^[A-Z]+$/ && ! /^MANIFEST/ ) || | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
/^[A-Z]+$/u && !/^MANIFEST/u || /^(Change(s|log)|MYMETA.yml|META.(json|yml)|e[gx]|(ex|s)amples?|demos?)$/iu
/^[A-Z]+$/u and not /^MANIFEST/u
MC/DC0%0/3
/^[A-Z]+$/u && !/^MANIFEST/u || /^(Change(s|log)|MYMETA.yml|META.(json|yml)|e[gx]|(ex|s)amples?|demos?)$/iu
/^[A-Z]+$/u
not /^MANIFEST/u
/^(Change(s|log)|MYMETA.yml|META.(json|yml)|e[gx]|(ex|s)amples?|demos?)$/iu
Truth table0%0/5
A and not(B) || C
A= /^[A-Z]+$/uB= not /^MANIFEST/uC= /^(Change(s|log)|MYMETA.yml|META.(json|yml)|e[gx]|(ex|s)amples?|demos?)$/iu
| |||||||||||||||||||||||||||||||||||||||
| 188 | m{^(Change(s|log)|MYMETA.yml|META.(json|yml)|e[gx]|(ex|s)amples?|demos?)$}i | ||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||
| 190 | 0 | map { $_->basename } | |||||||||||||||||||||||||||||||||||||
| 191 | $distdir->children; | ||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( @docfiles ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->log_debug( "found: @docfiles" ); | |||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $spec =~ /^%doc (.*)/m ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->log_debug( "updating %doc" ); | |||||||||||||||||||||||||||||||||||||
| 196 | 0 | $spec =~ s/^(%doc .*)$/%doc @docfiles/m; | |||||||||||||||||||||||||||||||||||||
| 197 | } else { | ||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->log_debug( "adding a %doc" ); | |||||||||||||||||||||||||||||||||||||
| 199 | 0 | $spec =~ s/^%files$/%files\n%doc @docfiles/m; | |||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->log_debug( "no documentation found" ); | |||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||
| 205 | # other things that might be worth checking... | ||||||||||||||||||||||||||||||||||||||
| 206 | # perl-version instead of perl(version) | ||||||||||||||||||||||||||||||||||||||
| 207 | # url before source | ||||||||||||||||||||||||||||||||||||||
| 208 | # source: http://www.cpan.org/modules/by-module/Algorithm/ | ||||||||||||||||||||||||||||||||||||||
| 209 | # Url: http://search.cpan.org/dist/%{upstream_name} | ||||||||||||||||||||||||||||||||||||||
| 210 | # license | ||||||||||||||||||||||||||||||||||||||
| 211 | # rpmlint ? | ||||||||||||||||||||||||||||||||||||||
| 212 | # sorting buildrequires | ||||||||||||||||||||||||||||||||||||||
| 213 | # %description\n\n | ||||||||||||||||||||||||||||||||||||||
| 214 | # $RPM_BUILD_ROOT | ||||||||||||||||||||||||||||||||||||||
| 215 | # %{upstream_name} module for perl within summary | ||||||||||||||||||||||||||||||||||||||
| 216 | # "perl module" within summary | ||||||||||||||||||||||||||||||||||||||
| 217 | # "module for perl" within summary | ||||||||||||||||||||||||||||||||||||||
| 218 | # %{upstream_name} within description | ||||||||||||||||||||||||||||||||||||||
| 219 | # requires with buildrequires | ||||||||||||||||||||||||||||||||||||||
| 220 | # requires perl | ||||||||||||||||||||||||||||||||||||||
| 221 | # no %check | ||||||||||||||||||||||||||||||||||||||
| 222 | # %upstream instead of %{upstream...} | ||||||||||||||||||||||||||||||||||||||
| 223 | # perl-devel alongside noarch | ||||||||||||||||||||||||||||||||||||||
| 224 | # within %install et %clean: [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} | ||||||||||||||||||||||||||||||||||||||
| 225 | # "no summary found" | ||||||||||||||||||||||||||||||||||||||
| 226 | # "no description found" | ||||||||||||||||||||||||||||||||||||||
| 227 | # make test without %check | ||||||||||||||||||||||||||||||||||||||
| 228 | # %modprefix | ||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||
| 231 | # removing extra newlines | ||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $spec =~ s{\n{3,}}{\n\n}g; | |||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||
| 234 | # writing down new spec file | ||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->log_debug( "writing updated spec file" ); | |||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $fh = $specfile->openw; | |||||||||||||||||||||||||||||||||||||
| 237 | 0 | $fh->print($spec); | |||||||||||||||||||||||||||||||||||||
| 238 | 0 | $fh->close; | |||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||
| 243 | 1 | 1; | |||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||
| 245 | __END__ | ||||||||||||||||||||||||||||||||||||||