]> git.lyx.org Git - lyx.git/commitdiff
Let TeXFiles.py handle symbolic links.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 25 Jun 2019 13:46:14 +0000 (15:46 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 27 Jun 2019 21:53:03 +0000 (23:53 +0200)
Nix (https://nixos.org) is a Unix package manager, which can be used to
install LaTeX on macOS. A peculiarity of Nix is that all packages are
installed into separate directories and the actual directory tree is
then constructed via symlinks.

This interacts badly with the way LyX currently detects files in the
TeX setup, because TeXFiles.py does not follow symlinks. Therefore,
almost nothing is found when using LyX together with Nix’ LaTeX.

Patch from Michael Roitzsch.

(cherry picked from commit 642b4acca1900c55662030ffc5162e9504881764)

lib/CREDITS
lib/generate_contributions.py
lib/scripts/TeXFiles.py
status.23x

index 72f642086f8e5b5ed590d39443f17f231ca5b839..53c7efe41765cf80838777d44f2883adc623f8af 100644 (file)
 @bBernhard Roider
 @iE-mail: bernhard.roider () sonnenkinder ! org
    Various bug fixes
+@bMichael Roitzsch
+@iE-mail: reactorcontrol () icloud ! com
+   Fixes for the Nix package manager
 @bJim Rotmalm
 @iE-mail: jim.rotmalm () gmail ! com
    Swedish translation
index 44953c52d12a0f01e370a6403566b32f5db3e3e9..2e9224c66c4143b4cf69c1c40a5a88ab4f6418df 100755 (executable)
@@ -1655,6 +1655,14 @@ contributors = [
                  "29 January 2007",
                  u"Various bug fixes"),
 
+     contributor(u"Michael Roitzsch",
+                 "reactorcontrol () icloud ! com",
+                 "GPL",
+                 "Re: TeXFiles.py compatibility with Nix on macOS",
+                 "m=156146891826580",
+                 "25 June 2019",
+                 u"Fixes for the Nix package manager"),
+
      contributor(u"Jim Rotmalm",
                  "jim.rotmalm () gmail ! com",
                  "GPL",
index aac29bc9d0e20c2c647586d27e00ef3608d933a8..188f6b90ad64d6d16311a818b28d5e95c58cc081 100755 (executable)
@@ -116,7 +116,17 @@ for type in types:
         if not os.path.isdir(dir):
             continue
         # walk down the file hierarchy
-        for root,path,files in os.walk(dir):
+        visited = set()
+        for root,dirs,files in os.walk(dir, followlinks=True):
+            # prevent inifinite recursion
+            recurse = []
+            for dir in dirs:
+                st = os.stat(os.path.join(root, dir))
+                key = st.st_dev, st.st_ino
+                if key not in visited:
+                    visited.add(key)
+                    recurse.append(dir)
+            dirs[:] = recurse
             # check file type
             for file in files:
                 if len(file) > 4 and file[-4:] == file_ext:
index dbd63f04daf995b583b9971693b3c996c242ab17..e98a9019fe82f0ad957d841a5e4b6c770981e4a7 100644 (file)
@@ -75,7 +75,7 @@ Avoid using text mode for unicode symbols representable in math mode (bug 9616).
 
 * INTERNALS
 
-
+- Fix TeX file listing with the Nix package manager.