diff options
author | 2007-05-20 17:04:25 +0000 | |
---|---|---|
committer | 2007-05-20 17:04:25 +0000 | |
commit | 42501089e31333c4233a6f5d124be13dcc512133 (patch) | |
tree | 54203771f23f09b4ab5f35f0a8308b1e46a2e18e | |
parent | add a -f option to allow specifing an alternative (diff) | |
download | wireguard-openbsd-42501089e31333c4233a6f5d124be13dcc512133.tar.xz wireguard-openbsd-42501089e31333c4233a6f5d124be13dcc512133.zip |
make the package tools more aware of manpages: handle names correctly,
and figure out how to process manpages.
-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); |