]> git.lyx.org Git - features.git/commitdiff
Make sure a textclass.lst will exist even when configure.py fails. Part of Bug 2829...
authorBo Peng <bpeng@lyx.org>
Wed, 26 Sep 2007 16:26:49 +0000 (16:26 +0000)
committerBo Peng <bpeng@lyx.org>
Wed, 26 Sep 2007 16:26:49 +0000 (16:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20519 a592a061-630c-0410-9148-cb99ea01b6c8

lib/chkconfig.ltx
lib/configure.py

index 76399b4dd7e0ca4a07dcf20f3f7562d67cd8c468..79f063ccaec4fc6dab6dbf9e7a095470649d4e22 100644 (file)
 
 % Initializes the files
 \typeout{\prefix Inspecting your LaTeX configuration.}
-\newwrite{\layouts} \immediate\openout \layouts = textclass.lst
+\newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp
 \newwrite{\sed} \immediate\openout \sed  = chkconfig.sed
 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
-\newwrite{\packages} \immediate\openout \packages = packages.lst
+\newwrite{\packages} \immediate\openout \packages = packages.lst.tmp
 
 \immediate\write\layouts{%
 # This file declares layouts and their associated definition files.^^J%
index 9db8e3a75c17359f053e206224b8e4eddcd8e3dd..43d1da2f1ef4a69131c0bfc704657c394e52e190 100644 (file)
@@ -593,10 +593,14 @@ def processLayoutFile(file, bool_docbook, bool_linuxdoc):
 def checkLatexConfig(check_config, bool_docbook, bool_linuxdoc):
     ''' Explore the LaTeX configuration '''
     print 'checking LaTeX configuration... ',
-    # First, remove the files that we want to re-create
-    removeFiles(['textclass.lst', 'packages.lst', 'chkconfig.sed'])
-    #
-    if not check_config:
+    # if --without-latex-config is forced, or if there is no previous 
+    # version of textclass.lst, re-generate a default file.
+    if not os.path.isfile('textclass.lst') or not check_config:
+        # remove the files only if we want to regenerate
+        removeFiles(['textclass.lst', 'packages.lst', 'chkconfig.sed'])
+        #
+        # Then, generate a default textclass.lst. In case configure.py
+        # fails, we still have something to start lyx.
         print ' default values'
         print '+checking list of textclasses... '
         tx = open('textclass.lst', 'w')
@@ -626,7 +630,8 @@ def checkLatexConfig(check_config, bool_docbook, bool_linuxdoc):
                 tx.write(processLayoutFile(file, bool_docbook, bool_linuxdoc))
         tx.close()
         print '\tdone'
-    else:
+    # the following will generate textclass.lst.tmp, and packages.lst.tmp
+    if check_config:
         print '\tauto'
         removeFiles(['wrap_chkconfig.ltx', 'chkconfig.vars', \
             'chkconfig.classes', 'chklayouts.tex'])
@@ -684,6 +689,12 @@ def checkLatexConfig(check_config, bool_docbook, bool_linuxdoc):
             pass
         if rmcopy:   # remove the copied file
             removeFiles( [ 'chkconfig.ltx' ] )
+        # if configure successed, move textclass.lst.tmp to textclass.lst
+        # and packages.lst.tmp to packages.lst
+        if os.path.isfile('textclass.lst.tmp') and len(open('textclass.lst.tmp').read()) > 0 \
+            and os.path.isfile('packages.lst.tmp') and len(open('packages.lst.tmp').read()) > 0:
+            shutil.move('textclass.lst.tmp', 'textclass.lst')
+            shutil.move('packages.lst.tmp', 'packages.lst')
 
 
 def createLaTeXConfig():