summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-10-24 17:06:06 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-10-24 17:06:06 +0000
commit93e83526f3585ad8b03ee4dfc5e46095fa9ab2c9 (patch)
tree776779dcf5329d2cb47c69ec491e19675e33fab5 /usr.sbin
parentc6888bafcd63586439ba1ffbdb4242b3f805c608 (diff)
use newer system for more efficient redirection, and chdir the way man(1)
does, so groff is happier with .so. (agreed by ingo)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm32
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm5
2 files changed, 24 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 2ff77a94e1e..2c0c0a92c83 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.185 2010/10/19 11:37:59 sthen Exp $
+# $OpenBSD: PackingElement.pm,v 1.186 2010/10/24 17:06:05 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -512,8 +512,11 @@ sub source_to_dest
# assumes the source is nroff, launches nroff
sub format
{
- my ($self, $base, $out) = @_;
- my $fname = $base."/".$self->fullname;
+ my ($self, $state, $dest) = @_;
+
+ my $base = $state->{base};
+ my $fname = $base.$self->fullname;
+ $dest = "$base$dest";
open(my $fh, '<', $fname) or die "Can't read $fname";
my $line = <$fh>;
close $fh;
@@ -528,15 +531,22 @@ sub format
}
}
}
- open my $oldout, '>&STDOUT';
- my $dir = dirname("$base/$out");
- unless (-d $dir) {
- mkdir($dir);
+ my $d = dirname($dest);
+ unless (-d $d) {
+ mkdir($d);
+ }
+ if (my ($dir, $file) = $fname =~ m/^(.*)\/([^\/]+\/[^\/]+)$/) {
+ $state->system(sub {
+ open STDOUT, '>', "$dest" or
+ die "Can't write to $dest";
+ chdir($dir) or die "Can't chdir to $dir";
+ },
+ OpenBSD::Paths->groff,
+ '-Tascii', '-mandoc', '-Wall', '-mtty-char', @extra, '--',
+ $file);
+ } else {
+ die "Can't parse source name $fname";
}
- open STDOUT, '>', "$base/$out" or die "Can't write to $base/$out";
- system(OpenBSD::Paths->groff,
- '-Tascii', '-mandoc', '-Wall', '-mtty-char', @extra, '--', $fname);
- open STDOUT, '>&', $oldout;
}
package OpenBSD::PackingElement::Mandoc;
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index 66845c58482..1283234ab44 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.23 2010/10/02 13:33:05 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.24 2010/10/24 17:06:05 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -390,7 +390,8 @@ sub makesum_plist
return $self->SUPER::makesum_plist($plist, $state);
}
my $dest = $self->source_to_dest;
- $self->format($state->{base}, $self->cwd."/".$dest);
+ my $out = $state->{base}.$self->cwd."/".$dest;
+ $self->format($state, $self->cwd."/".$dest);
my $e = OpenBSD::PackingElement::Manpage->add($plist, $dest);
$e->compute_checksum($e, $state, $state->{base});
}