summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2004-11-21 15:36:17 +0000
committerespie <espie@openbsd.org>2004-11-21 15:36:17 +0000
commitef27c4a1b37cb47b3850a343adb475baea6276b3 (patch)
tree56f3663c42bf9078e26a143ef65f4c15a1dc0fd2
parentcheck_lib_specs -> check_lib_spec: check one spec at a time, and report on it. (diff)
downloadwireguard-openbsd-ef27c4a1b37cb47b3850a343adb475baea6276b3.tar.xz
wireguard-openbsd-ef27c4a1b37cb47b3850a343adb475baea6276b3.zip
pull the code that handles shared libraries (ldconfig for now) aside.
-rw-r--r--usr.sbin/pkg_add/Makefile3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm51
-rw-r--r--usr.sbin/pkg_add/OpenBSD/SharedLibs.pm70
3 files changed, 82 insertions, 42 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile
index 66d9f1fb4cc..04c4bcf7989 100644
--- a/usr.sbin/pkg_add/Makefile
+++ b/usr.sbin/pkg_add/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.17 2004/11/11 12:29:58 espie Exp $
+# $OpenBSD: Makefile,v 1.18 2004/11/21 15:36:17 espie Exp $
MAN=pkg_add.1 pkg_info.1 pkg_create.1 pkg_delete.1 pkg.1
@@ -21,6 +21,7 @@ PACKAGES= \
OpenBSD/ProgressMeter.pm \
OpenBSD/RequiredBy.pm \
OpenBSD/SharedItems.pm \
+ OpenBSD/SharedLibs.pm \
OpenBSD/Temp.pm \
OpenBSD/Update.pm \
OpenBSD/Ustar.pm \
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index cdbe7ba07ff..2661c7e9e41 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.72 2004/11/18 21:46:07 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.73 2004/11/21 15:36:17 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -414,58 +414,27 @@ sub register_manpage
package OpenBSD::PackingElement::Lib;
our @ISA=qw(OpenBSD::PackingElement::FileBase);
-use File::Basename;
-use OpenBSD::Error;
+
+our $todo = 0;
__PACKAGE__->setKeyword('lib');
sub keyword() { "lib" }
-my $todo = 0;
-my $path;
-our @ldconfig = ('/sbin/ldconfig');
-
-sub init_path($)
-{
- my $destdir = shift;
- $path={};
- if ($destdir ne '') {
- unshift @ldconfig, 'chroot', $destdir;
- }
- open my $fh, "-|", @ldconfig, "-r";
- if (defined $fh) {
- local $_;
- while (<$fh>) {
- if (m/^\s*search directories:\s*(.*?)\s*$/) {
- for my $d (split(':', $1)) {
- $path->{$d} = 1;
- }
- }
- }
- close($fh);
- } else {
- print STDERR "Can't find ldconfig\n";
- }
-}
-
sub mark_ldconfig_directory
{
+ require OpenBSD::SharedLibs;
+
my ($self, $destdir) = @_;
- if (!defined $path) {
- init_path($destdir);
- }
- my $d = dirname($self->fullname());
- if ($path->{$d}) {
- $todo = 1;
- }
+ OpenBSD::SharedLibs::mark_ldconfig_directory($self->fullname(),
+ $destdir);
}
sub ensure_ldconfig
{
- my $state = shift;
if ($todo) {
- VSystem($state->{very_verbose},
- @ldconfig, "-R") unless $state->{not};
- $todo = 0;
+ require OpenBSD::SharedLibs;
+
+ &OpenBSD::SharedLibs::ensure_ldconfig();
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm
new file mode 100644
index 00000000000..2aa45aa96f5
--- /dev/null
+++ b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm
@@ -0,0 +1,70 @@
+# ex:ts=8 sw=4:
+# $OpenBSD: SharedLibs.pm,v 1.1 2004/11/21 15:36:17 espie Exp $
+#
+# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+use strict;
+use warnings;
+package OpenBSD::SharedLibs;
+use File::Basename;
+use OpenBSD::Error;
+
+my $path;
+my @ldconfig = ('/sbin/ldconfig');
+
+sub init_path($)
+{
+ my $destdir = shift;
+ $path={};
+ if ($destdir ne '') {
+ unshift @ldconfig, 'chroot', $destdir;
+ }
+ open my $fh, "-|", @ldconfig, "-r";
+ if (defined $fh) {
+ local $_;
+ while (<$fh>) {
+ if (m/^\s*search directories:\s*(.*?)\s*$/) {
+ for my $d (split(':', $1)) {
+ $path->{$d} = 1;
+ }
+ }
+ }
+ close($fh);
+ } else {
+ print STDERR "Can't find ldconfig\n";
+ }
+}
+
+sub mark_ldconfig_directory
+{
+ my ($name, $destdir) = @_;
+ if (!defined $path) {
+ init_path($destdir);
+ }
+ my $d = dirname($name);
+ if ($path->{$d}) {
+ $OpenBSD::PackingElement::Lib::todo = 1;
+ }
+}
+
+sub ensure_ldconfig
+{
+ my $state = shift;
+ VSystem($state->{very_verbose},
+ @ldconfig, "-R") unless $state->{not};
+ $OpenBSD::PackingElement::Lib::todo = 0;
+}
+
+1;