Skip to content

Commit

Permalink
Move detection of orphans from create_state()
Browse files Browse the repository at this point in the history
- Create a sub to compute orphans and called at better times, to avoid
  including packages that were automatically removed from dependencies.
- Remove all automatically rejected packages from state, including the package
  asked to be removed.
  • Loading branch information
jvdm committed Aug 9, 2011
1 parent bb47584 commit 1a79d76
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
36 changes: 28 additions & 8 deletions backend/mdvpkg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ use urpm::orphans qw();
use URPM;


##
# compute_orphans
# Compute from a $state object the orphans to remove and add them
# to @to_remove.
# :Parameters:
# `$urpm` : The urpm object
# `$state` : The state object
# `$to_remove : list ref
# The list of names to append orphans.
# :Returns:
# The $to_remove list ref
#
sub compute_orphans {
my $urpm = shift;
my $state = shift;
my $to_remove = shift;

urpm::orphans::compute_future_unrequested_orphans(
$urpm,
$state
);
push(@{ $to_remove },
map {
scalar $_->fullname
} @{ $state->{orphans_to_remove} });
return $to_remove
}

##
# create_state
# Get lists of package fullnames for installation and removal to
Expand Down Expand Up @@ -68,14 +96,6 @@ sub create_state {
die {error => 'error-nothing-to-remove',
names => []}
};
urpm::orphans::compute_future_unrequested_orphans(
$urpm,
\%state
);
push(@to_remove,
map {
scalar $_->fullname
} @{ $state{orphans_to_remove} });
}

my $restart;
Expand Down
3 changes: 3 additions & 0 deletions backend/resolve.pl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
my ($removed)
= keys %{ $state->{rejected}{$_}{removed} };
push @{ $depends{$removed} ||= [] }, $_;
delete $state->{rejected}{$_};
}
foreach (keys %depends) {
delete $state->{rejected}{$_};
Expand All @@ -166,6 +167,8 @@
}
}

mdvpkg::compute_orphans($urpm, $state, $to_remove);

# Emit actions ...
while (my ($id, $info) = each %{ $state->{selected} }) {
my $pkg = $urpm->{depslist}[$id];
Expand Down
2 changes: 2 additions & 0 deletions backend/urpmi_backend.pl
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ sub on_task__commit {
}
or do {
response('error', $@->{error}, @{ $@->{names} });
return;
};

$to_remove = mdvpkg::compute_orphans($urpm, $state, $to_remove);

# Populate pkg_map ...
my %pkg_map = ();
Expand Down

0 comments on commit 1a79d76

Please sign in to comment.