diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-20 17:04:26 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-20 17:04:26 +0000 |
commit | 4264829f2869911b43b3b8496011f103c1d837b7 (patch) | |
tree | 1096c2977f76ec1607c4d5b08158cf9e464da13d /usr.sbin | |
parent | 3d1a9ae558fb02fb38891e69eefe0a1a32e797f4 (diff) |
make the package tools more aware of manpages: handle names correctly,
and figure out how to process manpages.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 4f8443f1e1f..5de41e5272f 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.111 2007/05/18 13:22:06 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.112 2007/05/20 17:04:25 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -415,6 +415,46 @@ sub register_manpage } } +sub is_source +{ + my $self = shift; + return $self->{name} =~ m/man\/man[^\/]+\/[^\/]+\.[\dln][^\/]?$/; +} + +sub source_to_dest +{ + my $self = shift; + my $v = $self->{name}; + $v =~ s/(man\/)man([^\/]+\/[^\/]+)\.[\dln][^\/]?$/$1cat$2.0/; + return $v; +} + +# assumes the source is nroff, launches nroff +sub format +{ + my ($self, $base, $out) = @_; + my $fname = $base."/".$self->fullname; + open(my $fh, '<', $fname) or die "Can't read $fname"; + my $line = <$fh>; + close $fh; + my @extra = (); + # extra preprocessors as described in man. + if ($line =~ m/^\'\\\"\s+(.*)$/) { + for my $letter (split $1) { + if ($letter =~ m/[ept]/) { + push(@extra, "-$letter"); + } elsif ($letter eq 'r') { + push(@extra, "-R"); + } + } + } + open my $oldout, '>&STDOUT'; + open STDOUT, '>', "$base/$out" or die "Can't write to $base/$out"; + system('groff', '-Tascii', '-mandoc', '-Wall', '-mtty-char', + @extra, $fname); + open STDOUT, '>&', $oldout; +} + package OpenBSD::PackingElement::Lib; our @ISA=qw(OpenBSD::PackingElement::FileBase); |