diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-03-15 12:17:16 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-03-15 12:17:16 +0000 |
commit | 1ffac3dcb06889eb66393531445b57af91a433a2 (patch) | |
tree | 5df6da27e7fabe47d38c7187ae4dd49eef124c83 | |
parent | 99405741040a80ddd6d35dc982cf59cef171f609 (diff) | |
download | mgatools-1ffac3dcb06889eb66393531445b57af91a433a2.tar mgatools-1ffac3dcb06889eb66393531445b57af91a433a2.tar.gz mgatools-1ffac3dcb06889eb66393531445b57af91a433a2.tar.bz2 mgatools-1ffac3dcb06889eb66393531445b57af91a433a2.tar.xz mgatools-1ffac3dcb06889eb66393531445b57af91a433a2.zip |
(check_if_expandable) split it out of cleanrpmsrate()
-rw-r--r-- | pm/MGATools/rpmsrate.pm | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/pm/MGATools/rpmsrate.pm b/pm/MGATools/rpmsrate.pm index d6c611b..cd6cb27 100644 --- a/pm/MGATools/rpmsrate.pm +++ b/pm/MGATools/rpmsrate.pm @@ -73,6 +73,36 @@ sub preread_rpmsrate { (\@rpmsrate, \%potloc); } +sub check_if_expandable { + my ($key, $raw, $fullpath, $potloc, $locale, $localized_pkg, $urpm2, $o_urpm) = @_; + my ($pg, $loc) = $raw =~ /^(.*)-([^-+]+)$/; + return if !$pg || !$loc; + return if !$potloc->{$pg}; + + my $pkg; + # try to lookup package in urpm first (if we got an $urpm and if media were parsed): + $pkg = $o_urpm->{rpm}{$o_urpm->{rpmkey}{key}{$key}} if ref($o_urpm); + + # if package is not urpmi' synthesis, try to parse it directly: + if (!$pkg) { + my $id = $urpm2->parse_rpm($fullpath); + $pkg = $urpm2->{depslist}[$id]; + } + + # still nothing? bailout: + if (!$pkg) { + print "ERROR cleanrpmsrate: parse_rpm $fullpath ($key) failed\n"; + next; + } + + # some i18n packages does not require the same locale, e.g. kde-i18n-nb and nn requires locales-no + # if (grep { s/locales-// && $loc =~ /^$_(_|$)/ } @{$header{REQUIRENAME}}) { + if (any { /^locales-...?$/ } $pkg->requires) { + push @{$locale->{$pg}}, $loc; + $localized_pkg->{"$pg-$loc"} = 1; + } +} + # function copied from Mkcd::Tools sub cleanrpmsrate { my ($rpmsrate, $output, $norpmsrate, $reprpms, $o_urpm) = @_; @@ -111,31 +141,8 @@ sub cleanrpmsrate { } elsif (URPM::ranges_overlap("== $3", "> $rpms{$vname}[0]")) { $rpms{$vname} = [ $3, $vname ]; } - } elsif (my ($pg, $loc) = /^(.*)-([^-+]+)$/) { - if ($potloc{$pg}) { - my $pkg; - # try to lookup package in urpm first (if we got an $urpm and if media were parsed): - $pkg = $o_urpm->{rpm}{$o_urpm->{rpmkey}{key}{$key}} if ref($o_urpm); - - # if package is not urpmi' synthesis, try to parse it directly: - if (!$pkg) { - my $id = $urpm2->parse_rpm("$dir/$rpm"); - $pkg = $urpm2->{depslist}[$id]; - } - - # still nothing? bailout: - if (!$pkg) { - print "ERROR cleanrpmsrate: parse_rpm $dir/$rpm ($key) failed\n"; - next; - } - - # some i18n packages does not require the same locale, e.g. kde-i18n-nb and nn requires locales-no - # if (grep { s/locales-// && $loc =~ /^$_(_|$)/ } @{$header{REQUIRENAME}}) { - if (any { /^locales-...?$/ } $pkg->requires) { - push @{$locale{$pg}}, $loc; - $localized_pkg{"$pg-$loc"} = 1; - } - } + } else { + check_if_expandable($key, $_, "$dir/$rpm", \%potloc, \%locale, \%localized_pkg, $urpm2, $o_urpm); } } } |