#!/bin/sh
INFODIR=$1
if [ $ SKELETON=$2
else
SKELETON=/dev/null
fi
skip=
if [ $ echo usage: $0 info-directory [ skeleton-file ] 1>&2
exit 1
else
true
fi
if [ ! -d ${INFODIR} ] ; then
echo "$0: first argument must specify a directory"
exit 1
fi
echo "-*- Text -*-"
echo "This file was generated automatically by $0."
echo "This version was generated on `date`"
echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`"
cat << moobler
This is the file .../info/dir, which contains the topmost node of the
Info hierarchy. The first time you invoke Info you start off
looking at that node, which is (dir)Top.
File: dir Node: Top This is the top of the INFO tree
This (the Directory node) gives a menu of major topics.
Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h"
gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic,
etc.
Or click mouse button 2 on a menu item or cross reference to select it.
--- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---
* Menu: The list of major topics begins on the next line.
moobler
infofiles=`(cd ${INFODIR}; ls | egrep -v '\-|^dir$|^dir\.info$|^dir\.orig$')`
lines=`wc $SKELETON | awk '{print $1}'`
line=1
while [ $lines -ge $line ] ; do
fileline=`awk NR==$line $SKELETON`
if [ ! -z "$echoline" ] ; then echo "$fileline"
fileline=
echoline=
elif [ "${fileline}" = "--" ] ; then echoline=1
elif [ "${fileline}" = "%%" ] ; then skip=1
elif [ "${fileline}" = "!!" ] ; then exit 0
fi
for file in $fileline"" ; do
fname=
if [ -z "$echoline" -a ! -z "$file" ] ; then
infoname=`echo $file | sed 's/\.info$//'`
noext=
ext=
if [ -f ${INFODIR}/$infoname ] ; then
noext=$infoname
fi
if [ -f ${INFODIR}/${infoname}.info ] ; then
ext=${infoname}.info
fi
if [ ! -z "$ext" -a ! -z "$noext" ]; then
fname=$file
warn="### Warning: $ext and $noext both exist! Using ${file}. ###"
elif [ ! \( -z "$ext" -a -z "$noext" \) ]; then
fname=${noext}${ext}
fi
if [ ! -z "$fname" ] ; then
if [ -z "$skip" ] ; then
if [ ! -z "$warn" ] ; then echo $warn
warn=
fi
entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
-e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$fname`
if [ ! -z "${entry}" ] ; then
echo "${entry}"
else
echo "* ${infoname}: (${fname})."
fi
fi
infofiles=`echo ${infofiles} | sed -e "s/ ${fname} / /" \
-e "s/^${fname} //" \
-e "s/ ${fname}$//"`
fi
fi
done
line=`expr $line + 1`
done
if [ -z "${infofiles}" ] ; then
exit 0
else
echo
fi
for file in ${infofiles}; do
case $file in
*.gz) zcat=zcat; file=`echo $file|sed 's/\.gz$//'`; gz=.gz;;
*) zcat=cat; gz=;;
esac
infoname=`echo $file | sed 's/\.info$//'`
entry=`$zcat ${INFODIR}/${file}$gz \
|sed -e '1,/START-INFO-DIR-ENTRY/d' \
-e '/END-INFO-DIR-ENTRY/,$d'`
if [ ! -z "${entry}" ] ; then
echo "${entry}"
else
echo "* ${infoname}: (${file})."
fi
done