Allow building rpms for slightly older perl versions
The --old version is a bit of a harsh measure when merely building specfiles for centos 4 (perl 5.8.5) rpms on centos 5 (perl 5.8.8). This patch allows you to specify a minimum version to support and will use Module::Corelist instead of rpm to generate the corelist for that version.
This commit is contained in:
1 parent
1cd8735b7c
commit
3b953c0923
1 file changed
+23
-7
@@ -26,6 +26,7 @@ cpanspec [options] [file [...]]
|
|||||||
Options:
|
Options:
|
||||||
--help -h Help message
|
--help -h Help message
|
||||||
--old -o Be more compatible with old RHL/FC releases
|
--old -o Be more compatible with old RHL/FC releases
|
||||||
|
--perl-version -P Minimum perl version to support
|
||||||
--license -l Include generated license texts if absent in source
|
--license -l Include generated license texts if absent in source
|
||||||
--noprefix -n Don't add perl- prefix to package name
|
--noprefix -n Don't add perl- prefix to package name
|
||||||
--force -f Force overwriting existing spec
|
--force -f Force overwriting existing spec
|
||||||
@@ -86,6 +87,11 @@ Includes a hack to remove LD_RUN_PATH from Makefile.
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
=item B<-P>, B<--perl-version>
|
||||||
|
|
||||||
|
Include explicit dependencies for core modules when newer versions are
|
||||||
|
required than shipped with the specified version.
|
||||||
|
|
||||||
=item B<-l>, B<--license>
|
=item B<-l>, B<--license>
|
||||||
|
|
||||||
Generate COPYING and Artistic license texts if the source doesn't seem
|
Generate COPYING and Artistic license texts if the source doesn't seem
|
||||||
@@ -204,6 +210,7 @@ use File::Basename;
|
|||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use Parse::CPAN::Packages;
|
use Parse::CPAN::Packages;
|
||||||
use Pod::Simple::TextContent;
|
use Pod::Simple::TextContent;
|
||||||
|
use Module::CoreList;
|
||||||
# Apparently gets pulled in by another module.
|
# Apparently gets pulled in by another module.
|
||||||
#use Cwd;
|
#use Cwd;
|
||||||
|
|
||||||
@@ -211,6 +218,7 @@ our %opt;
|
|||||||
|
|
||||||
our $help=0;
|
our $help=0;
|
||||||
our $compat=0;
|
our $compat=0;
|
||||||
|
our $perl_version=0;
|
||||||
our $addlicense=0;
|
our $addlicense=0;
|
||||||
our $noprefix=0;
|
our $noprefix=0;
|
||||||
our $force=0;
|
our $force=0;
|
||||||
@@ -527,6 +535,7 @@ setlocale(LC_ALL, "en_US.UTF-8");
|
|||||||
GetOptions(
|
GetOptions(
|
||||||
'help|h' => \$help,
|
'help|h' => \$help,
|
||||||
'old|o' => \$compat,
|
'old|o' => \$compat,
|
||||||
|
'perl-version|P=s' => \$perl_version,
|
||||||
'license|l' => \$addlicense,
|
'license|l' => \$addlicense,
|
||||||
'noprefix|n' => \$noprefix,
|
'noprefix|n' => \$noprefix,
|
||||||
'force|f' => \$force,
|
'force|f' => \$force,
|
||||||
@@ -572,14 +581,21 @@ if (!$packager or $packager eq "\%packager") {
|
|||||||
|
|
||||||
our %corelist;
|
our %corelist;
|
||||||
|
|
||||||
my $rpm=new FileHandle "rpm -q --provides perl|"
|
if($perl_version) {
|
||||||
or warn "Failed to execute rpm: $!\n";
|
die("Unknown perl version: $perl_version. (Known versions: " . join(", ", keys %Module::CoreList::version) . ")")
|
||||||
|
unless exists $Module::CoreList::version{$perl_version};
|
||||||
|
%corelist = %{ $Module::CoreList::version{$perl_version} };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $rpm=new FileHandle "rpm -q --provides perl|"
|
||||||
|
or warn "Failed to execute rpm: $!\n";
|
||||||
|
|
||||||
while (my $provides=<$rpm>) {
|
while (my $provides=<$rpm>) {
|
||||||
chomp $provides;
|
chomp $provides;
|
||||||
|
|
||||||
if ($provides=~/^perl\(([^\)]+)\)(?:\s+=\s+(\S+))\s*$/) {
|
if ($provides=~/^perl\(([^\)]+)\)(?:\s+=\s+(\S+))\s*$/) {
|
||||||
$corelist{$1}=defined($2) ? $2 : 0;
|
$corelist{$1}=defined($2) ? $2 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1042,7 +1058,7 @@ END
|
|||||||
|
|
||||||
for my $dep (sort(keys(%build_requires))) {
|
for my $dep (sort(keys(%build_requires))) {
|
||||||
next if exists $dep_blacklist{$dep};
|
next if exists $dep_blacklist{$dep};
|
||||||
if (exists($corelist{$dep})) {
|
if (exists($corelist{$dep}) && $corelist{$dep} ge $build_requires{$dep}) {
|
||||||
next if (!$compat);
|
next if (!$compat);
|
||||||
} elsif ($follow) {
|
} elsif ($follow) {
|
||||||
if ($dep ne $module and !(grep { $_ eq $dep } @processed, @args)) {
|
if ($dep ne $module and !(grep { $_ eq $dep } @processed, @args)) {
|
||||||
|
|||||||
Reference in new issue
Block a user