diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2010-02-25 19:51:25 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-03-01 11:52:50 +0200 |
commit | b8f47a77f5dca3fcd4acbb822dd4824b582341bf (patch) | |
tree | 168ccc561137cbb9336bacf69279fd2392f7fbb8 /scripts | |
parent | c4b4a7e712e36d5074679e413e14150031eed407 (diff) | |
download | rpm-b8f47a77f5dca3fcd4acbb822dd4824b582341bf.tar.gz rpm-b8f47a77f5dca3fcd4acbb822dd4824b582341bf.tar.bz2 rpm-b8f47a77f5dca3fcd4acbb822dd4824b582341bf.zip |
Emit highest versions of perl module deps, not first versioned ones found.
Requires the "version" module installed (perl >= 5.9 or separately), falls
back to the previous "output first versioned one found" behavior if it is
not available.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/perl.req | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/scripts/perl.req b/scripts/perl.req index 0d543b79d..ab21b08ea 100755 --- a/scripts/perl.req +++ b/scripts/perl.req @@ -39,6 +39,10 @@ # by Ken Estes Mail.com kestes@staff.mail.com +$HAVE_VERSION = 0; +eval { require version; $HAVE_VERSION = 1; }; + + if ("@ARGV") { foreach (@ARGV) { process_file($_); @@ -74,6 +78,18 @@ exit 0; +sub add_require { + my ($module, $newver) = @_; + my $oldver = $require{$module}; + if ($oldver) { + $require{$module} = $newver + if ($HAVE_VERSION && $newver && version->new($oldver) < $newver); + } + else { + $require{$module} = $newver; + } +} + sub process_file { my ($file) = @_; @@ -247,18 +263,18 @@ sub process_file { # use base qw(Foo) dependencies if ($statement eq "use" && $module eq "base") { - $require{$module} ||= undef; + add_require($module, undef); if ($version =~ /^qw\s*[(\/]\s*([^)\/]+?)\s*[)\/]/) { - $require{$_} ||= undef for split(' ', $1); + add_require($_, undef) for split(' ', $1); } elsif ($version =~ /(["'])([^"']+)\1/) { - $require{$2} ||= undef; + add_require($2, undef); } next; } $version = undef unless $version =~ /^$modver_re$/o; - $require{$module} ||= $version; + add_require($module, $version); } } |