From d48431a762f74f6a68f8cf956f154a878ea5368d Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 27 Jul 2022 09:47:53 +0200 Subject: Track kernels by their NVRA No change for mdv-mga8, but it's needed for mga9+ where multiple kernel with the same short name "kernel-foobar" are installed with different versions instead of having different pkgs names such as "kernel-foobar-5.12-1-1.mga8" and "kernel-foobar-5.16.3-1-1.mga8" --- urpm/orphans.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/urpm/orphans.pm b/urpm/orphans.pm index f27bc610..cc9e76d2 100644 --- a/urpm/orphans.pm +++ b/urpm/orphans.pm @@ -443,7 +443,7 @@ so it's useless to look at them # %kernels tracks !"*-latest" kernels (to be later filtered) my (@req_by_latest_kernels, %requested_kernels, %kernels); sub _kernel_callback { - my ($pkg, $unreq_list) = @_; + my ($urpm, $pkg, $unreq_list) = @_; my $shortname = $pkg->name; my $n = $pkg->fullname; @@ -464,9 +464,11 @@ sub _kernel_callback { # keep track of packages required by latest kernels in order not to try removing requested kernels: if ($n =~ /latest/) { - push @req_by_latest_kernels, $pkg->requires; + my @a = $urpm->packages_providing($pkg->requires); + my $kpkg = $a[0]; + push @req_by_latest_kernels, scalar $kpkg->fullname if $kpkg; } else { - $kernels{$shortname} = $pkg; + $kernels{$n} = $pkg; } } @@ -498,7 +500,7 @@ sub _all_unrequested_orphans { my (%l, %provides); # 1- list explicit provides (not files) from installed packages: foreach my $pkg (@$unreq) { - $l{$pkg->name} = $pkg; + $l{$pkg->fullname} = $pkg; push @{$provides{$_}}, $pkg foreach $pkg->provides_nosense; } my $unreq_list = unrequested_list($urpm); @@ -508,12 +510,13 @@ sub _all_unrequested_orphans { # 2- check if "unrequested" packages are still needed: while (my $pkg = shift @$req) { # do not do anything regarding kernels if we failed to detect the running one (ie: chroot) - _kernel_callback($pkg, $unreq_list) if $current_kernel; + _kernel_callback($urpm, $pkg, $unreq_list) if $current_kernel; foreach my $prop ($pkg->requires, $pkg->recommends_nosense) { my $n = URPM::property2name($prop); foreach my $p (@{$provides{$n} || []}) { - if ($p != $pkg && $l{$p->name} && $p->provides_overlap($prop)) { - delete $l{$p->name}; + my $pfn = $p->fullname; + if ($p != $pkg && $l{$pfn} && $p->provides_overlap($prop)) { + delete $l{$pfn}; push @$req, $p; } } -- cgit v1.2.1