diff options
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 53 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 27 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 27 |
4 files changed, 105 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index ec4fc1fbc70..f43c1350205 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.18 2004/08/06 07:51:17 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.19 2004/08/06 10:23:45 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -19,6 +19,9 @@ use strict; use warnings; use OpenBSD::PackageInfo; +# perl ipc +require 5.008_000; + # This is the basic class, which is mostly abstract, except for # setKeyword and Factory. # It does provide base methods for stuff under it, though. @@ -343,6 +346,54 @@ sub destate } } +package OpenBSD::PackingElement::Lib; +our @ISA=qw(OpenBSD::PackingElement::FileBase); +use File::Basename; + +__PACKAGE__->setKeyword('lib'); +sub keyword() { "lib" } + +our $todo; +my $path; +our $ldconfig = '/sbin/ldconfig'; + +sub add_ldconfig_dirs() +{ + my $sub = shift; + return unless defined $todo; + for my $d (keys %$todo) { + &$sub($d); + } + $todo={}; +} + +sub mark_ldconfig_directory +{ + my ($self, $destdir) = @_; + if (!defined $path) { + $path={}; + 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"; + } + } + my $d = dirname($self->fullname()); + if ($path->{$d}) { + $todo = {} unless defined $todo; + $todo->{$d} = 1; + } +} + package OpenBSD::PackingElement::Ignore; our @ISA=qw(OpenBSD::PackingElement); __PACKAGE__->setKeyword('ignore'); diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index bb72c151981..bb650a2dff5 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingList.pm,v 1.20 2004/08/06 08:06:01 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.21 2004/08/06 10:23:45 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -75,7 +75,7 @@ sub FilesOnly my ($fh, $cont) = @_; local $_; while (<$fh>) { - next unless m/^\@(?:cwd|name|info|man|file)\b/ || !m/^\@/; + next unless m/^\@(?:cwd|name|info|man|file|lib)\b/ || !m/^\@/; &$cont($_); } } diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index d9b2e046b6f..f134ef8e1bf 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.42 2004/08/06 08:14:51 espie Exp $ +# $OpenBSD: pkg_add,v 1.43 2004/08/06 10:23:45 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -32,6 +32,16 @@ use File::Copy; our %forced = (); our ($ftp_only, $cdrom_only); +sub ensure_ldconfig +{ + my $verbose = shift; + return unless defined $OpenBSD::PackingElement::Lib::todo; + print "running ldconfig -m ", join(' ', keys %$OpenBSD: pkg_add,v 1.43 2004/08/06 10:23:45 espie Exp $verbose; + system($OpenBSD::PackingElement::Lib::ldconfig, "-m", + keys %$OpenBSD::PackingElement::Lib::todo); + undef $OpenBSD::PackingElement::Lib::todo; +} + package OpenBSD::PackingElement; sub install @@ -151,10 +161,20 @@ sub install { my ($self, $archive, $destdir, $verbose, $not) = @_; + main::ensure_ldconfig($verbose) unless $not; print "exec ", $self->{expanded}, "\n" if $verbose or $not; system('/bin/sh', '-c', $self->{expanded}) unless $not; } +package OpenBSD::PackingElement::Lib; + +sub install +{ + my ($self, $archive, $destdir, $verbose, $not) = @_; + $self->SUPER::install($archive, $destdir, $verbose, $not); + $self->mark_ldconfig_directory($destdir); +} + package OpenBSD::PackingElement::Arch; sub check @@ -552,6 +572,7 @@ sub really_add($$) }; if ($plist->has(REQUIRE)) { + ensure_ldconfig($opt_v) unless $opt_n; print "Require script: $dir",REQUIRE," $pkgname INSTALL\n" if $opt_v or $opt_n; unless ($opt_n) { chmod 0755, $dir.REQUIRE; @@ -562,6 +583,7 @@ sub really_add($$) unless ($opt_I) { if ($plist->has(INSTALL)) { + ensure_ldconfig($opt_v) unless $opt_n; print "Install script: $dir",INSTALL," $pkgname PRE-INSTALL\n" if $opt_v or $opt_n; unless ($opt_n) { chmod 0755, $dir.INSTALL; @@ -595,6 +617,7 @@ sub really_add($$) unless ($opt_I) { if ($plist->has(INSTALL) && !$interrupted) { + ensure_ldconfig($opt_v) unless $opt_n; print "Install script: $dir",INSTALL ," $pkgname POST-INSTALL\n" if $opt_v or $opt_n; unless ($opt_n) { if (system($dir.INSTALL, $pkgname, "POST-INSTALL") != 0) { @@ -684,6 +707,8 @@ while (my $pkg = shift @todo) { $conflict_list->{$plist->pkgname()} = $handle->{conflicts}; } +ensure_ldconfig($opt_v) unless $opt_n; + if ($opt_n or $opt_v) { OpenBSD::Vstat::tally(); } diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index bcef3b5c5f3..48c24d0847e 100644 --- a/usr.sbin/pkg_add/pkg_delete +++ b/usr.sbin/pkg_add/pkg_delete @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_delete,v 1.33 2004/08/06 07:51:17 espie Exp $ +# $OpenBSD: pkg_delete,v 1.34 2004/08/06 10:23:45 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -25,10 +25,19 @@ use OpenBSD::PackageInfo; use OpenBSD::RequiredBy; use OpenBSD::Logger; use OpenBSD::Vstat; +use OpenBSD::PackageInfo; our %forced = (); -use OpenBSD::PackageInfo; + +sub ensure_ldconfig +{ + my $verbose = shift; + return unless defined $OpenBSD::PackingElement::Lib::todo; + print "running ldconfig -R\n" if $verbose; + system($OpenBSD::PackingElement::Lib::ldconfig, "-R"); + undef $OpenBSD::PackingElement::Lib::todo; +} sub find_alldirrms { @@ -119,6 +128,7 @@ sub delete { my ($self, $state) = @_; my $cmd = $self->{expanded}; + main::ensure_ldconfig($state->{verbose}) unless $state->{not}; if ($state->{verbose} or $state->{not}) { print "unexec: $cmd\n"; } @@ -271,6 +281,7 @@ sub delete return unless $state->{extra}; my $cmd = $self->{expanded}; + main::ensure_ldconfig($state->{verbose}) unless $state->{not}; if ($state->{verbose} or $state->{not}) { print "unexec: $cmd\n"; } @@ -278,6 +289,15 @@ sub delete system($cmd); } +package OpenBSD::PackingElement::Lib; + +sub delete +{ + my ($self, $state) = @_; + $self->SUPER::delete($state); + $self->mark_ldconfig_directory($state->{destdir}); +} + package OpenBSD::PackingElement::FREQUIRE; use OpenBSD::PackageInfo; sub delete @@ -289,6 +309,7 @@ sub delete my $opt_n = $state->{not}; my $pkgname = $state->{pkgname}; + main::ensure_ldconfig($opt_v) unless $opt_n; print "Require script: $dir",REQUIRE," $pkgname DEINSTALL\n" if $opt_v or $opt_n; unless ($opt_n) { chmod 0755, $dir.REQUIRE; @@ -307,6 +328,7 @@ sub delete my $opt_v = $state->{verbose}; my $opt_n = $state->{not}; my $pkgname = $state->{pkgname}; + main::ensure_ldconfig($opt_v) unless $opt_n; print "Deinstall script: $dir",DEINSTALL ," $pkgname DEINSTALL\n" if $opt_v or $opt_n; unless ($opt_n) { chmod 0755, $dir.DEINSTALL; @@ -532,6 +554,7 @@ if ($opt_B eq '') { last if $opt_n; } while ($removed); } +ensure_ldconfig($opt_v) unless $opt_n; # delayed directory removal remove_dirs($state); |