summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pm/MGATools/rpmsrate.pm57
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);
}
}
}