On 2014/06/18 00:17, Ingo Schwarze wrote:
> 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?
I think you have sold B to me. :) Something like this?
Index: usr.sbin/pkg_add/OpenBSD/Add.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Add.pm,v
retrieving revision 1.155
diff -u -p -r1.155 Add.pm
--- usr.sbin/pkg_add/OpenBSD/Add.pm 17 Jun 2014 13:35:06 -0000 1.155
+++ usr.sbin/pkg_add/OpenBSD/Add.pm 18 Jun 2014 00:40:14 -0000
@@ -38,7 +38,7 @@ sub manpages_index
$state->say("Merging manpages in #1: #2",
$destdir.$k, join(' ', @l)) if $state->verbose;
} else {
- $state->run_makewhatis(['-d', $destdir.$k], \@l);
+ $state->run_makewhatis(['-P', '-d', $destdir.$k], \@l);
}
}
delete $state->{addman};
Index: usr.sbin/pkg_add/OpenBSD/Delete.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Delete.pm,v
retrieving revision 1.137
diff -u -p -r1.137 Delete.pm
--- usr.sbin/pkg_add/OpenBSD/Delete.pm 20 May 2014 05:55:43 -0000 1.137
+++ usr.sbin/pkg_add/OpenBSD/Delete.pm 18 Jun 2014 00:40:14 -0000
@@ -51,7 +51,7 @@ sub manpages_unindex
$state->say("Removing manpages in #1: #2",
$destdir.$k, join(' ', @l)) if $state->verbose;
} else {
- $state->run_makewhatis(['-u', $destdir.$k], \@l);
+ $state->run_makewhatis(['-P', '-u', $destdir.$k], \@l);
}
}
delete $state->{rmman};
Index: usr.bin/mandoc/makewhatis.8
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/makewhatis.8,v
retrieving revision 1.10
diff -u -p -r1.10 makewhatis.8
--- usr.bin/mandoc/makewhatis.8 25 Apr 2014 12:12:35 -0000 1.10
+++ usr.bin/mandoc/makewhatis.8 18 Jun 2014 00:40:14 -0000
@@ -23,20 +23,20 @@
.Nd index UNIX manuals
.Sh SYNOPSIS
.Nm
-.Op Fl aDnpQ
+.Op Fl aDnPpQ
.Op Fl T Cm utf8
.Op Fl C Ar file
.Nm
-.Op Fl aDnpQ
+.Op Fl aDnPpQ
.Op Fl T Cm utf8
.Ar dir ...
.Nm
-.Op Fl DnpQ
+.Op Fl DnPpQ
.Op Fl T Cm utf8
.Fl d Ar dir
.Op Ar
.Nm
-.Op Fl Dnp
+.Op Fl DnPp
.Op Fl T Cm utf8
.Fl u Ar dir
.Op Ar
@@ -105,6 +105,11 @@ to the database in
.It Fl n
Do not create or modify any database; scan and parse only,
and print manual page names and descriptions to standard output.
+.It Fl P
+Enable options suitable for use when called by pkg_add.
+Currently this just hides warnings about non-existent
+.Pa mandoc.db
+files.
.It Fl p
Print warnings about potential problems with manual pages
to the standard error output.
Index: usr.bin/mandoc/mandocdb.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandocdb.c,v
retrieving revision 1.107
diff -u -p -r1.107 mandocdb.c
--- usr.bin/mandoc/mandocdb.c 5 Jun 2014 07:13:53 -0000 1.107
+++ usr.bin/mandoc/mandocdb.c 18 Jun 2014 00:40:14 -0000
@@ -175,6 +175,7 @@ static int mparse_options; /* abort th
static int use_all; /* use all found files */
static int debug; /* print what we're doing */
static int warnings; /* warn about crap */
+static int pkgadd; /* behaviour suitable for pkg_add */
static int write_utf8; /* write UTF-8 output; else ASCII */
static int exitcode; /* to be returned by main */
static enum op op; /* operational mode */
@@ -354,7 +355,7 @@ mandocdb(int argc, char *argv[])
path_arg = NULL;
op = OP_DEFAULT;
- while (-1 != (ch = getopt(argc, argv, "aC:Dd:npQT:tu:v")))
+ while (-1 != (ch = getopt(argc, argv, "aC:Dd:nPpQT:tu:v")))
switch (ch) {
case 'a':
use_all = 1;
@@ -375,6 +376,9 @@ mandocdb(int argc, char *argv[])
case 'n':
nodb = 1;
break;
+ case 'P':
+ pkgadd = 1;
+ break;
case 'p':
warnings = 1;
break;
@@ -526,10 +530,10 @@ out:
ohash_delete(&mlinks);
return(exitcode);
usage:
- fprintf(stderr, "usage: %s [-aDnpQ] [-C file] [-Tutf8]\n"
- " %s [-aDnpQ] [-Tutf8] dir ...\n"
- " %s [-DnpQ] [-Tutf8] -d dir [file ...]\n"
- " %s [-Dnp] -u dir [file ...]\n"
+ fprintf(stderr, "usage: %s [-aDnPpQ] [-C file] [-Tutf8]\n"
+ " %s [-aDnPpQ] [-Tutf8] dir ...\n"
+ " %s [-DnPpQ] [-Tutf8] -d dir [file ...]\n"
+ " %s [-DnPp] -u dir [file ...]\n"
" %s [-Q] -t file ...\n",
progname, progname, progname,
progname, progname);
@@ -2223,7 +2227,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 (!pkgadd || SQLITE_CANTOPEN != rc)
+ say(MANDOC_DB, "%s", sqlite3_errstr(rc));
return(0);
}
goto prepare_statements;