Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize spec #25

Merged
merged 5 commits into from
Jan 7, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions cpanspec
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ END
my $version_string = '%{version}';

print $spec <<END;
%define cpan_name $name
Name: $prefix$name
Version: $rpm_version
Release: $release
Expand Down Expand Up @@ -1325,10 +1326,8 @@ END
print $spec "License: $license\n";
}
print $spec <<END;
%define cpan_name $name
Summary: $summary
Url: $url
Group: Development/Libraries/Perl
END
my $sfile = basename($ofile);
$sfile =~ s/$name/\%{cpan_name}/;
Expand Down Expand Up @@ -1375,7 +1374,6 @@ END
else {
printf $spec "%-16s%s\n", "BuildArch:", "noarch" if $noarch;
}
print $spec "BuildRoot: \%{_tmppath}/\%{name}-\%{version}-build\n";

printf $spec "%-16s%s\n", "BuildRequires:", "perl";
printf $spec "%-16s%s\n", "BuildRequires:", "perl-macros";
Expand Down Expand Up @@ -1476,19 +1474,42 @@ END
$description

\%prep
\%setup -q@{[($noprefix ? "" : " -n $buildpath")]}
END

my $all_patch_args_same = 1;
my $common_patch_args = undef;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to change this in #55

if ($config->{patches}) {
for my $p (sort keys %{$config->{patches}}) {
my $args = $config->{patches}->{$p} || undef;
$args =~ s/ ?PATCH-FIX.*// if defined($args);
if (!defined($common_patch_args) && defined($args)) {
$common_patch_args = $args;
}
$all_patch_args_same = ($args // '') eq ($common_patch_args // '');
last if !$all_patch_args_same;
}
}

my $autosetup_arg = (!$config->{patches} || $all_patch_args_same) ? (defined($common_patch_args) ? " $common_patch_args" : "") : " -N";
print $spec <<END;
\%autosetup @{[($noprefix ? "" : " -n $buildpath")]}$autosetup_arg
END

if ($execs) {
print $spec qq{find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -name "configure" -print0 | xargs -0 chmod 644\n};
}

if ($config->{patches}) {
if ($config->{patches} && !$all_patch_args_same) {
my $counter = 0;
for my $p (sort keys %{$config->{patches}}) {
my $args = $config->{patches}->{$p} || '';
$args =~ s/ ?PATCH-FIX.*//;
print $spec "%patch$counter $args\n";

my $args = $config->{patches}->{$p} || undef;
if (defined($args)) {
$args =~ s/ ?PATCH-FIX.*//;
print $spec "%patch$counter $args\n";
} else {
print $spec "%patch$counter\n";
}
$counter++;
}
}
Expand Down Expand Up @@ -1556,7 +1577,7 @@ END
if ($compat and !$noarch);

print $spec <<END;
$cmdmake \%{?_smp_mflags}
\%make_build

END
}
Expand Down Expand Up @@ -1628,7 +1649,6 @@ END
}

print $spec "\%files -f \%{name}.files\n";
print $spec "\%defattr(-,root,root,755)\n";

if (%hdoc) {
my (@ldoc, @hdoc);
Expand Down