From 82c36963aebbc9857585762c82c7a5d111420c7e Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sat, 9 Jun 2007 11:16:55 +0000 Subject: rework `special' package names a bit. - do a test to create partial-foo-1.0.1 instead of partial-partial-foo-1.0 when removing partial-foo fails. - have .libs name generation, e.g., .libs-foo, then .libs1-foo, then .libs2-foo instead of .libs-.libs-foo.... extend the pkgspec pattern slightly, so that all these are more or less equivalent for dependencies and conflicts. With this, we can do practically any scenario of shared libs updates and downgrades. --- usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 4 ++-- usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 28 ++++++++++++++++++++++------ usr.sbin/pkg_add/OpenBSD/PkgSpec.pm | 3 ++- usr.sbin/pkg_add/OpenBSD/Replace.pm | 6 ++++-- usr.sbin/pkg_add/OpenBSD/Update.pm | 4 ++-- usr.sbin/pkg_add/pkg_add | 4 ++-- 6 files changed, 34 insertions(+), 15 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm index e1657d2ee56..5f58b0a9f52 100644 --- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm +++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: CollisionReport.pm,v 1.13 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: CollisionReport.pm,v 1.14 2007/06/09 11:16:54 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie # @@ -76,7 +76,7 @@ sub collision_report($$) if ($pkg =~ m/^(?:partial\-|borked\.\d+$)/o) { $clueless_bat = $pkg; } - if ($pkg =~ m/^\.libs-*$/o) { + if ($pkg =~ m/^\.libs\d*-*$/o) { $clueless_bat2 = $pkg; } } diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index 068f5f6ee9c..371b6d7d0a5 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageInfo.pm,v 1.33 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.34 2007/06/09 11:16:54 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -124,16 +124,32 @@ sub installed_contents sub borked_package { - my $pkgname = $_[0]; - unless (-e "$pkg_db/partial-$pkgname") { - return "partial-$pkgname"; + my $pkgname = shift; + $pkgname = "partial-$pkgname" unless $pkgname =~ m/^partial\-/; + unless (-e "$pkg_db/$pkgname") { + return $pkgname; } my $i = 1; - while (-e "$pkg_db/partial-$pkgname.$i") { + while (-e "$pkg_db/$pkgname.$i") { $i++; } - return "partial-$pkgname.$i"; + return "$pkgname.$i"; +} + +sub libs_package +{ + my $pkgname = shift; + $pkgname =~ s/^\.libs\d*\-//; + unless (-e "$pkg_db/.libs-$pkgname") { + return ".libs-$pkgname"; + } + my $i = 1; + + while (-e "$pkg_db/.libs$i-$pkgname") { + $i++; + } + return ".libs$i-$pkgname"; } sub is_installed diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm index d8795327e10..ea1b19b8184 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgSpec.pm,v 1.15 2007/06/04 20:48:23 espie Exp $ +# $OpenBSD: PkgSpec.pm,v 1.16 2007/06/09 11:16:54 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -174,6 +174,7 @@ sub subpattern_match $stemspec =~ s/\+/\\\+/go; $stemspec =~ s/\*/\.\*/go; $stemspec =~ s/\?/\./go; + $stemspec =~ s/^(\\\.libs)\-/$1\\d*\-/go; $vspec =~ s/\./\\\./go; $vspec =~ s/\+/\\\+/go; $vspec =~ s/\*/\.\*/go; diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index 5e85ec86998..b64aa60b27f 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Replace.pm,v 1.38 2007/06/09 10:30:53 espie Exp $ +# $OpenBSD: Replace.pm,v 1.39 2007/06/09 11:16:54 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie # @@ -376,7 +376,9 @@ sub split_libs (my $splitted, $plist) = split_some_libs($plist, $to_split); - $splitted->set_pkgname(".libs-".$plist->pkgname); + require OpenBSD::PackageInfo; + + $splitted->set_pkgname(OpenBSD::PackageInfo::libs_package($plist->pkgname)); if (defined $plist->{'no-default-conflict'}) { # we conflict with the package we just removed... diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index f3dd40af440..5833d8468bb 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.79 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: Update.pm,v 1.80 2007/06/09 11:16:54 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie # @@ -57,7 +57,7 @@ sub add2updates sub process_package { my ($self, $pkgname, $state) = @_; - if ($pkgname =~ m/^(?:\.libs|partial)\-/o) { + if ($pkgname =~ m/^(?:\.libs\d*|partial)\-/o) { $state->progress->clear; print "Not updating $pkgname, remember to clean it\n"; return; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 952d3cbae76..3164b6ea27c 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.314 2007/06/09 10:30:53 espie Exp $ +# $OpenBSD: pkg_add,v 1.315 2007/06/09 11:16:54 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -742,7 +742,7 @@ sub uses_old_libs my $plist = shift; require OpenBSD::RequiredBy; - return grep {/^\.libs\-/o} + return grep {/^\.libs\d*\-/o} OpenBSD::Requiring->new($plist->pkgname)->list; } -- cgit v1.2.3