Skip to content

Commit

Permalink
fix for the situation where a noarch package depends on at least one …
Browse files Browse the repository at this point in the history
…of several architectures of a package being installed
  • Loading branch information
StephaneGerardVUB committed Nov 30, 2023
1 parent 2835821 commit e1d5c63
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ncm-spma/src/main/perl/spma/yum.pm
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,29 @@ sub spare_dependencies
return $self->spare_deps_requires($rm, $install, $error_is_warn);
}
}
# When a package appears in the "to remove" list
# with more than one architecture, we must keep at
# least one, because some noarch packages could depend
# on one of them (example: redhat-rpm-config).
sub keep_noarch_deps
{
my ($self, $torm) = @_;

my @torm_nameonly = map { (my $x = $_) =~ s/(.*);(.*)/$1/g; $x } @$torm;

my @torm_sorted = sort(@$torm);
my @torm_no_uniq = do { my %seen; grep { !$seen{$_}++ } @torm_nameonly};

my @torm_reduced;
foreach my $elem (@torm_no_uniq) {
my @found = grep(/$elem/, @torm_sorted);
push(@torm_reduced, $found[0]);
};
$torm->clear();
$torm->insert(@torm_reduced);

return 1;
}

# Completes any pending transactions
sub _do_complete_transaction {
Expand Down Expand Up @@ -919,6 +941,7 @@ sub update_pkgs
$to_rm = $self->packages_to_remove($wanted);
defined($to_rm) or return 0;
$self->spare_dependencies($to_rm, $to_install, $error_is_warn);
$self->keep_noarch_deps($to_rm);
$tx = $self->schedule(REMOVE, $to_rm);
}

Expand Down

0 comments on commit e1d5c63

Please sign in to comment.