New option -append: teach makewhatis to only add records, instead

of clobbering the entire database.

sort options in alphabetic order.

install manpage makewhatis.local.8
This commit is contained in:
wosch 1996-05-22 00:57:42 +00:00
parent 57113eed94
commit f7107b8cab
7 changed files with 195 additions and 49 deletions

View File

@ -1,5 +1,6 @@
MAN1= makewhatis.1
# MAN8= makewhatis.local.8
MAN8= makewhatis.local.8
MLINKS= makewhatis.local.8 catman.local.8
libexecdir=/usr/libexec
LINKS=${libexecdir}/makewhatis.local ${libexecdir}/catman.local

View File

@ -1,5 +1,5 @@
.\"
.\" (c) Copyright 1995 Wolfram Schneider. All rights reserved.
.\" (c) Copyright 1995 Wolfram Schneider, Berlin. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -26,12 +26,11 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" /usr/bin/makewhatis - create whatis database
.\" makewhatis -- update the whatis database in the man directories.
.\"
.\" Email: Wolfram Schneider <wosch@cs.tu-berlin.de>
.\"
.\" $Id: makewhatis.1,v 1.2 1995/03/31 04:00:51 joerg Exp $
.\"
.\" $Id: makewhatis.1,v 1.3 1996/04/08 04:17:48 mpp Exp $
.Dd Jan, 12, 1995
.Dt MAKEWHATIS 1
@ -41,26 +40,27 @@
.Nd create whatis database
.Sh SYNOPSIS
.Nm makewhatis
.Nm
.Op Fl a | Fl append
.Op Fl h | Fl help
.Op Fl i | Fl indent Ar column
.Op Fl n | Fl name Ar name
.Op Fl o | Fl outfile Ar file
.Op Fl v | Fl verbose
.Op Fl h | Fl help
.Op Ar directories ...
.Sh DESCRIPTION
.Nm Makewhatis
.Nm
extracts the name and a short description from unformatted manpages
and creates the
.Xr whatis 1
database.
.Nm Makewhatis
.Nm
can read gzip'ed manpages.
.Ar Directory
names a directory containing manpage subdirectories
.Pq named Pa man[0-8] .
.Pq named Pa man.+ .
Colons are treated as spaces, hence
.Ic makewhatis $MANPATH
or
@ -69,8 +69,31 @@ are allowed.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl a , Fl append
Append mode. Don't delete old entries in whatis database. Note:
the new database will be sorted without repeated lines and
.Nm
does not check if old entries are valid.
.It Fl h , Fl help
Print options and exit.
.It Fl i , Fl indent Ar column
Justify description strings to
.Ar column Pq default 24 .
.It Fl n , Fl name Ar name
Use
.Ar name
instead of
.Pa whatis Ns .
.It Fl o , Fl outfile Ar file
Write all output to
.Ar file
instead of
.Pa dirname/whatis Ns .
.It Fl v, Fl verbose
Issue more warnings
.Pq to stderr .
@ -81,22 +104,8 @@ for an uncompressed page,
for a compressed page, and
.Ql +
for a link.
.El
.It Fl i , Fl indent Ar column
Justify description strings to
.Ar column Pq default 24 .
.It Fl o , Fl outfile Ar file
Write all output to
.Ar file
instead of
.Pa dirname/whatis Ns .
.It Fl n , Fl name Ar name
Use
.Ar name
instead of
.Pa whatis Ns .
.Sh EXAMPLES
.Pp
@ -132,16 +141,19 @@ May be useful for Solaris.
whatis database
.It Pa /etc/weekly
run
.Nm
.Nm makewhatis.local
every week
.El
.Sh SEE ALSO
.Xr man 1 ,
.Xr whatis 1 ,
.Xr apropos 1 ,
.Xr catman 1 ,
.Xr sort 1 ,
.Xr makewhatis.local 1 ,
.Xr man 1 ,
.Xr manpath 1 ,
.Xr catman 1 .
.Xr uniq 1 ,
.Xr whatis 1 .
.Sh HISTORY
This
@ -149,6 +161,5 @@ This
command appeared in FreeBSD 2.1.
.Sh AUTHOR
Wolfram Schneider
.Aq wosch@cs.tu-berlin.de ,
Germany
Wolfram Schneider, Berlin.

View File

@ -0,0 +1,55 @@
.\" (c) Wolfram Schneider, Berlin. April 1996. Public Domain.
.\"
.\" $Id: makewhatis.local.8,v 1.1 1996/05/14 10:27:26 wosch Exp $
.Dd April, 26, 1996
.Dt MAKEWHATIS.LOCAL 8
.Os FreeBSD 2.2
.Sh NAME
.Nm makewhatis.local , catman.local
.Nd start makewhatis for local file systems
.Sh SYNOPSIS
.Nm /usr/libexec/makewhatis.local
.Op options
.Ar directories ...
.Nm /usr/libexec/catman.local
.Op options
.Ar directories ...
.Sh DESCRIPTION
.Nm
start
.Xr makewhatis 1
only for file systems physically mounted on the system
where the
.Nm
is being executed. Running makewhatis
from
.Pa /etc/weekly
for rw nfs-mounted /usr may kill
your NFS server -- all NFS clients start makewhatis at the same time!
So use this wrapper for
.Xr cron 8
instead calling makewhatis directly.
.Sh FILES
.Bl -tag -width /etc/weekly.XXX -compact
.It Pa /etc/weekly
run
.Nm
every week
.El
.Sh SEE ALSO
.Xr makewhatis 1 ,
.Xr catman 1 ,
.Xr find 1 ,
.Xr cron 8 .
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.

View File

@ -10,7 +10,7 @@
#
# PS: this wrapper works also for catman(1)
#
# $Id: makewhatis.local.sh,v 1.2 1996/04/27 12:17:01 wosch Exp $
# $Id: makewhatis.local.sh,v 1.1 1996/05/14 10:27:27 wosch Exp $
PATH=/bin:/usr/bin:$PATH; export PATH
opt= dirs= localdirs=

View File

@ -29,20 +29,18 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# makewhatis -- update the whatis database in the man directories.
#
# E-Mail: Wolfram Schneider <wosch@cs.tu-berlin.de>
#
# $Id: makewhatis.perl,v 1.8 1996/05/12 21:02:04 wosch Exp $
#
# $Id: makewhatis.perl,v 1.9 1996/05/14 14:38:12 wosch Exp $
sub usage {
warn <<EOF;
usage: makewhatis [-v|-verbose] [-h|-help] [-i|-indent colum]
[-n|-name name] [-o|-outfile file] [directories ...]
usage: makewhatis [-a|-append ] [-h|-help] [-i|-indent colum]
[-n|-name name] [-o|-outfile file] [-v|-verbose]
[directories ...]
EOF
exit 1;
}
@ -61,14 +59,38 @@ sub open_output {
}
$tmp = $whatisdb; # for signals
if (!open(A, "> $whatisdb")) {
die "$whatisdb: $!\n" if $outfile;
warn "$whatisdb: $!\n"; $err++; return 0;
}
# Array of all entries
@a = ();
# Append mode
if ($append) {
local($file) = $whatisdb;
$file =~ s/\.tmp$// if !$outfile;
if (open(A, "$file")) {
warn "Open $file for append mode\n" if $verbose;
while(<A>) {
push(@a, $_);
}
close A;
}
else {
warn "$whatisdb: $!\n" if lstat($file) && $verbose; #
}
undef $file;
}
warn "Open $whatisdb\n" if $verbose;
if (!open(A, "> $whatisdb")) {
die "$whatisdb: $!\n" if $outfile;
warn "$whatisdb: $!\n"; $err++; return 0;
}
select A;
return 1;
}
@ -83,21 +105,21 @@ sub close_output {
if ($success) { # success
# uniq
@b = ();
warn "\n" if $verbose && $pointflag;
warn "sort -u > $whatisdb\n" if $verbose;
foreach $i (sort @a) {
if ($i ne $last) {
push(@b, $i);
$counter++;
}
$last =$i;
}
$counter = $#b + 1;
print @b; close A; select STDOUT;
if (!$outfile) {
rename($whatisdb, $w);
warn "Rename $whatisdb to $w\n" if $verbose;
rename($whatisdb, $w) || warn "rename $whatisdb $w\n";
$counter_all += $counter;
warn "$counter entries in $w\n" if $verbose;
} else {
@ -411,6 +433,7 @@ sub variables {
$indent = 24; # indent for description
$outfile = 0; # Don't write to ./whatis
$whatis_name = "whatis"; # Default name for DB
$append = 0; # Don't delete old entries
# if no argument for directories given
@defaultmanpath = ( '/usr/share/man' );
@ -453,6 +476,7 @@ sub parse {
elsif (/^--?(o|outfile)$/) { $outfile = $argv[0]; shift @argv }
elsif (/^--?(f|format|i|indent)$/) { $i = $argv[0]; shift @argv }
elsif (/^--?(n|name)$/) { $whatis_name = $argv[0];shift @argv }
elsif (/^--?(a|append)$/) { $append = 1 }
else { &usage }
}

View File

@ -0,0 +1,55 @@
.\" (c) Wolfram Schneider, Berlin. April 1996. Public Domain.
.\"
.\" $Id: makewhatis.local.8,v 1.1 1996/05/14 10:27:26 wosch Exp $
.Dd April, 26, 1996
.Dt MAKEWHATIS.LOCAL 8
.Os FreeBSD 2.2
.Sh NAME
.Nm makewhatis.local , catman.local
.Nd start makewhatis for local file systems
.Sh SYNOPSIS
.Nm /usr/libexec/makewhatis.local
.Op options
.Ar directories ...
.Nm /usr/libexec/catman.local
.Op options
.Ar directories ...
.Sh DESCRIPTION
.Nm
start
.Xr makewhatis 1
only for file systems physically mounted on the system
where the
.Nm
is being executed. Running makewhatis
from
.Pa /etc/weekly
for rw nfs-mounted /usr may kill
your NFS server -- all NFS clients start makewhatis at the same time!
So use this wrapper for
.Xr cron 8
instead calling makewhatis directly.
.Sh FILES
.Bl -tag -width /etc/weekly.XXX -compact
.It Pa /etc/weekly
run
.Nm
every week
.El
.Sh SEE ALSO
.Xr makewhatis 1 ,
.Xr catman 1 ,
.Xr find 1 ,
.Xr cron 8 .
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.

View File

@ -10,7 +10,7 @@
#
# PS: this wrapper works also for catman(1)
#
# $Id: makewhatis.local.sh,v 1.2 1996/04/27 12:17:01 wosch Exp $
# $Id: makewhatis.local.sh,v 1.1 1996/05/14 10:27:27 wosch Exp $
PATH=/bin:/usr/bin:$PATH; export PATH
opt= dirs= localdirs=