summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-11-16 20:11:22 +0000
committerThierry Vignaud <tv@mageia.org>2012-11-16 20:11:22 +0000
commite0087eccd1af4155b06d82e590a3fff0e8e46b33 (patch)
tree3cb5dbb065396dcd2fa49fbb84ee5d2f586b8169 /urpm
parente68126591e246735d6ed1b3eab66304b82ec7661 (diff)
downloadurpmi-e0087eccd1af4155b06d82e590a3fff0e8e46b33.tar
urpmi-e0087eccd1af4155b06d82e590a3fff0e8e46b33.tar.gz
urpmi-e0087eccd1af4155b06d82e590a3fff0e8e46b33.tar.bz2
urpmi-e0087eccd1af4155b06d82e590a3fff0e8e46b33.tar.xz
urpmi-e0087eccd1af4155b06d82e590a3fff0e8e46b33.zip
(_schedule_packages_for_erasing) split it out of install()
Diffstat (limited to 'urpm')
-rw-r--r--urpm/install.pm80
1 files changed, 45 insertions, 35 deletions
diff --git a/urpm/install.pm b/urpm/install.pm
index a0e0cbbf..7cf36a15 100644
--- a/urpm/install.pm
+++ b/urpm/install.pm
@@ -174,39 +174,8 @@ sub options {
);
}
-=item install($urpm, $remove, $install, $upgrade, %options)
-
-Install packages according to each hash (remove, install or upgrade).
-
-options:
- test, excludepath, nodeps, noorder (unused), delta,
- callback_inst, callback_trans, callback_report_uninst,
- post_clean_cache, verbose
- (more options for trans->run)
- excludedocs, nosize, noscripts, oldpackage, replacepkgs, justdb, ignorearch
-
-=cut
-
-sub install {
- my ($urpm, $remove, $install, $upgrade, %options) = @_;
- $options{translate_message} = 1;
-
- my $db = urpm::db_open_or_die_($urpm, !$options{test}); #- open in read/write mode unless testing installation.
-
- my $trans = $db->create_transaction;
- if ($trans) {
- sys_log("transaction on %s (remove=%d, install=%d, upgrade=%d)", $urpm->{root} || '/', scalar(@{$remove || []}), scalar(values %$install), scalar(values %$upgrade));
- $urpm->{log}(N("created transaction for installing on %s (remove=%d, install=%d, upgrade=%d)", $urpm->{root} || '/',
- scalar(@{$remove || []}), scalar(values %$install), scalar(values %$upgrade)));
- } else {
- return N("unable to create transaction");
- }
-
- $trans->set_script_fd($options{script_fd}) if $options{script_fd};
-
- my ($update, @errors) = 0;
- my @produced_deltas;
-
+sub _schedule_packages_for_erasing {
+ my ($urpm, $trans, $remove) = @_;
foreach (@$remove) {
if ($trans->remove($_)) {
$urpm->{debug} and $urpm->{debug}("trans: scheduling removal of $_");
@@ -214,8 +183,11 @@ sub install {
$urpm->{error}("unable to remove package " . $_);
}
}
+}
- my @trans_pkgs;
+sub _schedule_packages {
+ my ($urpm, $trans, $install, $upgrade, $update, %options) = @_;
+ my (@trans_pkgs, @produced_deltas);
foreach my $mode ($install, $upgrade) {
foreach (keys %$mode) {
my $pkg = $urpm->{depslist}[$_];
@@ -247,6 +219,44 @@ sub install {
}
++$update;
}
+ \@produced_deltas, @trans_pkgs;
+}
+
+=item install($urpm, $remove, $install, $upgrade, %options)
+
+Install packages according to each hash (remove, install or upgrade).
+
+options:
+ test, excludepath, nodeps, noorder (unused), delta,
+ callback_inst, callback_trans, callback_report_uninst,
+ post_clean_cache, verbose
+ (more options for trans->run)
+ excludedocs, nosize, noscripts, oldpackage, replacepkgs, justdb, ignorearch
+
+=cut
+
+sub install {
+ my ($urpm, $remove, $install, $upgrade, %options) = @_;
+ $options{translate_message} = 1;
+
+ my $db = urpm::db_open_or_die_($urpm, !$options{test}); #- open in read/write mode unless testing installation.
+
+ my $trans = $db->create_transaction;
+ if ($trans) {
+ sys_log("transaction on %s (remove=%d, install=%d, upgrade=%d)", $urpm->{root} || '/', scalar(@{$remove || []}), scalar(values %$install), scalar(values %$upgrade));
+ $urpm->{log}(N("created transaction for installing on %s (remove=%d, install=%d, upgrade=%d)", $urpm->{root} || '/',
+ scalar(@{$remove || []}), scalar(values %$install), scalar(values %$upgrade)));
+ } else {
+ return N("unable to create transaction");
+ }
+
+ $trans->set_script_fd($options{script_fd}) if $options{script_fd};
+
+ my ($update, @errors) = 0;
+
+ _schedule_packages_for_erasing($urpm, $trans, $remove);
+
+ my ($produced_deltas, @trans_pkgs) = _schedule_packages($urpm, $trans, $install, $upgrade, $update, %options);
if (!$options{nodeps} && (@errors = $trans->check(%options))) {
} elsif (!$options{noorder} && (@errors = $trans->order)) {
@@ -324,7 +334,7 @@ sub install {
}
}
- unlink @produced_deltas;
+ unlink @$produced_deltas;
urpm::sys::may_clean_rpmdb_shared_regions($urpm, $options{test});