summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm21
-rw-r--r--usr.sbin/pkg_add/OpenBSD/AddDelete.pm21
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm47
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Temp.pm2
4 files changed, 65 insertions, 26 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
index 72492f28504..94573d496e9 100644
--- a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: AddCreateDelete.pm,v 1.13 2010/12/24 09:04:14 espie Exp $
+# $OpenBSD: AddCreateDelete.pm,v 1.14 2011/03/07 09:26:47 espie Exp $
#
# Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org>
#
@@ -71,6 +71,25 @@ sub handle_options
$state->{not} = $state->opt('n');
}
+# those are required for makewhatis integration
+sub picky
+{
+ return shift->{picky};
+}
+
+sub testmode
+{
+ return shift->{testmode};
+}
+
+sub check_dir
+{
+ my ($self, $dir) = @_;
+ unless (-d $dir) {
+ $self->fatal("#1: #2 is not a directory", $0, $dir);
+ }
+}
+
package OpenBSD::AddCreateDelete;
use OpenBSD::Error;
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
index 18821bcdbe2..6534e78247f 100644
--- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: AddDelete.pm,v 1.45 2011/01/23 06:56:53 espie Exp $
+# $OpenBSD: AddDelete.pm,v 1.46 2011/03/07 09:26:47 espie Exp $
#
# Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org>
#
@@ -309,25 +309,6 @@ sub updateset_from_location
OpenBSD::Handle->from_location($location));
}
-# those are required for makewhatis integration
-sub picky
-{
- return shift->{picky};
-}
-
-sub testmode
-{
- return shift->{testmode};
-}
-
-sub check_dir
-{
- my ($self, $dir) = @_;
- unless (-d $dir) {
- $self->fatal("#1: #2 is not a directory", $0, $dir);
- }
-}
-
OpenBSD::Auto::cache(ldconfig,
sub {
my $self = shift;
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index afca0d8b312..3c0b762040c 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.41 2011/01/09 13:06:10 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.42 2011/03/07 09:26:47 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -108,6 +108,7 @@ sub pretend_to_archive
sub archive {}
sub comment_create_package {}
+sub grab_manpages {}
sub print_file {}
@@ -421,6 +422,18 @@ sub makesum_plist
package OpenBSD::PackingElement::Manpage;
use File::Basename;
+sub grab_manpages
+{
+ my ($self, $state) = @_;
+ my $filename;
+ if ($self->{wtempname}) {
+ $filename = $self->{wtempname};
+ } else {
+ $filename = $state->{base}.$self->fullname;
+ }
+ push(@{$state->{manpages}}, $filename);
+}
+
sub makesum_plist
{
my ($self, $plist, $state) = @_;
@@ -429,8 +442,11 @@ sub makesum_plist
}
my $dest = $self->source_to_dest;
my $d = dirname($self->cwd."/".$dest);
- my ($fh, $tempname) = OpenBSD::Temp::permanent_file(
- $ENV{TMPDIR} // '/tmp', "manpage.".basename($dest));
+ $state->{mandir} //= OpenBSD::Temp::permanent_dir(
+ $ENV{TMPDIR} // '/tmp', "manpage");
+ my $tempname = $state->{mandir}."/".basename($dest);
+ open my $fh, ">", $tempname or $state->error("can't create #1: #2",
+ $tempname, $!);
chmod 0444, $fh;
if (-d $state->{base}.$d) {
undef $d;
@@ -1052,6 +1068,29 @@ sub check_dependencies
}
}
+sub finish_manpages
+{
+ my ($self, $state, $plist) = @_;
+ $plist->grab_manpages($state);
+ if (defined $state->{manpages}) {
+ $state->{v} ++;
+
+ require OpenBSD::Makewhatis;
+
+ try {
+ OpenBSD::Makewhatis::scan_manpages($state->{manpages},
+ $state);
+ } catchall {
+ $state->errsay("Error in makewhatis: #1", $_);
+ };
+ $state->{v} --;
+ }
+
+ $plist->remove_temp;
+ if (defined $state->{mandir}) {
+ rmdir($state->{mandir});
+ }
+}
sub parse_and_run
{
@@ -1207,7 +1246,7 @@ sub parse_and_run
} else {
$self->create_package($state, $plist, $wname);
}
- $plist->remove_temp;
+ $self->finish_manpages($state, $plist);
}catch {
print STDERR "$0: $_\n";
return 1;
diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm
index 9c8137037d2..58699814234 100644
--- a/usr.sbin/pkg_add/OpenBSD/Temp.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Temp.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Temp.pm,v 1.22 2010/12/24 09:04:14 espie Exp $
+# $OpenBSD: Temp.pm,v 1.23 2011/03/07 09:26:47 espie Exp $
#
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
#