diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-01-27 11:27:19 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-01-27 11:27:19 +0000 |
commit | cc21fc6fb7bcbaae0f1732f0b2d4af4bf5ca43b8 (patch) | |
tree | 43dab2c62be53d4cf13c6b75dc15ce01b0717bd0 /libexec | |
parent | 4923bc0dd4fe9b4901b97bf153e00dae5ece53ec (diff) |
fix pkg_delete for people who had mandocdb enabled:
if we don't find a whatis.db when deleting (which could happen if
mandocdb was enabled while pkg_add was running), first create it,
then update it.
okay nigel@, schwarze@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis.pm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libexec/makewhatis/OpenBSD/Makewhatis.pm b/libexec/makewhatis/OpenBSD/Makewhatis.pm index de9467716a6..32d01d2bfd9 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Makewhatis.pm,v 1.10 2011/02/22 00:23:14 espie Exp $ +# $OpenBSD: Makewhatis.pm,v 1.11 2012/01/27 11:27:18 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -188,6 +188,22 @@ sub merge OpenBSD::Makewhatis::Whatis::write($subjects, $mandir, $p); } +# open_whatis(dir, file, $p) +# +# open existing whatis database, or recreate it in case of problem +# +sub open_whatis +{ + my ($mandir, $whatis, $p) = @_; + my $fh; + + if (!open($fh , '<', $whatis) && $!{ENOENT}) { + build_index($mandir, $p); + open($fh , '<', $whatis); + } + return $fh; +} + # remove(dir, \@pages, $p) # # remove set of pages from directory index @@ -200,7 +216,7 @@ sub remove $p //= OpenBSD::Makewhatis::Printer->new; $p->check_dir($mandir); my $whatis = "$mandir/whatis.db"; - open(my $old, '<', $whatis) or + my $old = open_whatis($mandir, $whatis, $p) or $p->fatal("#1: can't open #2 to merge with: #3", $0, $whatis, $!); my $subjects = scan_manpages($args, $p); my %remove = map {$_ => 1 } @$subjects; |