summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@mandriva.com>2009-01-13 14:09:05 +0000
committerChristophe Fergeau <cfergeau@mandriva.com>2009-01-13 14:09:05 +0000
commitf8c1eabb7d685ee517ecac69b682b96398cec860 (patch)
treee7588525df2162f3958794a13b8544fea48a9a99
parente39d69aa09e8489351ae23a12d7a88a90ea9db32 (diff)
downloadurpmi-f8c1eabb7d685ee517ecac69b682b96398cec860.tar
urpmi-f8c1eabb7d685ee517ecac69b682b96398cec860.tar.gz
urpmi-f8c1eabb7d685ee517ecac69b682b96398cec860.tar.bz2
urpmi-f8c1eabb7d685ee517ecac69b682b96398cec860.tar.xz
urpmi-f8c1eabb7d685ee517ecac69b682b96398cec860.zip
Mark packages as "manually installed"
With the orphan mechanism, there is no way to manually mark a package that was installed as a dep of another package as not being a potential orphan. Mimic apt and if an already package is passed as an argument to urpmi, remove it from the potential orphans list. Fixes bug #45054.
-rw-r--r--urpm/orphans.pm38
-rwxr-xr-xurpmi9
2 files changed, 44 insertions, 3 deletions
diff --git a/urpm/orphans.pm b/urpm/orphans.pm
index 15546190..13e46ed3 100644
--- a/urpm/orphans.pm
+++ b/urpm/orphans.pm
@@ -4,6 +4,7 @@ use strict;
use urpm::util;
use urpm::msg;
use urpm;
+use strict;
# $Id: select.pm 243120 2008-07-01 12:24:34Z pixel $
@@ -38,6 +39,29 @@ sub unrequested_list {
} cat_(unrequested_list__file($urpm)) };
}
+#- side-effects: those of _write_unrequested_list__file
+sub mark_as_requested {
+ my ($urpm, $state, $test) = @_;
+ my $unrequested = unrequested_list($urpm);
+ my @requested;
+
+ push @requested, map { ($urpm->{depslist}[$_])->name } keys %{$state->{rejected_already_installed} || {}};
+
+ foreach (@requested) {
+ my $name = $_;
+ if ($unrequested->{$_}) {
+ $urpm->{info}(N("Marking $_ as manually installed, it won't be auto-orphaned"));
+ } else {
+ $urpm->{debug}("$_ is not in potential orphans") if $urpm->{debug};
+ print("$_ is not in potential orphans\n");
+ }
+ delete $unrequested->{$_};
+ }
+ if (!$test) {
+ _write_unrequested_list__file($urpm, $unrequested);
+ }
+}
+
#- side-effects:
#- + those of _installed_req_and_unreq_and_update_unrequested_list (<root>/var/lib/rpm/installed-through-deps.list)
sub _installed_req_and_unreq {
@@ -53,7 +77,17 @@ sub _installed_and_unrequested_lists {
push @$pkgs, @$pkgs2;
($pkgs, $unrequested);
}
+
#- side-effects: <root>/var/lib/rpm/installed-through-deps.list
+sub _write_unrequested_list__file {
+ my ($urpm, $unreq) = @_;
+
+ output_safe(unrequested_list__file($urpm),
+ join('', sort map { $_->name . "\n" } @$unreq),
+ ".old") if !$urpm->{env_dir};
+}
+
+#- side-effects: those of _write_unrequested_list__file
sub _installed_req_and_unreq_and_update_unrequested_list {
my ($urpm) = @_;
@@ -64,9 +98,7 @@ sub _installed_req_and_unreq_and_update_unrequested_list {
my ($unreq, $req) = partition { $unrequested->{$_->name} } @$pkgs;
# update the list (to filter dups and now-removed-pkgs)
- output_safe(unrequested_list__file($urpm),
- join('', sort map { $_->name . "\n" } @$unreq),
- ".old") if !$urpm->{env_dir};
+ _write_unrequested_list__file($urpm, $unreq);
($req, $unreq, $unrequested);
}
diff --git a/urpmi b/urpmi
index 18eabe11..fec56f1a 100755
--- a/urpmi
+++ b/urpmi
@@ -574,6 +574,15 @@ if (@to_install && $options{auto_orphans}) {
}
}
+#- this cleans up the list of potential orphan packages:
+#- - if a package is explicitly requested on the command line, then
+#- we assume the user doesn't want this package to be auto orphaned
+#- so we remove it from installed-through-deps
+#- - this also takes care of removing packages from
+#- installed-through-deps if the package was first installed as a
+#- dep of another package, then removed and then explicitly installed
+urpm::orphans::mark_as_requested($urpm, $state, $test);
+
foreach my $pkg (@to_install) {
#- reflect change in flag usage, now requested is set whatever a package is selected or not,
#- but required is always set (so a required but not requested is a pure dependency).