[tex-k] Patch for a bug in mktexlsr.pl

Martin Vath martin at mvath.de
Mon Jun 24 22:00:58 CEST 2024


Hi,

there is a bug (actually two) in mktexlsr.pl with the handling
of VCS ("hidden") files and directories like .git or CVS.

To trigger the bug, just create a CVS directory (with some
files inside!) into some subdirectory of some texmf tree,
and you will (very likely) observe that "mktexlsr.pl" does
not generate output for all files of that tree; essentially,
it "stops" when it meets the CVS directory.

There are in fact two bugs causing the issue:

1. In case of a VCS file/dir, $node should probably not be
    updated at all (maybe it works by accident anyway, but
    it is cleaner to just ignore the file you want to ignore).

2. In case of a dir, also the directory content should be
    skipped, that is, further recursing into that directory
    should be pruned.

Note that 1 is fixed easily by checking for the VCS files/dir
*before* updating $note, and to return immediately when one
is found.

Moreover, 2 is fixed even easier by just setting the
File::find::prune variable of the File::find package to 1.

You can find my patch with both fixes attached to this email
or in the link below.

Please feel free to include the patch in any form you like.

https://github.com/vaeth/portage-env-mv/blob/main/env/patches/texlive-core-mktexlsr.patch

Best Regards
Martin Väth
-------------- next part --------------
--- 1/texmf-dist/scripts/texlive/mktexlsr.pl
+++ 2/texmf-dist/scripts/texlive/mktexlsr.pl
@@ -206,13 +206,16 @@
       # add an entry of 1 if it is not a directory, otherwise
       # create an empty hash as argument
       File::Find::find( { follow_skip => 2, follow_fast => $opt_follow, wanted => sub {
-        $node = (pop @s)->[1] while (@s && $File::Find::dir ne $s[-1][0]);
         # ignore VCS
-        return if ($_ eq ".git");
-        return if ($_ eq ".svn");
-        return if ($_ eq ".hg");
-        return if ($_ eq ".bzr");
-        return if ($_ eq "CVS");
+        if ($_ eq ".git"
+         || $_ eq ".svn"
+         || $_ eq ".hg"
+         || $_ eq ".bzr"
+         || $_ eq "CVS") {
+          $File::Find::prune = 1 if (-d);
+          return;
+        }
+        $node = (pop @s)->[1] while (@s && $File::Find::dir ne $s[-1][0]);
         return $node->{$_} = 1 if (! -d);
         push (@s, [ $File::Find::name, $node ]);
         $node = $node->{$_} = {};


More information about the tex-k mailing list.