Hi Stuart,
Stuart Henderson wrote on Tue, Jun 17, 2014 at 10:41:16PM +0100:
> On 2014/06/17 11:57, Erling Westenvik wrote:
>> On Tue, Jun 17, 2014 at 12:00:41AM -0400, Eduardo Lopes wrote:
>>> On installing vim (gtk2 flavor) from snapshots I'v got the following
>>> message:
>>> /usr/local/man//mandoc.db: unable to open database file
>> I've received similar messages from various ports lately. Like right
>> now on amd64 current:
>>
>> icedtea-web-1.4.2p0: ok
>> --- +jdk-1.7.0.55p1v0 -------------------
>> You may wish to add /usr/local/jdk-1.7.0/man to /etc/man.conf
>> /usr/local/jdk-1.7.0/man//mandoc.db: unable to open database file
> This happens every time a package installs a manpage in a new path
> that doesn't already have a mandoc.db file.
>
> Needs squelching somewhere, could be in pkg_add, but I think mandocdb
> would be a better place. Ingo, what do you think about this diff?
I think the diff is very wrong.
What happens here is that pkg_add(1) runs the following command:
makewhatis -d /usr/local/man some_file
Now, about the worst kind of error that can occur when trying to
explicitly add a single entry to an existing database is that the
database - contrary to the expectation - does not even exist.
So we most definitely do *not* want to silently ignore this kind
of error in makewhatis(8) in general.
That said, pkg_add(1) add does want to ignore this particular error
in this special case. Actually, it has all the necessary information
to know that it is requesting generation of a new database; it merely
uses the -d option because that's convenient and easier to code
in pkg_add(1) and makewhatis(8) does the right thing anyway.
So the question is how to ignore the error in this case, without
ignoring other potential errors as well. I see the following options:
a) When pkg_add(1) wants a new database and no warning,
let it call makewhatis(8) without -d.
b) Add an option "pkg_add(1) mode" to makewhatis(8),
let pkg_add(1) always use that, and let makewhatis(8)
ignore this particular error in this case.
I suspect there will be a few more cases where pkg_add(1)
wants makewhatis(8) behaviour that is slightly different
from sane default behaviour in the non-pkg_add case.
I could live with both approaches; the second one seems slightly
more flexible and requires less code in pkg_add(1), at the
expense of one more option for makewhatis(8).
Which one do you prefer?
Yours,
Ingo
> Index: mandocdb.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mandoc/mandocdb.c,v
> retrieving revision 1.107
> diff -u -p -r1.107 mandocdb.c
> --- mandocdb.c 5 Jun 2014 07:13:53 -0000 1.107
> +++ mandocdb.c 17 Jun 2014 21:39:53 -0000
> @@ -2223,7 +2223,8 @@ dbopen(int real)
> rc = sqlite3_open_v2(MANDOC_DB, &db, ofl, NULL);
> if (SQLITE_OK != rc) {
> exitcode = (int)MANDOCLEVEL_SYSERR;
> - say(MANDOC_DB, "%s", sqlite3_errstr(rc));
> + if (SQLITE_CANTOPEN != rc)
> + say(MANDOC_DB, "%s", sqlite3_errstr(rc));
> return(0);
> }
> goto prepare_statements;
>