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

Re: [urgent] update-fontlang new checks



Hi Florent!

Thanks again!

On Die, 10 Okt 2006, Florent Rougon wrote:
> >> > +            if [ -r "$d/$PATH_COMPONENT/$DEFAULT_OUTPUTFILE_BASENAME" ]; then
> >> 
> >>                  or -f...
> >
> > What would you suggest, oh my POSIX guru ;-)???
> 
> ;-)
> 
> Nothing to do with POSIX, but I prefer -f. That's because if there is a
> file in such a place, be it readable or not, it's a bit weird, so I
> think the user should be warned. But this is not very important...

Ok, now it is -f

> What I would probably do:

> +output_file_specified=0

> and then, use:
> 
> if [ $syswide_mode = 0 ] && [ $output_file_specified = 0 ]; then

Good idea. Done.

> >  perform_sanity_checks
> 
> I believe this code could actually enter perform_sanity_checks.

Moved there.

> > +which will shadow the former one. We'll continue generating the first
>                                 ^^^
> I don't think this is correct...

I.e. deleted " one"

Thanks a lot. Last version is in svn. For completeness here the diff.
--- /usr/sbin/update-fontlang	2006-10-09 00:33:43.000000000 +0200
+++ update-fontlang	2006-10-10 01:26:09.000000000 +0200
@@ -22,6 +22,8 @@
 version="0.9"
 progname=$(basename "$0")
 
+SYSPATH_BASE=/var/lib/texmf
+
 if [ "$progname" = "update-language" ] ; then
     CNFDIR=language.d
     # System-wide configuration directory
@@ -29,7 +31,8 @@
     CHECKFILE="$SYSWIDE_CONFDIR/00tex.cnf"
     EXT="cnf"
     MEMORY_DIR=/var/lib/tex-common/language-cnf
-    SYSWIDE_VARD=/var/lib/texmf/tex/generic/config
+    PATH_COMPONENT=tex/generic/config
+    SYSWIDE_VARD="$SYSPATH_BASE/$PATH_COMPONENT"
     DEFAULT_OUTPUTFILE_BASENAME=language.dat
     SYSWIDE_DEFAULT_OUTPUTFILE="$SYSWIDE_VARD/$DEFAULT_OUTPUTFILE_BASENAME"
     CC="%"                      # for COMMENTCHAR
@@ -43,7 +46,8 @@
     CHECKFILE="$SYSWIDE_CONFDIR/00updmap.cfg"
     EXT="cfg"
     MEMORY_DIR=/var/lib/tex-common/fontmap-cfg
-    SYSWIDE_VARD=/var/lib/texmf/web2c
+    PATH_COMPONENT=web2c
+    SYSWIDE_VARD="$SYSPATH_BASE/$PATH_COMPONENT"
     DEFAULT_OUTPUTFILE_BASENAME=updmap.cfg
     SYSWIDE_DEFAULT_OUTPUTFILE="$SYSWIDE_VARD/$DEFAULT_OUTPUTFILE_BASENAME"
     CC="#"
@@ -56,7 +60,8 @@
     CHECKFILE="$SYSWIDE_CONFDIR/00tex.cnf"
     EXT="cnf"
     MEMORY_DIR=/var/lib/tex-common/fmtutil-cnf
-    SYSWIDE_VARD=/var/lib/texmf/web2c
+    PATH_COMPONENT=web2c
+    SYSWIDE_VARD="$SYSPATH_BASE/$PATH_COMPONENT"
     DEFAULT_OUTPUTFILE_BASENAME=fmtutil.cnf
     SYSWIDE_DEFAULT_OUTPUTFILE="$SYSWIDE_VARD/$DEFAULT_OUTPUTFILE_BASENAME"
     CC="#"
@@ -267,6 +272,30 @@
             exit 1
         fi
     fi
+
+    # it could be that there is a DEFAULT_OUTPUTFILE_BASENAME file 
+    # in TEXMFCONFIG, which would be found instead of the
+    # output_file. So we check for this and give a warning in case
+    # the created file would be shadowed.
+    if [ $syswide_mode = 0 ] && [ $output_file_specified = 0 ]; then
+        OLDIFS="$IFS"
+        IFS=:
+        for d in "$texmfconfig"; do
+            if [ ! "$d/$PATH_COMPONENT/$DEFAULT_OUTPUTFILE_BASENAME" = "$output_file" ] && [ -f "$d/$PATH_COMPONENT/$DEFAULT_OUTPUTFILE_BASENAME" ] ; then
+                printf "\
+You are about to generate the file 
+        $output_file
+but at the same time you have a file
+        $d/$PATH_COMPONENT/$DEFAULT_OUTPUTFILE_BASENAME
+which will shadow the former. We'll continue generating the first
+file, but to allow TeX and friends to find it, you'll have to remove the
+second one.\n"
+                # don't break out as we want to warn the user for *every*
+                # shadowing file!
+            fi
+        done
+        IFS="$OLDIFS"
+    fi
 }
 
 #
@@ -382,6 +411,8 @@
 # ****************************************************************************
 quiet=1
 dochecks=0
+output_file_specified=0
+
 if [ $syswide_mode = 1 ]; then
     output_file="$SYSWIDE_DEFAULT_OUTPUTFILE"
 else
@@ -409,7 +440,7 @@
     # Does $TEXMFVAR expand to a single directory?
     texmfvar=$(kpsewhich --expand-path '$TEXMFVAR')
     if ! echo "$texmfvar" | grep -e ':'; then
-        output_file="$texmfvar/web2c/$DEFAULT_OUTPUTFILE_BASENAME"
+        output_file="$texmfvar/$PATH_COMPONENT/$DEFAULT_OUTPUTFILE_BASENAME"
     else
         # We don't know what to do in this case, therefore: do nothing unless
         # the output file is specified with the correponding option.
@@ -424,7 +455,10 @@
 while true; do
     case "$1" in
         -c|--conf-dir) conf_dir="$2"; shift 2 ;;
-        -o|--output-file) output_file="$2"; shift 2 ;;
+        -o|--output-file) 
+            output_file="$2"
+            output_file_specified=1
+            shift 2 ;;
         --quiet) quiet=1; shift ;;
         --check) dochecks=1; shift ;;
         -v) printf "\



Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining@logic.at>                    Università di Siena
Debian Developer <preining@debian.org>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
HOBBS CROSS (n.)
The awkward leaping manoeuvre a girl has to go through in bed in order
to make him sleep on the wet patch.
			--- Douglas Adams, The Meaning of Liff



Reply to: