home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
scohelp
/
root.1
/
usr
/
man
/
bin
/
config_man
/
config_man~
Wrap
Text File
|
1998-08-19
|
26KB
|
881 lines
#! /bin/sh -h
#
# @(#) SCCS ID: 15.5
#
# TechPubs SCCS ID:
# @(#) Filetype: AS
# @(#) SCCS ID: 100.30
# @(#) File: config_man
# @(#) Last delta: 97/12/01 14:00:39
# @(#) Last get: 97/12/01 14:00:41
# @(#) SCCS file: /f/doctools/bin/s.config_man
# @(#) Book: odssi
#
# Copyright (C) 1986-1997 The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# This Module contains Proprietary Information of
# The Santa Cruz Operation, Inc. and should be
# treated as Confidential.
#
# config_man - incorporates manpage documentation into the SCO help system
#
# usage: config_man [-L lang] [-d mandir] [-n] [mansection] ...
#
# Examines the documentation distribution files in one or more manpage
# section directories, and constructs the necessary files (indexes, whatis
# database, etc.) that hook the documentation into the rest of the help
# system. This should be run whenever new documentation packages are
# installed.
#
# A separate tool (config_help) performs a similar function for guide
# documentation.
#
# Copyright (C) 1996-1997 The Santa Cruz Operation, Inc.
#
##########################################################################
#
####### CONFIGURATION SECTION
#
# The directory containing the various support files and tools used by
# this script. These are not guarenteed to be in our PATH, so we have
# to access them all via this path. The code below constructs the path
# from our pathname and the current directory.
ODSSI_TOOL_PATH=`dirname $0`
if [ `expr "/$ODSSI_TOOL_PATH" : //` -eq 0 ]
then ODSSI_TOOL_PATH="`pwd`/$ODSSI_TOOL_PATH"
fi
#
# The location of the ODSSI configuration data, which depends upon the
# TOOL_PATH.
ODSSI_CONFIG=$ODSSI_TOOL_PATH/odssi.config
#
# Place any configuration parameters that are particular to this specific
# tool below. Configuration parameters specific to all ODSSI tools are
# in the ODSSI_CONFIG file, specified above.
#
# location of nroff
PATH=$PATH:/usr/ucb
export PATH
#
# Message catalog set number for this tool
MsgSet=2
#
####### END OF CONFIGURATION SECTION
#
# Get our name for use in error messages.
ME="`basename $0`"
USAGE="[-L lang] [-n] [-d mandir] [mansection] ..."
#
# Set up temporary files and arrange for them to get deleted.
TMP="/var/tmp/cm$$"
Errs=1
trap "rm -rf ${TMP}*; exit 1" 1 2 3 15
trap "rm -rf ${TMP}*; exit \$Errs" 0
if [ -z "$USER_LANG" ]
then USER_LANG="$LANG"
if [ -z "$USER_LANG" ]
then USER_LANG="C"
fi
export USER_LANG
fi
#
#### FUNCTIONS
#
# This outputs the usage line.
Usage ()
{
echo >&2 "usage: $ME $USAGE"
exit 1
}
#
# This outputs an error message. It does not exit the script. The arguments
# are a message catalog number, the text of the message, and any arguments
# referenced from within the message using printf-style formatting constructs.
# It writes the message to the standard error.
Error()
{
# Restore the user's LANG for error messages
DOCLANG=$LANG
LANG=$USER_LANG
# This version uses message catalog defined in odssi.config
MsgNum="$1"
shift
echo >&2 "${ME}: ${DOCLANG}: \c"
dspmsg >&2 "$MSG_CATALOG_NAME" -s $MsgSet $MsgNum "$@"
echo >&2
LANG=$DOCLANG
}
#
# Function to generate our awk script. This writes the script that produces
# index and whatis files to its standard output. There are no arguments, and
# no meaningful return value.
GenerateScript()
{
# Start with the common and node functions.
cat $AWK_COMMON_FUNCS $AWK_NODE_FUNCS
#
# Now add in the code that creates the index and whatis files.
cat <<'__END_OF_SCRIPT__'
function WhatisSpace(s,n, l,o)
{ # Makes a string of whitespace to pad s to n tab stops
l = length(s);
if (l > n * 8)
return(" "); # Use a single space when s is longer than n.
o = "\t"; # We always have at least one tab.
# Add more tabs as necessary to pad it out.
for (l = n - int(l / 8) - 1; l > 0; l--)
o = o "\t";
return(o);
}
function GetDescList(l)
{ # Function to get the list portion of a description line.
# Return the part of the line before the hyphen separator.
sub(/ - .*/, "", l);
# If there happens to be a section name here, remove that too.
sub(/[[:blank:]]*\([^[:blank:]][^[:blank:]]*\)[:blank:]*$/, "", l);
return(l);
}
function GetDescText(l)
{ # Function to get the text portion of a description line.
# Return the part of the line after the hyphen separator.
sub(/.* - /, "", l);
return(l);
}
function IndexFromDescription(d,f,s, a,i,n)
{ # Output index lines for each name in a description line.
d = GetDescList(d);
if (d == "")
return; # No data to output.
n = split(d, a, /[:,][[:blank:]][[:blank:]]*/);
for (i = 1; i <= n; i++)
{ # Write a line for each name in the list.
printf("%s %s %s\n", a[i], f, s) | IndexPipe;
}
}
function WhatisFromDescription(d,s, l)
{ # Output whatis line given description line and section.
if (d == "")
return;
l = GetDescList(d) " (" s ")";
d = GetDescText(d);
printf("%s%s- %s\n", l, WhatisSpace(l, 3), d) | WhatisPipe;
}
END { # Process collected nodes.
# Construct the commands that append the sorted and uniqued index
# and whatis data to our temporary files.
IndexPipe = "sort -u >> " INDEX
WhatisPipe = "sort -u >> " WHATIS
# Loop through all the nodes.
for (n = 1; n <= NumNodes; n++)
{ # For each possible node.
if (! (n in NodeSet))
continue; # This node has been deleted.
# Get the filename, without any directory path.
FileName = NodeSet[n]; # The filename is the node name.
# Get the title and extract the section name from it.
Title = Section = GetValue(n, K_TITLE);
sub(/^.*\(/, "", Section);
sub(/\).*$/, "", Section);
sub(/\(.*$/, "", Title);
# If we could not get a section number, use the one
# from the filename.
if (Section == "")
{ # Extract the section number from the filename.
Section = FileName;
sub(/.*\./, "", Section);
}
# Now strip the section number off the filename.
sub(/\.[^\.]*$/, "", FileName);
# Create the main index entry from the TITLE line.
if (Title != "")
printf("%s %s %s\n", Title,
FileName, Section) | IndexPipe;
# Make index and whatis entries from the Name line.
Value = GetValue(n, K_NAME);
IndexFromDescription(Value, FileName, Section);
WhatisFromDescription(Value, Section);
# Make index and whatis entries from any SubName lines.
for (i = GetKeyIndex(n, K_SUBNAME); i > 0; \
i = GetNextKeyIndex(n, K_SUBNAME, i))
{ # For each SubName line.
Value = GetValueAtIndex(n, i);
IndexFromDescription(Value, FileName, Section);
WhatisFromDescription(Value, Section);
}
# Make just index entries from any IndexEntry Lines.
for (i = GetKeyIndex(n, K_IENTRY); i > 0; \
i = GetNextKeyIndex(n, K_IENTRY, i))
IndexFromDescription(GetValueAtIndex(n, i),
FileName, Section);
}
}
__END_OF_SCRIPT__
}
#
# Function to generate a list of all the section names that exist within
# the current language. The current directory is assumed to be that of the
# current language, and all directories within it are manpage data directories
# containing manpages in some source format. We collect the directory names,
# remove the source format prefixes, sort and unique them. There are no
# arguments, the list of manpage names is written to the standard output.
GetAllSectionNames()
{
# Construct an awk script that removes the source format prefix from each
# directory name on its standard input, outputting the section names.
cat $AWK_COMMON_FUNCS >$TMP-scr
cat <<'__END_OF_SCRIPT__' >>$TMP-scr
BEGIN { n = split(DIRS, a, /[[:blank:]]+/);
for (i = 1; i <= n; i++)
a[i] = Quote(a[i]);
}
{ for (i = 1; i <= n; i++)
{ # For each directory prefix.
if (match($0, ("^" a[i])))
{
print substr($0, RSTART + RLENGTH);
break
}
}
}
__END_OF_SCRIPT__
#
# Now use the above script to get the section names. We use ls to list the
# names within just the current directory, which ignores any hidden
# directories (such as MAN_DATA_DIR), then pass only those entries that
# are directories to our awk script.
ls -1 | while read n; do if [ -d "$n" ]; then echo "$n"; fi; done | \
awk -v "DIRS=$MAN_SECT_PREFIXES" -f $TMP-scr | \
sort -u
rm -f $TMP-scr
}
#
# Function to remove any data in the MAN_DATA_DIR for sections which no
# longer exist. This prevents this old data from being included in any
# new databases we create. The arguments are the names of all the manpage
# sections. There is no output and no return value.
RemoveOldSectionData()
{
# If there is no section data, then there is nothing for us to do.
if [ ! -d "$MAN_DATA_DIR" ]
then return
fi
#
# Write the command line arguments to a file, then pipe the names of all
# the existing section data files into an awk script. The awk script first
# reads the file of existing section names, then reads its input. For each
# input line, it strips the directory path and any suffixes, then sees if
# what remains is one of the existing section names. If not, it outputs
# the original line. The output of the awk script goes into xargs and rm
# to remove all the files that awk lists.
#
# Write the command line arguments to a file.
for section
do echo "$section"
done | sort -u >$TMP-sect
#
# Pipe a list of all existing section data file names into our awk script.
find "$MAN_DATA_DIR" -type f -print | \
awk -v "SECT=$TMP-sect" -v "RMSECT=$TMP-rmsect" '
BEGIN { while ((getline s < SECT) > 0)
Sections[s] = 1;
close(SECT);
}
{ # For each section data file.
f = $0;
sub(/^.*\//, "", f); # Strip directory path.
sub(/\.[^\.]*$/, "", f); # Strip any suffix.
if (! (f in Sections))
print; # File for unknown section.
print > RMSECT # Save for vbi removal
}' | \
xargs rm -f 2>/dev/null
# Now also remove any .vbi leftovers
if [ -s $TMP-rmsect ]
then
cat $TMP-rmsect |\
while read sect
do
# copy vbi file to the deletion area
if [ -f "$VerityDir/$INDEXED_DIR/man.${sect}.vbi" ]
then
cp $VerityDir/$INDEXED_DIR/man.${sect}.vbi $VerityDir/$DELETE_DIR
fi
done
fi
rm -f $TMP-rmsect
}
#
# Function to generate the index and whatis files from the .titles file
# for a section. The arguments are the section name and the path of the
# awk script that creates the files. It writes files named index.$1 and
# whatis.$1 to the current directory
MakeIndexAndWhatis()
{
# Run the script that produces the index and whatis files.
awk -v "SECTION=$1" -v "INDEX=$TMP-i$1" \
-v "WHATIS=$TMP-w$1" -v "ME=$ME" -f $2 \
$MAN_DATA_DIR/$MAN_TITLES_DIR/$1
#
# If we generated index or whatis data, replace the files.
Index="$MAN_DATA_DIR/$MAN_INDEX_DIR/$1"
Whatis="$MAN_DATA_DIR/$MAN_WHATIS_DIR/$1"
rm -f $Index $Whatis
#
# Make sure the directories we put the index and whatis data in exist.
if [ ! -d "$MAN_DATA_DIR/$MAN_INDEX_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_INDEX_DIR"
then : # We made it.
else Error 1 "Could not create title data directory for section %s" "$1"
return 1
fi
fi
if [ ! -d "$MAN_DATA_DIR/$MAN_WHATIS_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_WHATIS_DIR"
then : # We made it.
else Error 2 "Could not create whatis data directory for section %s" "$1"
return 1
fi
fi
#
# Now put the new data in place.
if [ -f $TMP-i$1 ]
then sort -u $TMP-i$1 > $Index
fi
if [ -f $TMP-w$1 ]
then sort -u $TMP-w$1 > $Whatis
fi
rm -f $TMP-i$1 $TMP-w$1
}
#
# Function to convert the whatis database for the current language to
# contain language-fallback data. Entries that are in the whatis database
# for the FALLBACK_LANG which are not in the whatis database for the current
# language are added to the current language, and this replaces the whatis
# database for the current language. There are no arguments. It returns
# zero if successful, non-zero if it fails.
WhatisLanguageFallback()
{
# If this is the fallback language or there is no directory for the
# fallback language, do nothing.
if [ "$LANG" = "$FALLBACK_LANG" -o ! -d "$BASE_PATH/$FALLBACK_LANG" ]
then return 0
fi
#
# If the fallback language does not have a whatis database, complain.
FALLBACK_WHATIS="$BASE_PATH/$FALLBACK_LANG/$MAN_DIR/whatis"
if [ ! -f "$FALLBACK_WHATIS" ]
then Error 3 "no whatis database for fallback language: %s" "$FALLBACK_LANG"
return 1
fi
#
# Get lists of the "name list" part of the whatis file for this language and
# for the fallback language.
sed 's/[[:blank:]]*- .*//' < whatis | sort -u >$TMP-w1
sed 's/[[:blank:]]*- .*//' < $FALLBACK_WHATIS | sort -u >$TMP-w2
#
# Get a list of the names in the fallback language that are not in the
# current language, and use this with the whatis file from the fallback
# language to select the missing records.
comm -13 $TMP-w1 $TMP-w2 | awk -v "WHATIS=$FALLBACK_WHATIS" '
{ # Record names not in current language.
Names[$0] = 1;
}
END { # Read the whatis file.
# Output those lines whose names are in our array.
while ((getline < WHATIS) > 0)
{ # For each line in the whatis database.
# Get the name list without the description.
Name = $0;
sub(/[[:blank:]]*- .*/, "", Name);
# If this name is not in the Name[] array, output it.
if (! ($0 in Names))
print;
}
close(WHATIS)
}
' >$TMP-w3
rm -f $TMP-w1 $TMP-w2
#
# If we found some whatis data from the fallback language that was not in
# the current language, combine this with the whatis data from the current
# language and replace the whatis file for the current language.
if [ -s $TMP-w3 ]
then sort -u whatis $TMP-w3 >$TMP-w4
if [ -s $TMP-w4 ]
then if cp $TMP-w4 whatis
then : # It worked.
else Error 4 "Could not combine whatis database with language fallback data"
fi
fi
fi
rm -f $TMP-w3 $TMP-w4
}
#
# Function to generate the awk script that creates the Verity Bulk Insert
# file from the .titles database. It writes the script to the standard
# output.
GenerateVBIScript()
{
# Construct our awk script. Start with the node functions.
cat $AWK_COMMON_FUNCS $AWK_NODE_FUNCS
#
# Now add in the code to output the data in .vbi format.
# title, and so on.
cat <<'__END_OF_SCRIPT__'
END { # Process collected nodes.
# Write the node data in .vbi format.
for (i = 1; i <= NumNodes; i++)
{ # For each node we found.
if (! (i in NodeSet))
continue;
n = NodeSet[i];
f = GetValue(i, K_SPATH);
if (f == "")
f = n;
printf("VDKVGWKEY: %s/%s/%s\n", DOCROOT, MAN, f)
t = GetValue(i, K_TITLE);
v = GetValue(i, K_VERSION);
p = GetValue(i, K_PRINTSEQ);
if (t != "")
print "TITLE: " t;
if (v != "")
print "VERSION: " v;
if (p != "")
print "PRINTSEQ: " p;
print "<<EOD>>";
}
}
__END_OF_SCRIPT__
}
#
# Function to generate the Verity Bulk Insert file from the .titles database.
# The bulk insert file is used by the Verity search engine to decide what
# to include in its indexing process. The command line argument is the
# section name. It writes a file named SECTION to the MAN_VERITY_DIR
# directory under the MAN_DATA_DIR under the current directory, which is
# assumed to be the man directory for the current language.
MakeVerityBulkInsertFile()
{
# Make sure the title database exists.
if [ ! -f "$MAN_DATA_DIR/$MAN_TITLES_DIR/$1" ]
then Error 5 "No title file for section: %s, cannot make VBI." "$1"
return 1
fi
#
# Name of man section vbi file
MANVBI=man.$1.vbi
#
# Execute the script on the titles file to build the .vbi file
awk -f $VBIScript -v "DOCROOT=$BASE_PATH/$Lang" -v "SECTION=$1" \
-v "MAN=$MAN_DIR" $MAN_DATA_DIR/$MAN_TITLES_DIR/$1 > $MANVBI
Ret=$?
#
# Move the vbi files as needed for merging
if [ $Ret = 0 ]
then
# copy old one to delete area
if [ -f $VerityDir/$INDEXED_DIR/$MANVBI ]
then
cp $VerityDir/$INDEXED_DIR/$MANVBI $VerityDir/$DELETE_DIR
fi
# Now put new one in insert area
mv $MANVBI $VerityDir/$INSERT_DIR
fi
return $Ret
}
#
# Function to run mkvdk on Verity bulk insert and delete
# files. It operates on whatever it finds in the appropriate
# directories, but only if the -n option was not specified to
# defer Verity indexing.
CombineGlobalIndex()
{
# Do this only if -n option does not defer it
if [ "$Nopt" = 1 ]
then
return 1
else
if [ -n "$Lopt" ]
then
$CONFIG_SEARCH -L "$Lopt"
else
$CONFIG_SEARCH
fi
fi
#
return 0
}
#
# Function to generate the REFhome.view file in the TopicViews directory.
# This locates all the CONTENTS.html files under the current directory,
# which should be the "man" directory for the current LANG, and creates
# a view file referring to each such contents file. There are no arguments.
# it returns zero if successful, one if not.
# Note that this works from the CONTENTS.html files and not the files in
# the MAN_TOC_DIR in order to pick up any "fixed" TOCs.
MakeRefHome()
{
# Generate the awk script that creates the .view file.
Script=$TMP-scr
cat $AWK_COMMON_FUNCS $AWK_NODE_FUNCS $AWK_GETTAG_FUNCS >$Script
cat <<'__END_OF_SCRIPT__' >>$Script
END { # Each node is the name of a CONTENTS.html file.
REFView = "RefHome";
for (n = 1; n <= NumNodes; n++)
{ # For each node we found.
if (! (n in NodeSet))
continue;
# Get information about this node.
File = NodeSet[n];
Title = GetSGMLTag(File, "TITLE");
Section = File;
sub(/\/[^\/]*$/, "", Section);
sub(/.*\./, "", Section);
if (Title == "")
Title = Section; # Use section as title.
URL = "/" MAN "/" File;
if (match(Section, /^[[:alpha:]][[:digit:]]/) &&
(length(Section) < 3 ||
match(Section, /^..[[:alpha:]]/)))
Class = substr(Section, 1, 2);
else if (match(Section, /^1M/))
Class = substr(Section, 1, 2);
else Class = substr(Section, 1, 1);
Class = "mansect" Class;
# Is there an html intro for this section?
Intro = ""
CMD = sprintf("/bin/ls -1 html.%s/[Ii]ntro*.html 2> /dev/null", Section)
CMD | getline Intro
close(CMD);
# Set the fields for this node.
if ( Intro ) {
Intro = "/" MAN "/" Intro
SetKeyValue(n, K_OVERVIEW, Intro);
}
SetKeyValue(n, K_TITLE, Title);
SetKeyValue(n, K_URL, URL);
SetKeyValue(n, K_PARENT, REFView);
SetKeyValue(n, K_CLASS, Class);
}
# Create the node for the REFhome view.
n = AddNode(REFView);
SetKeyValue(n, K_TITLE, HOME_TITLE);
SetKeyValue(n, K_URL, HOME_URL);
SetKeyValue(n, K_PARENT, HOME_PARENT);
SetKeyValue(n, K_VERSION, HOME_VERSION);
SetKeyValue(n, K_CLASS, HOME_CLASS);
SetKeyValue(n, K_OVERVIEW, HOME_OVERVIEW);
# Finally, dump everything out.
OutputNodes();
}
__END_OF_SCRIPT__
#
# Make sure the directory we want to write into exists, we can write it,
# and the file we want to write can be overwritten if it exists.
HomeDir=`dirname $MAN_HOME_VIEW`
if [ ! -d "$HomeDir" ]
then if mkdir -p -m 0755 "$HomeDir"
then : # We made it.
else Error 7 "Could not create view directory: %s" "$HomeDir"
return 1
fi
fi
if [ ! -w "$HomeDir" -o \( -f "$MAN_HOME_VIEW" -a ! -w "$MAN_HOME_VIEW" \) ]
then Error 8 "Cannot create file for reference view."
return 1
fi
#
# Find all the CONTENTS.html files, and pipe their paths into sed to
# remove the ./ find creates, then append a colon so each line looks like
# a view file node entry. Send this to our awk script.
find . -name CONTENTS.html ! -type d -print | \
sed 's@^\./@@;s/$/:/' | \
awk -f $Script -v "MAN=$MAN_DIR" -v "HOME_TITLE=$MAN_HOME_TITLE" \
-v "HOME_URL=$MAN_HOME_URL" \
-v "HOME_PARENT=$MAN_HOME_PARENT" \
-v "HOME_VERSION=$MAN_HOME_VERSION" \
-v "HOME_OVERVIEW=$MAN_HOME_OVERVIEW" \
-v "HOME_CLASS=$MAN_HOME_CLASS" > $MAN_HOME_VIEW
}
#
# Function to configure a single manpage section within a language. The only
# argument is the name of the section to be configured.
Config_Section()
{
# Remove any temporary index or whatis files for this section.
rm -f $TMP-[iw]$1
#
# Make the titles database for this section.
if $MKTITLES -m "$1"
then # Make the other files based on the titles database.
$MKCONTENTS -m "$1"
#
# Make the index and whatis databases for this section.
MakeIndexAndWhatis "$1" "$Script"
#
# Make the Verity bulk insert file for this section.
MakeVerityBulkInsertFile "$1"
fi
}
#
# Function to configure manpages for a specific language. The current
# directory is the language-specific manual directory under the BASE_PATH
# of the language whose documentation is to be configured. The arguments
# are the set of manpage sections to be configured within the language.
# If there are no arguments, all manpage sections within the language
# are configured. There is no return value.
Config_Language()
{
# Set the location of the Verity collection files for this language
VerityDir=$BASE_PATH/$Lang/$SEARCH_DIR
if [ ! -d $VerityDir ]
then
mkdir $VerityDir
if [ $? != 0 ]
then
Error 1 "Cannot create search index directory $VerityDir"
VerityDir=""
fi
fi
# Create the bulk insert subdirectories if needed
if [ -d "$VerityDir" ]
then
for subdir in $INDEXED_DIR $DELETE_DIR $INSERT_DIR
do
test -d $VerityDir/$subdir || mkdir $VerityDir/$subdir
done
fi
# If no arguments were specified, get all possible manpage section names.
unset Complain
if [ $# -eq 0 ]
then # Make a list of all the section names.
set -- `GetAllSectionNames`
#
# Now remove any section data for sections that no longer exist.
RemoveOldSectionData "$@"
else # We were given section names, complain if any are bad.
Complain=1
fi
#
# Make the awk script that creates index and whatis files.
Script=$TMP-genidx
GenerateScript >$Script
#
# Make sure the directory we will put the titles database files into exists.
if [ ! -d "$MAN_DATA_DIR/$MAN_TITLES_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_TITLES_DIR"
then : # We made it.
else Error 9 "Could not create title data directory"
return 1
fi
fi
#
# Make sure the directory we will put the TOC files into exists.
if [ ! -d "$MAN_DATA_DIR/$MAN_TOC_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_TOC_DIR"
then : # We made it.
else Error 10 "Could not create Table Of Contents data directory"
return 1
fi
fi
#
# Make sure the directories we put the index and whatis data in exist.
if [ ! -d "$MAN_DATA_DIR/$MAN_INDEX_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_INDEX_DIR"
then : # We made it.
else Error 11 "Could not create index data directory"
return 1
fi
fi
if [ ! -d "$MAN_DATA_DIR/$MAN_WHATIS_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_WHATIS_DIR"
then : # We made it.
else Error 12 "Could not create whatis data directory"
return 1
fi
fi
#
# Make sure the directory we will put the VBI file into exists.
if [ ! -d "$MAN_DATA_DIR/$MAN_VERITY_DIR" ]
then if mkdir -p -m 0755 "$MAN_DATA_DIR/$MAN_VERITY_DIR"
then : # We made it.
else Error 13 "Could not create Verity data directory"
return 1
fi
fi
#
# Get the path of the directory we start out in, so we can restore it.
StartDir="`pwd`"
#
# Loop over each manpage section name.
ProcList=""
NumProcs=0
for Section
do # Process each section.
#
# Check if we need to wait for processes to finish.
if [ $NumProcs -ge $MAX_PARALLEL_SECTIONS ]
then # Too many background processes active.
wait $ProcList # Wait for the children to die.
ProcList="" # All the children are dead.
NumProcs=0
fi
#
# Start configuring a section in the background.
Config_Section $Section &
# Keep track of the PIDs of each background process.
ProcList="$ProcList $!"
NumProcs=`expr $NumProcs + 1`
done
#
# If there are still some background processes active, wait for them.
if [ $NumProcs -gt 0 ]
then wait $ProcList
ProcList=""
NumProcs=0
fi
#
# All done with manpage sections, combine global data.
find $MAN_DATA_DIR/$MAN_INDEX_DIR -type f -print | \
xargs cat | sort -u > index
find $MAN_DATA_DIR/$MAN_WHATIS_DIR -type f -print | \
xargs cat | sort -u > whatis
#
# Perform language fallback for the whatis database. The index database
# does not need anything done to it because the man(1) command will do
# language fallback by itself.
WhatisLanguageFallback
#
# Run the Verity indexing process.
CombineGlobalIndex
#
# Generate the REFhome file.
MakeRefHome
}
#
#
##### MAIN CODE
#
# Parse the command line.
unset Lopt Dopt
while getopts "nL:d:" Opt
do case "$Opt" in
L) Lopt="$OPTARG";;
d) Dopt="$OPTARG";;
n) Nopt=1;;
\?) Usage;;
esac
done
shift `expr $OPTIND - 1`
#
# Locate and load the ODSSI configuration file.
if [ -f "$ODSSI_CONFIG" -a -r "$ODSSI_CONFIG" ]
then . "$ODSSI_CONFIG"
if [ -z "$BASE_PATH" ]
then Error 14 "Invalid ODSSI configuration file: %s" "$ODSSI_CONFIG"
exit 1
fi
else Error 15 "Cannot locate ODSSI configuration file: %s" "$ODSSI_CONFIG"
exit 1
fi
#
# Default the number of parallel processes if it is out of range.
if [ "$MAX_PARALLEL_SECTIONS" -gt 0 ] 2>/dev/null
then : # It is OK.
else MAX_PARALLEL_SECTIONS=1
fi
#
# If a directory was given and it exists, use it instead of the BASE_PATH.
if [ -n "$Dopt" ]
then if [ -d "$Dopt" ]
then BASE_PATH="$Dopt"
else Error 16 "No such directory: %s" "$Dopt"
exit 1
fi
fi
#
# Change directories to the base path.
if cd $BASE_PATH >/dev/null 2>&1
then : # It exists.
else Error 17 "Cannot find documentation directory: %s" "$BASE_PATH"
exit 1
fi
#
# Make sure this user can write into the documentation directories.
if [ ! -w "." ]
then Error 18 "Cannot configure documentation: permission denied: %s" "$BASE_PATH"
exit 1
fi
#
# Determine which languages to work on.
if [ -n "$Lopt" ]
then Langs="$Lopt"
if [ ! -d "$Langs/$MAN_DIR" ]
then Error 19 "No manual pages for language: %s" "$Lopt"
exit 1
fi
elif [ -n "$Dopt" -a "`basename $Dopt`" = "man" ]
then Langs=".."
else # Get the lang list from the directory
LangList="`echo * | tr ' ' '\012'`"
# Only language directories have Framework.
Langs=""
for dir in $LangList
do
test -d $dir/Framework -a $dir != $FALLBACK_LANG && Langs="$Langs $dir"
done
# Make sure we always do the fallback language first.
Langs="$FALLBACK_LANG $Langs"
fi
#
# Generate the VBI script.
VBIScript=$TMP-vbiscr
GenerateVBIScript >$VBIScript
#
# Loop over all the languages specified.
for Lang in $Langs
do # Configure documentation for this language.
if [ ! -d "$Lang/$MAN_DIR" ]; then continue; fi
Errs=0
if cd "$Lang/$MAN_DIR" >/dev/null 2>&1
then if [ "$Lang" != ".." ]
then # Use the language name for sorting, etc.
LANG="$Lang"
else LANG="$USER_LANG"
fi
export LANG
Config_Language "$@"
Errs=`expr $Errs + $?`
else Error 20 "No manual pages for language: %s" "$Lang"
Errs=1
fi
cd $BASE_PATH >/dev/null 2>&1
done
exit $Errs
#
### EOF