1#!/bin/sh 2# 3# generate an Info directory, given a directory of Info files and a 4# list of entries. The output will be suitable for a dir.info file, 5# in the order given in the skeleton file 6 7INFODIR=$1 8if [ $# = 2 ] ; then 9 SKELETON=$2 10else 11 SKELETON=/dev/null 12fi 13 14skip= 15 16if [ $# -gt 2 ] ; then 17 echo usage: $0 info-directory [ skeleton-file ] 1>&2 18 exit 1 19else 20 true 21fi 22 23if [ ! -d ${INFODIR} ] ; then 24 echo "$0: first argument must specify a directory" 25 exit 1 26fi 27 28infofiles=`(cd ${INFODIR}; ls *.info | sort | sed "s/dir\.info//")` 29template=`cat ${SKELETON}` 30 31### output the dir.info header 32echo "-*- Text -*-" 33echo "This file was generated automatically by the gen-info-dir script." 34echo "This version was generated on `date`" 35echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`" 36 37cat << moobler 38 39This is the file .../info/dir, which contains the topmost node of the 40Info hierarchy. The first time you invoke Info you start off 41looking at that node, which is (dir)Top. 42 43File: dir Node: Top This is the top of the INFO tree 44 This (the Directory node) gives a menu of major topics. 45 Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" 46 gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic, 47 etc. 48 --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- 49 50* Menu: The list of major topics begins on the next line. 51 52moobler 53 54 55### go through the list of files in the template. If an info file 56### exists, grab the ENTRY information from it. If there is no entry 57### info, then create a minimal dir entry, otherwise use the given info. 58### 59### Then remove that file from the list of existing files. If any 60### additional files remain (ones that don't have a template entry), 61### then generate entries for those in the same way, putting the info for 62### those at the very end.... 63 64for file in ${template} ; do 65 if [ "${file}" = "--" ] ; then 66 skip=1 67 else 68 if [ -f ${INFODIR}/${file}.info ] ; then 69 entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}.info` 70 if [ ! -z "${skip}" ] ; then 71 echo 72 skip= 73 fi 74 75 if [ ! -z "${entry}" ] ; then 76 echo "${entry}" 77 else 78 echo "* ${file}: (${file})." 79 fi 80 81 infofiles=`echo ${infofiles} | sed -e "s/${file}\.info//"` 82 fi 83 fi 84done 85 86if [ -z "${infofiles}" ] ; then 87 exit 0 88else 89 echo 90fi 91 92for file in ${infofiles}; do 93 entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}` 94 95 if [ ! -z "${entry}" ] ; then 96 echo "${entry}" 97 else 98 echo "* ${file}: (${file})." 99 fi 100done 101 102