[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#354517: tex-common: Include additional checks in update-language



> # perform_content_check
> #
> # This function *TRIES* to check wether the installed files are correct in
> # the sense that every file occurring in it is present. This can help to
> # find typing errors
> perform_content_check ()

What is the use of $1 in this function?

> {
>     #
>     # performing content checking only works when kpsewhich is present
>     # and configured, this can be done in one step:
                                    ^^^^
                      ;            checked, or queried

>     if kpsewhich --version  >/dev/null 2>&1 ; then
>         if [ "$progname" = "update-language" ] ; then
>             perform_content_check_language "$2"
>         elif [ "$progname" = "update-updmap" ] ; then
>             perform_content_check_map "$2"
>         elif [ "$progname" = "update-fmtutil" ] ; then
>             perform_content_check_format "$2"

          else
              echo "Invalid progname: '$progname'" >&2
              exit 1

>         fi
>     fi
> }

> perform_content_check_language ()
> {
>     fn="$1"
>     cat "$fn" | grep -v '^\W*\(%\|=\|$\)' | while read lang hyph comm ; do

      grep -v '^\W*\(%\|=\|$\)' "$fn" | while read lang hyph comm; do

  -> spare one process

>         # now check the existence of the hyphenation file
>         if [ -z $(kpsewhich -format=tex $hyph) ] ; then
>            cat >&2 <<EOF
> DEBUG: lang=$lang hyph=$hyph comm=$comm
> The config file $fn references a not-existing file

                                   file that is not in the kpathsea
                                   database

(it could well exist, just waiting for mktexlsr to be run)


>     $hyph
> This may be ok, but it could also be a typing error.
> EOF
>         fi
>     done
> }
        
> perform_content_check_map ()
> {
>     fn="$1"
>     cat "$fn" | grep -i '^[ \t]*\(Mixed\)\?*Map' | while read foo map ; do

  -> again, cat is useless here
  -> the second star in the regexp shouldn't be there, right?
 (-> also, I tend to always use grep -E, since it is the more powerful syntax)

>         # now check the existence of the hyphenation file
>         if [ -z $(kpsewhich -format=map $map) ] ; then
>            cat >&2 <<EOF
> The config file $fn references a not-existing file

-> same thing for "not-existing"

> perform_content_check_format ()
> {
>     fn="$1"
>     cat "$fn" | grep -v '^\W*\(#\|$\)' | while read format engine hyphenation args ; do

  -> spare this cat process

>         # this is stolen from fmtutil

The comment should rather tell what you are going to do in the next lines...

>         set - $args

This is not POSIX anymore (cf.
http://www.opengroup.org/onlinepubs/009695399/utilities/set.html). Use
'set -- $args' instead.

>         pool=; tcx=
>         case $1 in
>             nls=*)
>             pool=$(echo $1 | sed 's@nls=@@; s@,.*@@')
>             tcx=$(echo $1 | sed 's@nls=[^,]*@@; s@^,@@')
>             shift
>             ;;
>         esac
>         texargs="$@"

This blob is useless here.

>         eval lastarg=\$$#
>         inifile=$(echo $lastarg | sed 's%^\*%%')
>         case "$engine" in
>             mpost)  fmtfile="$format.mem";  kpsefmt=mpost;;

fmtfile is unused here

>             mf|mfw|mf-nowin) fmtfile="$format.base"; kpsefmt=mf;;
>             *)      fmtfile="$format.fmt";  kpsefmt=tex;;

same thing

>         esac
>         # now check the existence of the hyphenation file
>         if [ -z $(kpsewhich -progname=$format -format=$kpsefmt $inifile) ] ; then
>            cat >&2 <<EOF
> The config file $fn references a not-existing file
                                   ^^^^^^^^^^^^
                           same thing as seen previously

>     $inifile
> This may be ok, but it could also be a typing error.
> EOF
>         fi
>     done
> }

Well, I'm not sure there is a real need to add all this code, but if
there is user demand...

Is it so complex to check whether a package is actually installing the
expected map file/hyphenation file/format file?

-- 
Florent




Reply to: