diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-11-21 15:44:57 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-11-21 15:44:57 +0000 |
commit | c53b2a7f20a43b28361bc4013fba89068cb2d217 (patch) | |
tree | 6196ec893e1ea2e890c6924c5d11a8f8431e3615 | |
parent | fb6f361db6a95abea88ca21adc0b58a0414d0856 (diff) |
move the system libraries registration code to SharedLibs.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/SharedLibs.pm | 31 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 33 |
2 files changed, 36 insertions, 28 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm index 2aa45aa96f5..4bcc459fc15 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SharedLibs.pm,v 1.1 2004/11/21 15:36:17 espie Exp $ +# $OpenBSD: SharedLibs.pm,v 1.2 2004/11/21 15:44:56 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -24,6 +24,7 @@ use OpenBSD::Error; my $path; my @ldconfig = ('/sbin/ldconfig'); + sub init_path($) { my $destdir = shift; @@ -67,4 +68,32 @@ sub ensure_ldconfig $OpenBSD::PackingElement::Lib::todo = 0; } +our $registered_libs = {}; + +sub register_lib +{ + my ($stem, $minor, $pkg) = @_; + if (!defined $registered_libs->{"$stem"} || $registered_libs->{"$stem"}->[0] < $minor) { + $registered_libs->{"$stem"} = [$minor, $pkg]; + } +} + +my $done_system = 0; + +sub add_system_libs +{ + my ($destdir) = @_; + return if $done_system; + $done_system = 1; + for my $dirname ("/usr/lib", "/usr/X11R6/lib") { + opendir(my $dir, $destdir.$dirname) or next; + while (my $d = readdir($dir)) { + next unless $d =~ m/^(.*\.so\.\d+)\.(\d+)$/; + my ($stem, $minor) = ($1, $2); + $stem = "$dirname/$stem"; + register_lib($stem, $minor, 'system'); + } + closedir($dir); + } +} 1; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index aea6d0e0069..4bb9c30c95d 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.126 2004/11/21 13:32:18 espie Exp $ +# $OpenBSD: pkg_add,v 1.127 2004/11/21 15:44:55 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -487,25 +487,6 @@ sub find_old_lib return 0; } -my $syst_avail; - -sub add_system_libs -{ - my ($destdir, $avail) = @_; - for my $dirname ("/usr/lib", "/usr/X11R6/lib") { - opendir(my $dir, $destdir.$dirname) or next; - while (my $d = readdir($dir)) { - next unless $d =~ m/^(.*\.so\.\d+)\.(\d+)$/; - my ($stem, $minor) = ($1, $2); - $stem = "$dirname/$stem"; - if (!defined $avail->{"$stem"} || $avail->{"$stem"}->[0] < $minor) { - $avail->{"$stem"} = [$minor, 'system']; - } - } - closedir($dir); - } -} - sub lookup_library { my ($state, $lib, $available, $plist, $dependencies, $harder) = @_; @@ -515,16 +496,15 @@ sub lookup_library return 1; } if ($harder && $lib !~ m|/|) { - if (!defined $syst_avail) { - $syst_avail = {}; - add_system_libs($state->{destdir}, $syst_avail); - } + require OpenBSD::SharedLibs; + + OpenBSD::SharedLibs::add_system_libs($state->{destdir}); if (check_lib_spec($state->{very_verbose}, - $state->{destdir}."/usr", $lib, $syst_avail)) { + $state->{destdir}."/usr", $lib, $OpenBSD::SharedLibs::registered_libs)) { return 1; } if (check_lib_spec($state->{very_verbose}, - $state->{destdir}."/usr/X11R6", $lib, $syst_avail)) { + $state->{destdir}."/usr/X11R6", $lib, $OpenBSD::SharedLibs::registered_libs)) { return 1; } } @@ -623,7 +603,6 @@ sub install_package } } } -# add_system_libs($state->{destdir}, $available); for my $lib (@{$plist->{wantlib}}) { if (!lookup_library($state, $lib->{name}, $available, $plist, $handle->{solved_dependencies}, 1)) { |