5 kx #!/bin/sh
5 kx # update-info-dir
5 kx # create a dir file from all installed info files
5 kx # Copyright 2009, 2014 Norbert Preining
5 kx # GPLv2
5 kx
5 kx INFODIR=/usr/info
5 kx
5 kx set -e
5 kx
5 kx #
5 kx # since user's environment is taken over into root account when sudo-ing
5 kx # we don't want that one's user LANGUAGE setting changes the messages in
5 kx # the dir file. Unset LANGUAGE and reload /etc/environment to get
5 kx # the system wide settings. See bug #536476
5 kx unset LANGUAGE
5 kx unset LANG
5 kx if [ -r /etc/environment ] ; then
5 kx . /etc/environment
5 kx fi
5 kx if [ -r /etc/default/locale ] ; then
5 kx . /etc/default/locale
5 kx fi
5 kx
5 kx Help ()
5 kx {
5 kx echo "\
5 kx SYNOPSIS: update-info-dir [-h,--help] [info-directory]
5 kx
5 kx (re-)creates the index of available documentation in info format
5 kx (the file $(echo $INFODIR)/dir) which is usually presented by info browsers
5 kx on startup."
5 kx
5 kx exit 0
5 kx }
5 kx
5 kx
5 kx if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
5 kx Help
5 kx fi
5 kx
5 kx if [ -n "$1" ] ; then
5 kx INFODIR="$1"
5 kx fi
5 kx
5 kx if [ ! -d "$INFODIR" ] ; then
5 kx echo "Not a directory: $INFODIR." >&2
5 kx exit 1
5 kx fi
5 kx
5 kx if [ -r "$INFODIR/dir" ] ; then
5 kx rm -f "$INFODIR/dir.old"
5 kx cp $INFODIR/dir $INFODIR/dir.old
5 kx fi
5 kx
5 kx # we have to remove the dir file not make install-info being surprised
5 kx rm -f "$INFODIR/dir"
5 kx
5 kx errors=0
5 kx find "$INFODIR" -type f | while read file ; do
5 kx case $file in
5 kx */dir|*/dir.gz|*/dir.old|*/dir.old.gz|*-[0-9]|*-[0-9].gz|*-[1-9][0-9]|*-[1-9][0-9].gz|*.png|*.jpg)
5 kx # these files are ignored
5 kx continue
5 kx ;;
5 kx *)
5 kx install-info "$file" "$INFODIR/dir" || {
5 kx errors=$((errors+1))
5 kx }
5 kx ;;
5 kx esac
5 kx done
5 kx
5 kx if [ $errors -gt 0 ] ; then
5 kx exec >&2
5 kx echo
5 kx echo "Updating the index of info documentation produced $errors errors."
5 kx fi
5 kx
5 kx exit 0
5 kx
5 kx # vim:set expandtab tabstop=2: #