summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2009-08-20 14:06:43 +0000
committerThierry Vignaud <tv@mandriva.org>2009-08-20 14:06:43 +0000
commite6396fe8683c1b43098efc8f60a09025c60e8192 (patch)
tree3939cbe9340b50396162b047a10a526471389a58 /urpm
parent249248c51cc2045ee51acd90e0c5ec7cfe5fb5d2 (diff)
downloadurpmi-e6396fe8683c1b43098efc8f60a09025c60e8192.tar
urpmi-e6396fe8683c1b43098efc8f60a09025c60e8192.tar.gz
urpmi-e6396fe8683c1b43098efc8f60a09025c60e8192.tar.bz2
urpmi-e6396fe8683c1b43098efc8f60a09025c60e8192.tar.xz
urpmi-e6396fe8683c1b43098efc8f60a09025c60e8192.zip
(_kernel_callback,_get_orphan_kernels,_all_unrequested_orphans) offer
to remove old kernels (excluding the running one) do not do anything if we failed to detect the running one (ie: chroot))
Diffstat (limited to 'urpm')
-rw-r--r--urpm/orphans.pm48
1 files changed, 48 insertions, 0 deletions
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 ];