summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-12-20 22:43:26 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-12-20 22:43:26 +0000
commit3f37fd6fabcb5e48a0a2e80051166f8f73bca137 (patch)
treee01d9903d6b91eff7207fec502ca1fa74b5d533a
parent2f09bbf6bd4ee25bccc3a7b87abfae64d9885018 (diff)
allow a replacing package to replace several packages, in principle:
this is just a question of iterating over the replaced packages. The fun part (can_install) still isn't done: wholesale replacements like that mean the inter-dependencies between the replaced packages don't count.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm62
-rw-r--r--usr.sbin/pkg_add/pkg_add32
2 files changed, 49 insertions, 45 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 308143598e4..cc2a1b889c1 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.45 2004/12/20 12:16:51 espie Exp $
+# $OpenBSD: Update.pm,v 1.46 2004/12/20 22:43:25 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -380,40 +380,42 @@ sub save_old_libraries
{
my ($new_plist, $state) = @_;
- my $old_plist = $new_plist->{replacing};
- my $libs = {};
- my $p = {};
+ for my $old_plist (@{$new_plist->{replacing}}) {
- print "Looking for changes in shared libraries\n"
- if $state->{beverbose};
- $old_plist->visit('mark_lib', $libs, $p);
- $new_plist->visit('unmark_lib', $libs, $p);
+ my $libs = {};
+ my $p = {};
- if (%$libs) {
- print "Libraries to keep: ", join(",", sort(keys %$libs)), "\n"
+ print "Looking for changes in shared libraries\n"
if $state->{beverbose};
- my $stub_list = split_libs($old_plist, $libs);
- my $stub_name = $stub_list->pkgname();
- my $dest = installed_info($stub_name);
- print "Keeping them in $stub_name\n" if $state->{beverbose};
- if ($state->{not}) {
- $stub_list->to_cache();
- $old_plist->to_cache();
+ $old_plist->visit('mark_lib', $libs, $p);
+ $new_plist->visit('unmark_lib', $libs, $p);
+
+ if (%$libs) {
+ print "Libraries to keep: ", join(",", sort(keys %$libs)), "\n"
+ if $state->{beverbose};
+ my $stub_list = split_libs($old_plist, $libs);
+ my $stub_name = $stub_list->pkgname();
+ my $dest = installed_info($stub_name);
+ print "Keeping them in $stub_name\n" if $state->{beverbose};
+ if ($state->{not}) {
+ $stub_list->to_cache();
+ $old_plist->to_cache();
+ } else {
+ mkdir($dest);
+ my $oldname = $old_plist->pkgname();
+ open my $comment, '>', $dest.COMMENT;
+ print $comment "Stub libraries for $oldname";
+ close $comment;
+ link($dest.COMMENT, $dest.DESC);
+ $stub_list->to_installation();
+ $old_plist->to_installation();
+ }
+ add_installed($stub_name);
+
+ walk_depends_closure($old_plist->pkgname(), $stub_name, $state);
} else {
- mkdir($dest);
- my $oldname = $old_plist->pkgname();
- open my $comment, '>', $dest.COMMENT;
- print $comment "Stub libraries for $oldname";
- close $comment;
- link($dest.COMMENT, $dest.DESC);
- $stub_list->to_installation();
- $old_plist->to_installation();
+ print "No libraries to keep\n" if $state->{beverbose};
}
- add_installed($stub_name);
-
- walk_depends_closure($old_plist->pkgname(), $stub_name, $state);
- } else {
- print "No libraries to keep\n" if $state->{beverbose};
}
}
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 88dc296e314..0fb2ff7971a 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.158 2004/12/20 22:19:24 espie Exp $
+# $OpenBSD: pkg_add,v 1.159 2004/12/20 22:43:25 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -46,6 +46,7 @@ sub can_install($$$)
{
my ($plist, $state, $handle) = @_;
my $pkgname = $plist->pkgname();
+ $plist->{replacing} = [];
my @conflicts = OpenBSD::PkgCfl::find_all($plist, $state);
return 1 if @conflicts == 0;
@@ -108,7 +109,7 @@ sub can_install($$$)
return undef;
}
$rplist->{dir} = installed_info($conflicts[0]);
- $plist->{replacing} = $rplist;
+ push(@{$plist->{replacing}}, $rplist);
return 1;
} else {
print "Can't update $conflicts[0] into $pkgname\n";
@@ -288,7 +289,7 @@ sub really_add($$)
$plist->{dir} = $dir;
$state->set_pkgname($pkgname);
$state->{replacing} = 0;
- if (defined $plist->{replacing}) {
+ if (@{$plist->{replacing}}) {
$state->{replacing} = 1;
}
if (defined $plist->{old_libs}) {
@@ -300,8 +301,8 @@ sub really_add($$)
if (defined $state->{deptree}->{$pkgname}) {
$header = $state->{deptree}->{$pkgname}.":".$header;
}
- if (defined $plist->{replacing}) {
- $header.=" (replacing ". $plist->{replacing}->pkgname(). ")";
+ if (@{$plist->{replacing}}) {
+ $header.=" (replacing ". join(', ', (map {$_->pkgname()}@{$plist->{replacing}})). ")";
}
if (!OpenBSD::ProgressMeter::set_header($header)) {
print $state->{not} ? "Pretending to add " : "Adding ";
@@ -355,20 +356,20 @@ sub really_add($$)
"Installation of $pkgname failed");
}
- if (defined $plist->{replacing}) {
- OpenBSD::ProgressMeter::set_header($plist->{replacing}->pkgname()." (deleting)");
- $state->set_pkgname($plist->{replacing}->pkgname());
+ for my $op (@{$plist->{replacing}}) {
+ OpenBSD::ProgressMeter::set_header($op->pkgname()." (deleting)");
+ $state->set_pkgname($op->pkgname());
require OpenBSD::Delete;
try {
- OpenBSD::Delete::delete_plist($plist->{replacing}, $state);
+ OpenBSD::Delete::delete_plist($op, $state);
} catchall {
Warn $_;
OpenBSD::Add::borked_installation($plist, $dir,
"Deinstallation of ",
- $plist->{replacing}->pkgname(), " failed");
+ $op->pkgname(), " failed");
};
- delete_installed($plist->{replacing}->pkgname());
+ delete_installed($op->pkgname());
}
# Here there should be code to handle old libs
@@ -440,17 +441,18 @@ sub really_add($$)
$plist->get(DISPLAY)->prepare($state);
}
# and add dependencies corresponding to the replacement
- if (defined $plist->{replacing}) {
+ for my $op (@{$plist->{replacing}}) {
require OpenBSD::RequiredBy;
require OpenBSD::Update;
+ my $opkgname = $op->pkgname();
- print "Adjusting dependencies for $pkgname\n"
+ print "Adjusting dependencies for $pkgname/$opkgname\n"
if $state->{beverbose};
my $d = OpenBSD::RequiredBy->new($pkgname);
- for my $dep (@{$plist->{replacing}->{wantlist}}) {
+ for my $dep (@{$op->{wantlist}}) {
print "\t$dep\n" if $state->{beverbose};
$d->add($dep);
- OpenBSD::Update::adjust_dependency($dep, $plist->{replacing}->pkgname(), $pkgname);
+ OpenBSD::Update::adjust_dependency($dep, $opkgname, $pkgname);
}
}
}