From 71faac3c9b8a6471eb6955b9fc614071943322db Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 15 Mar 2012 12:30:46 +0000 Subject: (lookup_pkg) split it out of check_if_expandable() --- pm/MGATools/rpmsrate.pm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pm/MGATools/rpmsrate.pm b/pm/MGATools/rpmsrate.pm index a027886..64d67ed 100644 --- a/pm/MGATools/rpmsrate.pm +++ b/pm/MGATools/rpmsrate.pm @@ -73,21 +73,24 @@ sub preread_rpmsrate { (\@rpmsrate, \%potloc); } +sub lookup_pkg { + my ($key, $fullpath, $urpm2, $o_urpm) = @_; + + # try to lookup package in urpm first (if we got an $urpm and if media were parsed): + return $o_urpm->{rpm}{$o_urpm->{rpmkey}{key}{$key}} if ref($o_urpm); + + # if package is not urpmi' synthesis, try to parse it directly: + my $id = $urpm2->parse_rpm($fullpath); + return $urpm2->{depslist}[$id]; +} + 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]; - } + my $pkg = lookup_pkg($key, $fullpath, $urpm2, $o_urpm); # still nothing? bailout: if (!$pkg) { -- cgit v1.2.1