summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--urpm/orphans.pm48
2 files changed, 51 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 5d6bcd63..ba8902ba 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
- orphans handling
o do not offer to remove current kernel (even if it's not a official
kernel
+ o offer to remove old kernels (excluding the running one)
+ (also do not do anything regarding kernels if we failed to detect
+ the running one (ie: chroot))
Version 6.27.1 - 18 August 2009
diff --git a/urpm/orphans.pm b/urpm/orphans.pm
index a7f722f9..04308e26 100644
--- a/urpm/orphans.pm
+++ b/urpm/orphans.pm
@@ -297,6 +297,48 @@ sub _get_current_kernel_package() {
}
+# - returns list of kernels
+#
+# _fast_ version w/o looking at all non kernel packages requires on
+# kernels (like "urpmi_find_leaves '^kernel'" would)
+#
+# _all_unrequested_orphans blacklists nearly all kernels b/c of packages
+# like 'ndiswrapper' or 'basesystem' that requires 'kernel'
+#
+# rationale: other packages only require 'kernel' or a sub package we
+# do not care about (eg: kernel-devel, kernel-firmware, kernel-latest)
+# so it's useless to look at them
+#
+my (@requested_kernels, %kernels);
+sub _kernel_callback {
+ my ($pkg) = @_;
+ my $shortname = $pkg->name;
+ my $n = $pkg->fullname;
+
+ # only consider kernels (and not main 'kernel' package):
+ return if $shortname !~ /^kernel-/;
+
+ # only consider real kernels (and not kernel-doc and the like):
+ return if $shortname =~ /-(?:doc|headers|firmware(?:|-extra))$/;
+
+ # keep track of latest kernels in order not to try removing requested kernels:
+ if ($n =~ /latest/) {
+ push @requested_kernels, $pkg->requires;
+ } else {
+ $kernels{$shortname} = $pkg;
+ }
+}
+
+
+# - returns list of orphan kernels
+sub _get_orphan_kernels() {
+ # keep kernels required by kernel-*-latest:
+ delete $kernels{$_} foreach @requested_kernels;
+ # return list of unused/orphan kernels:
+ %kernels;
+}
+
+
#- returns the list of "unrequested" orphans.
#-
#- side-effects: none
@@ -312,6 +354,8 @@ sub _all_unrequested_orphans {
my $current_kernel = _get_current_kernel_package();
while (my $pkg = shift @$req) {
+ # do not do anything regarding kernels if we failed to detect the running one (ie: chroot)
+ _kernel_callback($pkg) if $current_kernel;
foreach my $prop ($pkg->requires, $pkg->suggests) {
my $n = URPM::property2name($prop);
foreach my $p (@{$provides{$n} || []}) {
@@ -323,6 +367,10 @@ sub _all_unrequested_orphans {
}
}
+ # add orphan kernels to the list:
+ my $a = { _get_orphan_kernels() };
+ add2hash_(\%l,$a);
+
# do not offer to remove current kernel:
delete $l{$current_kernel};
[ values %l ];