#! /bin/sh # # Generated automatically from install-inf.in by configure. # # $Id: install-inf.in 0.21 2000/06/14 00:02:01 tom Exp $ # # This is my private `install-info' script. # # It inserts INFO-DIR-ENTRY lines of Texinfo `.info' files at the end of # an existing `dir.texi' file and recreates the `dir' file either in the # directory given by the `--info-dir=DIR' option or in the first matching # $INFOPATH directory. It also creates a backup of the original `dir.texi' # file under the name `dir.texi~'. # # *** It cannot insert INFO-DIR-ENTRY lines into an existing `dir' file # *** in case no `dir.texi' file exists! # # This script also manages compressed/gzipped Texinfo `*.info' files like # `*.info*.Z', `*.info*.z' and `*.info*.gz', also compressed/gzipped `dir' # and `dir.texi' files. # # If both the `dir' and `dir.texi' files do not exist, this script will # create a new `dir.texi' file and --using it-- a new `dir' file! # # Needs `test', `echo', `head', `eval', `cat', `cd', `cp', `rm', `makeinfo', # `set', `gzip' or `compress', `sort', `sed' and `awk' for processing. # # Returns 0 if success. # Returns 1 in case an error occurs. # # Copyright (c) 1996, 97, 2000 Thomas Esken # Im Hagenfeld 84 # D-48147 M"unster # GERMANY # # This software doesn't claim completeness, correctness or usability. # On principle I will not be liable for ANY damages or losses (implicit # or explicit), which result from using or handling my software. # If you use this software, you agree without any exception to this # agreement, which binds you LEGALLY !! # # This program is free software; you can redistribute it and/or modify # it under the terms of the `GNU General Public License' as published by # the `Free Software Foundation'; either version 2, or (at your option) # any later version. # # You should have received a copy of the `GNU General Public License' # along with this program; if not, write to the: # # Free Software Foundation, Inc. # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # # # # Basically used programs. # Sed=sed Test=test Echo=echo # # Basically used texts. # PACKAGE=gcal VERSION=3.01 myname=`$Echo "$0" | $Sed -e 's,.*/,,'` myversion=0.21 myinternalname="$myname ($PACKAGE $VERSION) $myversion" usage1="usage: $myname --help | --version" usage2="usage: $myname [--verbose] [--debug] [--info[-]dir=DIR] INFOFILE..." error1="$myinternalname: error: no input file specified" error2="$myinternalname: error: use --help to show usage" # # Some constant values. # EXIT_SUCCESS=0 EXIT_FAILURE=1 # # Let's start processing now. # if $Test "$#" -ne 0; then # # The suffix for the backup of the original `dir.texi' file. # backup_suffix="~" # # The suffixes of compressed/gzipped files. # gzip_2_suffix=.gz gzip_1_suffix=.z compress_suffix=.Z # # Number of lines to scan for INFO-DIR-ENTRY texts in an INFOFILE. # lines_to_scan=200 # # The used programs. # Head=head Head_flags="-$lines_to_scan" Eval=eval Set=set Cat=cat Cd=cd Cp="cp -p" Rm=rm Makeinfo=makeinfo Gzip=gzip Compress= Gzip_uncompress_flags=-cd Sort=sort Awk=mawk # # Let's set some default directories and file names first. # tmpdir=/tmp prefix=/usr/local infodir="$prefix/info" dirfile=dir dir_texifile="$dirfile.texi" # # Let's set the compressor program to `compress' if no `gzip' is available. # if $Test -z "$Gzip"; then if $Test -n "$Compress"; then Gzip="$Compress" fi fi # # Respect a $TMPDIR or a $TMP environment variable. # if $Test -n "$TMPDIR"; then tmpdir="$TMPDIR" else if $Test -n "$TMP"; then tmpdir="$TMP" fi fi # # Let's check for command line arguments. # verbose=no debug=no infodir_set=no previous="" for option in $* do # # If the previous option needs an argument, assign it. # if $Test -n "$previous"; then $Eval "$previous=\$option" previous="" continue fi case "$option" in -*=) optarg="###error###" ;; -*=*) optarg=`$Echo "$option" | $Sed 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg="" ;; esac # # Manage the options. # case "$option" in -help=* | -hel=* | -he=* | -h=* | \ -help | -hel | -he | -h | \ --help=* | --hel=* | --he=* | --h=* | \ --help | --hel | --he | --h) if $Test -n "$optarg"; then $Echo "$myname: error: option \``$Echo $option | $Sed -e 's/=.*//'`' doesn't allow an argument" 1>&2 exit $EXIT_FAILURE fi $Echo "$usage1" $Echo "$usage2" exit $EXIT_SUCCESS ;; -version=* | -versio=* | -versi=* | -vers=* | \ -version | -versio | -versi | -vers | \ --version=* | --versio=* | --versi=* | --vers=* | \ --version | --versio | --versi | --vers) if $Test -n "$optarg"; then $Echo "$myname: error: option \``$Echo $option | $Sed -e 's/=.*//'`' doesn't allow an argument" 1>&2 exit $EXIT_FAILURE fi $Echo "$myinternalname" exit $EXIT_SUCCESS ;; -verbose=* | -verbos=* | -verbo=* | -verb=* | \ -verbose | -verbos | -verbo | -verb | \ --verbose=* | --verbos=* | --verbo=* | --verb=* | \ --verbose | --verbos | --verbo | --verb) if $Test -n "$optarg"; then $Echo "$myname: error: option \``$Echo $option | $Sed -e 's/=.*//'`' doesn't allow an argument" 1>&2 exit $EXIT_FAILURE fi verbose=yes ;; -debug=* | -debu=* | -deb=* | -de=* | -d=* | \ -debug | -debu | -deb | -de | -d | \ --debug=* | --debu=* | --deb=* | --de=* | --d=* | \ --debug | --debu | --deb | --de | --d) if $Test -n "$optarg"; then $Echo "$myname: error: option \``$Echo $option | $Sed -e 's/=.*//'`' doesn't allow an argument" 1>&2 exit $EXIT_FAILURE fi debug=yes ;; -info-dir | -info-di | -info-d | -info- | \ -infodir | -infodi | -infod | -info | -inf | -in | -i | \ --info-dir | --info-di | --info-d | --info- | \ --infodir | --infodi | --infod | --info | --inf | --in | --i) previous=infodir ;; -info-dir=* | -info-di=* | -info-d=* | -info-=* | \ -infodir=* | -infodi=* | -infod=* | -info=* | -inf=* | -in=* | -i=* | \ --info-dir=* | --info-di=* | --info-d=* | --info-=* | \ --infodir=* | --infodi=* | --infod=* | --info=* | --inf=* | --in=* | --i=*) if $Test -z "$optarg" || $Test "$optarg" = "###error###"; then $Echo "$myname: error: option \``$Echo $option | $Sed -e 's/=//g'`' requires an argument" 1>&2 exit $EXIT_FAILURE fi infodir_set=yes infodir="$optarg" ;; -*) $Echo "$myname: error: $option: invalid option; use --help to show usage" 1>&2 exit $EXIT_FAILURE ;; esac done if $Test -n "$previous"; then $Echo "$myname: error: missing argument to --$previous" 1>&2 exit $EXIT_FAILURE fi # # We need two temporary files for processing! # newtmp="n$$" dirtmp="d$$" if $Test "$debug" = yes; then # # Enable tracing. # $Set -x else trap "$Rm -f $tmpdir/$newtmp $tmpdir/$dirtmp;exit $EXIT_FAILURE" 1 2 15 fi # # Check for the presence of AWK. # if $Test -z "$Awk" then $Echo "$myinternalname: error: \`awk' not available" 1>&2 exit $EXIT_FAILURE fi # # Override an existing $INFOPATH environment variable. # if $Test "$infodir_set" = yes || $Test -z "$INFOPATH"; then if $Test -d "$infodir" && $Test -s "$infodir"; then INFOPATH="$infodir" else $Echo "$myinternalname: error: cannot access infodir \`$infodir'" 1>&2 exit $EXIT_FAILURE fi fi # # Detect where the original `dir.texi' and `dir' files are stored. # IFS="${IFS= }" save_ifs="$IFS" IFS="${IFS}:" dirpath="" real_dirfile="" dirfile_gzipped_2=no dirfile_gzipped_1=no dirfile_compressed=no dir_texifile_gzipped_2=no dir_texifile_gzipped_1=no dir_texifile_compressed=no for dir in $INFOPATH do if $Test -f "$dir/$dir_texifile""$gzip_2_suffix" && \ $Test -r "$dir/$dir_texifile""$gzip_2_suffix"; then dir_texifile_gzipped_2=yes dirpath="$dir/$dir_texifile""$gzip_2_suffix" fi if $Test "$dir_texi_file_gzipped_2" = no; then if $Test -f "$dir/$dir_texifile""$gzip_1_suffix" && \ $Test -r "$dir/$dir_texifile""$gzip_1_suffix"; then dir_texifile_gzipped_1=yes dirpath="$dir/$dir_texifile""$gzip_1_suffix" fi if $Test "$dir_texi_file_gzipped_1" = no; then if $Test -f "$dir/$dir_texifile""$compress_suffix" && \ $Test -r "$dir/$dir_texifile""$compress_suffix"; then dir_texifile_compressed=yes dirpath="$dir/$dir_texifile""$compress_suffix" fi fi fi if $Test "$dir_texifile_gzipped_2" = yes || \ $Test "$dir_texifile_gzipped_1" = yes || \ $Test "$dir_texifile_compressed" = yes || \ $Test -f "$dir/$dir_texifile"; then if $Test -f "$dir/$dir_texifile" && \ $Test -r "$dir/$dir_texifile"; then dirpath="$dir/$dir_texifile" fi if $Test -f "$dir/$dirfile""$gzip_2_suffix" && \ $Test -r "$dir/$dirfile""$gzip_2_suffix"; then dirfile_gzipped_2=yes real_dirfile="$dir/$dirfile""$gzip_2_suffix" fi if $Test "$dirfile_gzipped_2" = no; then if $Test -f "$dir/$dirfile""$gzip_1_suffix" && \ $Test -r "$dir/$dirfile""$gzip_1_suffix"; then dirfile_gzipped_1=yes real_dirfile="$dir/$dirfile""$gzip_1_suffix" fi if $Test "$dirfile_gzipped_1" = no; then if $Test -f "$dir/$dirfile""$compress_suffix" && \ $Test -r "$dir/$dirfile""$compress_suffix"; then dirfile_compressed=yes real_dirfile="$dir/$dirfile""$compress_suffix" else real_dirfile="$dir/$dirfile" fi fi fi break fi done IFS="$save_ifs" if $Test -z "$dirpath"; then if $Test "$verbose" = yes; then $Echo "$myinternalname: warning: no existing \`$infodir/$dir_texifile' file found" fi # # No `dir.texi' file found, so check for a `dir' file now. # if $Test -f "$dir/$dirfile" && \ $Test -r "$dir/$dirfile"; then # # This script cannot insert INFO-DIR-ENTY lines into an existing # `dir' file, which will be untouched now, so just exit with success. # if $Test "$verbose" = yes; then $Echo "$myinternalname: warning: but existing \`$infodir/$dirfile' file found" $Echo $Echo "$myinternalname: warning: this case cannot be managed now, so you" $Echo "$myinternalname: warning: have to install *GNU Texinfo-3.8* or later" $Echo "$myinternalname: warning: in order to install the INFO-DIR-ENTRY lines" $Echo fi $Echo "$myinternalname: mission impossible by reason of missing \`$infodir/$dir_texifile' file" exit $EXIT_SUCCESS fi if $Test "$verbose" = yes; then $Echo "$myinternalname: warning: a new \`$dir_texifile' file will be created now" $Echo "$myinternalname: warning: in the \`$infodir' directory, please wait..." fi dirpath="$infodir/$dir_texifile" $Echo "@setfilename dir" > $dirpath $Echo "@node Top, (dir), (dir), (dir)" >> $dirpath $Echo "@center" >> $dirpath $Echo "Welcome to the FSF's Info Browser =8^.@*" >> $dirpath $Echo "@center" >> $dirpath $Echo "Select one of the following basic documentations:" >> $dirpath $Echo "@menu" >> $dirpath $Echo "My favourite tools:" >> $dirpath $Echo "@end menu" >> $dirpath $Echo "@bye" >> $dirpath if $Test "$verbose" = yes; then $Echo $Echo "$myinternalname: \`$dirpath' successfully created" $Echo $Echo "$myinternalname: let's see if \`$dirpath'" $Echo "$myinternalname: can be extended by some INFO-DIR-ENTRY lines" $Echo $Echo "$myinternalname: please wait..." $Echo fi else if $Test ! -w "$dirpath"; then $Echo "$myinternalname: error: \`$dirpath' file not writeable" 1>&2 exit $EXIT_FAILURE else if $Test "$verbose" = yes; then $Echo "$myinternalname: let's see if \`$dirpath'" $Echo "$myinternalname: can be extended by some INFO-DIR-ENTRY lines" $Echo $Echo "$myinternalname: please wait..." $Echo fi fi fi # # Let's start processing now. # files_given=no for file in $* do case "$file" in -*) continue ;; *) files_given=yes # # Store all lines between `START-INFO-DIR-ENTRY' and `END-INFO-DIR-ENTRY'. # if $Test -f "$file" && $Test -r "$file"; then if $Test "$verbose" = yes; then $Echo "$myinternalname: working on \`$file' ..." fi # # Let's check for compressed/gzipped files. # infofile_gzipped_2=`$Echo "$file" | \ $Sed -e 's/\///g' -e "s/$gzip_2_suffix/\//" \ -e 's/[-_\*\ \\^\!\$%&=?+#,;:|.~<>(){}a-zA-Z0-9]/@/g' \ -e 's/@\/@//' -e 's/@\//yes/' -e 's/@//g'` if $Test "$infofile_gzipped_2" != yes; then infofile_gzipped_1=`$Echo "$file" | \ $Sed -e 's/\///g' -e "s/$gzip_1_suffix/\//" \ -e 's/[-_\*\ \\^\!\$%&=?+#,;:|.~<>(){}a-zA-Z0-9]/@/g' \ -e 's/@\/@//' -e 's/@\//yes/' -e 's/@//g'` if $Test "$infofile_gzipped_1" != yes; then infofile_compressed=`$Echo "$file" | \ $Sed -e 's/\///g' -e "s/$compress_suffix/\//" \ -e 's/[-_\*\ \\^\!\$%&=?+#,;:|.~<>(){}a-zA-Z0-9]/@/g' \ -e 's/@\/@//' -e 's/@\//yes/' -e 's/@//g'` fi fi if $Test "$infofile_gzipped_2" = yes || \ $Test "$infofile_gzipped_1" = yes || \ $Test "$infofile_compressed" = yes; then if $Test -n "$Gzip"; then cmd=`$Gzip $Gzip_uncompress_flags $file | \ $Head $Head_flags` else cmd="" fi else cmd=`$Head $Head_flags $file` fi if $Test -n "$cmd"; then $Echo "$cmd" | \ $Awk 'BEGIN {found = 0; lines = 0;} \ { \ if ($0 ~ /START-INFO-DIR-ENTRY/) \ found = 1; \ else \ if (found == 1) \ { \ if ($0 ~ /END-INFO-DIR-ENTRY/) \ { \ found = 0; \ if (lines > 0) \ { \ if (substr(buf, 1, 1) == "*") \ print buf; \ else \ { \ i = 1; \ while (substr(buf, i, 1) == " ") \ i++; \ if (i == 1) \ i++; \ print substr(buf, i-1); \ } \ } \ } \ else \ { \ if (lines == 0) \ buf = $0; \ else \ { \ nl_found = 0; \ if (substr($0, 1, 1) == "*") \ nl_found = 1; \ if (nl_found == 0) \ printf "%s", buf; \ else \ { \ i = 1; \ while (substr(buf, i, 1) == " ") \ i++; \ if (i == 1) \ i++; \ print substr(buf, i-1); \ } \ buf = $0; \ } \ lines++; \ } \ } \ }' - >> $tmpdir/$newtmp else $Echo "$myinternalname: warning: can't operate on \`$file' by reason of missing compressor program" fi else if $Test ! -f "$file"; then $Echo "$myinternalname: warning: \`$file' file not found" else $Echo "$myinternalname: warning: \`$file' file not readable" fi fi esac done # # Emit some diagnostic texts. # if $Test -s "$tmpdir/$newtmp" then # # Some INFO-DIR-ENTRY lines detected, go ahead. # if $Test "$verbose" = yes; then $Echo $Echo "$myinternalname: some INFO-DIR-ENTRY lines detected..." $Echo "$myinternalname: here they are:" $Cat $tmpdir/$newtmp $Echo fi else # # No INFO-DIR-ENTRY lines detected, exit. # if $Test "$debug" = no; then $Rm -f $tmpdir/$newtmp fi if $Test "$verbose" = yes; then if $Test "$files_given" = yes; then $Echo $Echo "$myinternalname: no INFO-DIR-ENTRY lines detected," $Echo "$myinternalname: so modification of \`$dirpath' unnecessary..." exit $EXIT_SUCCESS else $Echo "$myinternalname: error: no files specified" 1>&2 exit $EXIT_FAILURE fi else # # No INFO-DIR-ENTRY lines detected, exit with success. # $Echo "$myinternalname: nothing to do... bye bye" exit $EXIT_SUCCESS fi fi # # Check whether the `dir' file is compressed/gzipped. # use_gzip_with_dirfile=no if $Test "$dirfile_gzipped_2" = yes || \ $Test "$dirfile_gzipped_1" = yes || \ $Test "$dirfile_compressed" = yes; then use_gzip_with_dirfile=yes fi # # Check whether the `dir.texi' file is compressed/gzipped. # use_gzip_with_dir_texifile=no if $Test "$dir_texifile_gzipped_2" = yes || \ $Test "$dir_texifile_gzipped_1" = yes || \ $Test "$dir_texifile_compressed" = yes; then use_gzip_with_dir_texifile=yes fi # # We can always continue our task if the `dir.texi' file is uncompressed... # If it is compressed/gzipped, check whether it can be uncompressed. # If former have failed, we have lost because our mission is impossible! # if $Test "$use_gzip_with_dir_texifile" = no || $Test -n "$Gzip"; then # # Now create the NEW `dir.texi' file. # if $Test "$use_gzip_with_dir_texifile" = yes; then $Gzip $Gzip_uncompress_flags $dirpath | \ $Awk 'BEGIN {found = 0;} \ { \ if (found == 0) \ { \ if ($0 ~ /@end menu/) \ found = 1; \ else \ print $0; \ } \ }' - >> $tmpdir/$dirtmp else $Awk 'BEGIN {found = 0;} \ { \ if (found == 0) \ { \ if ($0 ~ /@end menu/) \ found = 1; \ else \ print $0; \ } \ }' $dirpath >> $tmpdir/$dirtmp fi # # After copying all text of the original `dir.texi' file until (exclusive) # an "@end menu" line, append the extracted texts between START-INFO-DIR-ENTRY # and END-INFO-DIR-ENTRY to the temporary file in sorted manner. # $Cat $tmpdir/$newtmp | $Sort >> $tmpdir/$dirtmp # # And append the rest of the original `dir.texi' file to the temporary file. # if $Test "$use_gzip_with_dir_texifile" = yes; then $Gzip $Gzip_uncompress_flags $dirpath | \ $Awk 'BEGIN {found = 0;} \ { \ if (found != 0) \ print $0; \ else \ if ($0 ~ /@end menu/) \ { \ found = 1; \ print $0; \ } \ }' - >> $tmpdir/$dirtmp else $Awk 'BEGIN {found = 0;} \ { \ if (found != 0) \ print $0; \ else \ if ($0 ~ /@end menu/) \ { \ found = 1; \ print $0; \ } \ }' $dirpath >> $tmpdir/$dirtmp fi if $Test -n "$Makeinfo"; then # # Create a NEW `dir' file by means of the `makeinfo' program, # but first backup the original `dir.texi' file and then copy # the results of processing to the NEW `dir.texi' file. # $Cd $dir if $Test -n "$Cp"; then $Cp $dirpath $dirpath""$backup_suffix $Cp $tmpdir/$dirtmp $dir_texifile else $Cat $dirpath > $dirpath""$backup_suffix $Cat $tmpdir/$dirtmp > $dir_texifile fi $Makeinfo $dir_texifile # # And compress/gzip the resulting file now. # if $Test "$use_gzip_with_dirfile" = yes && $Test -n "$Gzip"; then $Rm -f $real_dirfile $Gzip $dirfile fi else if $Test "$verbose" = yes; then $Echo "$myinternalname: warning: cannot create \`$dirfile' by reason of missing makeinfo program" fi fi if $Test "$use_gzip_with_dir_texifile" = yes && $Test -n "$Gzip"; then $Rm -f $dirpath $Gzip $dir_texifile fi # # At last, clean the temporary files and exit with success. # if $Test "$debug" = no; then $Rm -f $tmpdir/$newtmp $tmpdir/$dirtmp fi if $Test "$verbose" = yes; then $Echo fi $Echo "$myinternalname: all modifications successfully done" exit $EXIT_SUCCESS else # # At last, clean the one remaining temporary file and exit with success. # if $Test "$debug" = no; then $Rm -f $tmpdir/$newtmp fi if $Test "$verbose" = yes; then $Echo fi $Echo "$myinternalname: mission impossible by reason of missing compressor program" exit $EXIT_SUCCESS fi else $Echo "$error1" 1>&2 $Echo "$error2" 1>&2 exit $EXIT_FAILURE fi