From: espie Date: Fri, 3 Aug 2018 06:39:12 +0000 (+0000) Subject: reorg groff runner so that failures are handled better X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5dd47ccf1196d78337ae1a7004e86d11874380f0;p=openbsd reorg groff runner so that failures are handled better do the logic for manpage formatting better, so that we can't miss things simplify filenames, fullname always has a slash --- diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index cf2c268fe9b..0e252304646 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.265 2018/07/07 11:32:01 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.266 2018/08/03 06:39:12 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -637,7 +637,7 @@ sub format mkdir($d); } if (my ($dir, $file) = $fname =~ m/^(.*)\/([^\/]+\/[^\/]+)$/) { - $state->system(sub { + my $r = $state->system(sub { open STDOUT, '>&', $destfh or die "Can't write to $dest"; close $destfh; @@ -646,8 +646,13 @@ sub format OpenBSD::Paths->groff, qw(-mandoc -mtty-char -E -Ww -Tascii -P -c), @extra, '--', $file); + if ($r != 0) { + # system already displays an error message + return; + } } else { - die "Can't parse source name $fname"; + $state->error("Can't parse source name #1", $fname); + return; } return 1; } diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 77578edc373..3cf12e4cfa6 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.151 2018/06/26 09:42:18 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.152 2018/08/03 06:39:12 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -624,31 +624,37 @@ sub grab_manpages push(@{$state->{manpages}}, $filename); } -sub makesum_plist +sub format_source_page { my ($self, $state, $plist) = @_; + if ($state->{subst}->empty("USE_GROFF") || !$self->is_source) { - return $self->SUPER::makesum_plist($state, $plist); + return 0; } my $dest = $self->source_to_dest; my $fullname = $self->cwd."/".$dest; my $d = dirname($fullname); $state->{mandir} //= OpenBSD::Temp::permanent_dir( $ENV{TMPDIR} // '/tmp', "manpage"); - my $tempname = $state->{mandir}."/".$fullname; + my $tempname = $state->{mandir}.$fullname; require File::Path; - File::Path::make_path($state->{mandir}."/".$d); - open my $fh, ">", $tempname or $state->error("can't create #1: #2", - $tempname, $!); + File::Path::make_path($state->{mandir}.$d); + open my $fh, ">", $tempname; + if (!defined $fh) { + $state->error("can't create #1: #2", $tempname, $!); + return 0; + } chmod 0444, $fh; if (-d $state->{base}.$d) { undef $d; } - $self->format($state, $tempname, $fh) or return; + if (!$self->format($state, $tempname, $fh)) { + return 0; + } if (-z $tempname) { $state->errsay("groff produced empty result for #1", $dest); $state->errsay("\tkeeping source manpage"); - return $self->SUPER::makesum_plist($state, $plist); + return 0; } if (defined $d && !$state->{known_dirs}->{$d}) { $state->{known_dirs}->{$d} = 1; @@ -657,8 +663,18 @@ sub makesum_plist my $e = OpenBSD::PackingElement::Manpage->add($plist, $dest); $e->{wtempname} = $tempname; $e->compute_checksum($e, $state, $state->{base}); + return 1; } +sub makesum_plist +{ + my ($self, $state, $plist) = @_; + if (!$self->format_source_page($state, $plist)) { + $self->SUPER::makesum_plist($state, $plist); + } +} + + package OpenBSD::PackingElement::Depend; sub avert_duplicates_and_other_checks {