summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-08-10 11:53:28 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-08-10 11:53:28 +0000
commit23eb54c9e9a3cdb77080e794df20fd407973015c (patch)
treed5870e09950adb4f8189d81a09f254a4ea8d3297 /usr.sbin
parent51d7fa141fd9b9c007246a705d784b856d570fba (diff)
cosmetic tweak: ensure all dirs always get exactly one / at the end.
cosmetic tweak: do not show a space after a keyword without args. dir support reworked: keep clones() of dir objects, and call cleanup/reload routines at end. @mandir/fontdir support: both mandir and fontdir remove extra files on delete. @fontdir creates alias files, runs mkfontdir, and uses fc-cache.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm63
-rw-r--r--usr.sbin/pkg_add/pkg_add12
-rw-r--r--usr.sbin/pkg_add/pkg_delete64
3 files changed, 117 insertions, 22 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index cf11c2d181a..7360affc6ac 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.20 2004/08/07 17:27:26 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.21 2004/08/10 11:53:27 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -67,7 +67,7 @@ sub category() { 'items' }
sub new
{
my ($class, $args) = @_;
- if ($args =~ m|/$| and defined $class->dirclass()) {
+ if ($args =~ m|/+$| and defined $class->dirclass()) {
bless { name => $` }, $class->dirclass();
} else {
bless { name => $args }, $class;
@@ -110,10 +110,12 @@ sub needs_keyword() { 1 }
sub write
{
my ($self, $fh) = @_;
+ my $s = $self->stringize();
if ($self->needs_keyword()) {
- print $fh "\@", $self->keyword(), " ", $self->stringize(), "\n";
+ $s = " $s" unless $s eq '';
+ print $fh "\@", $self->keyword(), "$s\n";
} else {
- print $fh $self->stringize(), "\n";
+ print $fh "$s\n";
}
}
@@ -121,10 +123,12 @@ sub write
sub fullstring
{
my ($self, $fh) = @_;
+ my $s = $self->stringize();
if ($self->needs_keyword()) {
- return "\@".$self->keyword()." ".$self->stringize();
+ $s = " $s" unless $s eq '';
+ return "\@".$self->keyword().$s;
} else {
- return $self->stringize();
+ return $s;
}
}
@@ -768,7 +772,8 @@ sub NoDuplicateNames() { 1 }
package OpenBSD::PackingElement::DirBase;
sub stringize($)
{
- return $_[0]->{name}."/";
+ my $self = $_[0];
+ return $self->{name}."/";
}
sub NoDuplicateNames() { 1 }
@@ -797,12 +802,56 @@ our @ISA=qw(OpenBSD::PackingElement::Dir);
__PACKAGE__->setKeyword('fontdir');
sub keyword() { "fontdir" }
sub needs_keyword { 1 }
+sub dirclass() { "OpenBSD::PackingElement::Fontdir" }
+
+our %fonts_todo = ();
+
+sub install
+{
+ my ($self, $archive, $destdir, $verbose, $not) = @_;
+ $self->SUPER::install($archive, $destdir, $verbose, $not);
+ $fonts_todo{$destdir.$self->fullname()} = 1;
+}
+
+sub reload
+{
+ my ($self, $state) = @_;
+ $fonts_todo{$state->{destdir}.$self->fullname()} = 1;
+}
+
+sub update_fontalias
+{
+ my $dirname = shift;
+ my @aliases;
+
+ for my $alias (glob "$dirname/fonts.alias-*") {
+ open my $f ,'<', $alias or next;
+ push(@aliases, <$f>);
+ close $f;
+ }
+ open my $f, '>', "$dirname/fonts.alias";
+ print $f @aliases;
+ close $f;
+}
+
+sub finish_fontdirs
+{
+ my @l = keys %fonts_todo;
+ if (@l != 0) {
+ map { update_fontalias($_) } @l;
+ print "You may wish to update your font path for ", join(' ', @l), "\n";
+ eval { system("/usr/X11R6/bin/mkfontdir", @l); };
+ eval { system("/usr/X11R6/bin/fc-cache", @l); };
+ }
+}
+
package OpenBSD::PackingElement::Mandir;
our @ISA=qw(OpenBSD::PackingElement::Dir);
__PACKAGE__->setKeyword('mandir');
sub keyword() { "mandir" }
sub needs_keyword { 1 }
+sub dirclass() { "OpenBSD::PackingElement::Mandir" }
package OpenBSD::PackingElement::Extra;
our @ISA=qw(OpenBSD::PackingElement);
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index fc3aa0e3855..590a0dcd070 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.47 2004/08/07 17:27:26 espie Exp $
+# $OpenBSD: pkg_add,v 1.48 2004/08/10 11:53:27 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -132,6 +132,15 @@ sub install
&OpenBSD::PackingElement::Dir::install;
}
+package OpenBSD::PackingElement::Mandir;
+
+sub install
+{
+ my ($self, $archive, $destdir, $verbose, $not) = @_;
+ $self->SUPER::install->($archive, $destdir, $verbose, $not);
+ print "You may wish to add ", $self->fullname(), " to /etc/man.conf\n";
+}
+
package OpenBSD::PackingElement::InfoFile;
use File::Basename;
@@ -713,6 +722,7 @@ while (my $pkg = shift @todo) {
$conflict_list->{$plist->pkgname()} = $handle->{conflicts};
}
+OpenBSD::PackingElement::Fontdir::finish_fontdirs();
ensure_ldconfig($opt_v) unless $opt_n;
if ($opt_n or $opt_v) {
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index 7ef582f91df..2df41528e9f 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.38 2004/08/09 01:40:57 espie Exp $
+# $OpenBSD: pkg_delete,v 1.39 2004/08/10 11:53:27 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -39,14 +39,14 @@ sub ensure_ldconfig
undef $OpenBSD::PackingElement::Lib::todo;
}
-sub find_alldirrms
+sub erase_alldirrms
{
my $db = {};
my @list = installed_packages();
for my $e (@list) {
my $plist = OpenBSD::PackingList->fromfile(installed_info($e).CONTENTS, \&OpenBSD::PackingList::DirrmOnly) or next;
for my $item (@{$plist->{items}}) {
- $item->record_dirrm($e, $db);
+ $item->erase_dir($e, $db);
}
}
return $db;
@@ -59,13 +59,21 @@ sub remove_dirs
my $h = $state->{dirs_to_rm};
return unless defined $h;
- my $remaining = find_alldirrms();
+ my $remaining = erase_alldirrms();
for my $d (sort {$b cmp $a} keys %$h) {
- next if defined $remaining->{$d};
my $realname = $state->{destdir}.$d;
- if (!rmdir $realname) {
- print "Error deleting directory $realname: $!\n";
+ if ($remaining->{$realname}) {
+ for my $i (@{$h->{$d}}) {
+ $i->reload($state);
+ }
+ } else {
+ for my $i (@{$h->{$d}}) {
+ $i->cleanup($state);
+ }
+ if (!rmdir $realname) {
+ print "Error deleting directory $realname: $!\n";
+ }
}
}
}
@@ -76,7 +84,15 @@ sub delete
{
}
-sub record_dirrm
+sub erase_dir
+{
+}
+
+sub cleanup
+{
+}
+
+sub reload
{
}
@@ -92,12 +108,11 @@ sub log_pkgname
package OpenBSD::PackingElement::DirBase;
-sub record_dirrm
+sub erase_dir
{
my ($self, $pkgname, $db) = @_;
my $k = $self->fullname();
- $db->{$k} = [] unless defined $db->{$k};
- push(@{$db->{$k}}, $pkgname);
+ $db->{$k} = 1;
}
sub delete
@@ -114,13 +129,13 @@ sub delete
my $h = $state->{dirs_to_rm};
$h->{$name} = [] unless defined $h->{$name};
- push(@{$h->{$name}}, $state->{pkgname});
+ push(@{$h->{$name}}, $self->clone());
}
package OpenBSD::PackingElement::DirRm;
-sub record_dirrm
+sub erase_dir
{
- &OpenBSD::PackingElement::DirBase::record_dirrm;
+ &OpenBSD::PackingElement::DirBase::erase_dir;
}
sub delete
@@ -279,6 +294,26 @@ sub delete
$self->SUPER::delete($state);
}
+package OpenBSD::PackingElement::Mandir;
+sub cleanup
+{
+ my ($self, $state) = @_;
+ my $fullname = $state->{destdir}.self->fullname();
+ print "You may wish to remove ", $fullname, " from man.conf\n";
+ unlink("$fullname/whatis.db");
+}
+
+package OpenBSD::PackingElement::Fontdir;
+sub cleanup
+{
+ my ($self, $state) = @_;
+ my $fullname = $state->{destdir}.$self->fullname();
+ print "You may wish to remove ", $fullname, " from your font path\n";
+ unlink("$fullname/fonts.alias");
+ unlink("$fullname/fonts.dir");
+ unlink("$fullname/fonts.cache-1");
+}
+
package OpenBSD::PackingElement::ExtraUnexec;
sub delete
{
@@ -567,6 +602,7 @@ if ($opt_B eq '') {
ensure_ldconfig($opt_v) unless $opt_n;
# delayed directory removal
remove_dirs($state);
+OpenBSD::PackingElement::Fontdir::finish_fontdirs();
my $logname = OpenBSD::Logger::logname();
if (defined $logname) {