# \author Bo Peng
# Full author contact details are available in file CREDITS.
-import glob, logging, os, re, shutil, subprocess, sys
+import glob, logging, os, re, shutil, subprocess, sys, stat
# set up logging
logging.basicConfig(level = logging.DEBUG,
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')
+def copy_tree(src, dst, preserve_symlinks=False, level=0):
+ ''' Copy an entire directory tree 'src' to a new location 'dst'.
+
+ Code inspired from distutils.copy_tree.
+ Copying ignores non-regular files and the cache directory.
+ Pipes may be present as leftovers from LyX for lyx-server.
+
+ If 'preserve_symlinks' is true, symlinks will be
+ copied as symlinks (on platforms that support them!); otherwise
+ (the default), the destination of the symlink will be copied.
+ '''
+
+ if not os.path.isdir(src):
+ raise FileError, \
+ "cannot copy tree '%s': not a directory" % src
+ try:
+ names = os.listdir(src)
+ except os.error, (errno, errstr):
+ raise FileError, \
+ "error listing files in '%s': %s" % (src, errstr)
+
+ if not os.path.isdir(dst):
+ os.makedirs(dst)
+
+ outputs = []
+
+ for name in names:
+ src_name = os.path.join(src, name)
+ dst_name = os.path.join(dst, name)
+ if preserve_symlinks and os.path.islink(src_name):
+ link_dest = os.readlink(src_name)
+ os.symlink(link_dest, dst_name)
+ outputs.append(dst_name)
+ elif level == 0 and name == 'cache':
+ logger.info("Skip cache %s", src_name)
+ elif os.path.isdir(src_name):
+ outputs.extend(
+ copy_tree(src_name, dst_name, preserve_symlinks, level=(level + 1)))
+ elif stat.S_ISREG(os.stat(src_name).st_mode) or os.path.islink(src_name):
+ shutil.copy2(src_name, dst_name)
+ outputs.append(dst_name)
+ else:
+ logger.info("Ignore non-regular file %s", src_name)
+
+ return outputs
+
+
+def checkUpgrade():
+ ''' Check for upgrade from previous version '''
+ cwd = os.getcwd()
+ basename = os.path.basename( cwd )
+ lyxrc = os.path.join(cwd, outfile)
+ if not os.path.isfile( lyxrc ) and basename.endswith( version_suffix ) :
+ logger.info('Checking for upgrade from previous version.')
+ parent = os.path.dirname(cwd)
+ appname = basename[:(-len(version_suffix))]
+ for version in ['-2.0', '-1.6' ]:
+ logger.debug('Checking for upgrade from previous version ' + version)
+ previous = os.path.join(parent, appname + version)
+ logger.debug('previous = ' + previous)
+ if os.path.isdir( previous ):
+ logger.info('Found directory "%s".', previous)
+ copy_tree( previous, cwd )
+ logger.info('Content copied to directory "%s".', cwd)
+ return
+
+
def createDirectories():
''' Create the build directories if necessary '''
for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
# run platex on chklatex.ltx and check result
if cmdOutput(PLATEX + ' chklatex.ltx').find('pLaTeX2e') != -1:
# We have the Japanese pLaTeX2e
- addToRC(r'\converter platex dvi "%s -kanji=$$E $$i" "latex=platex"' % PLATEX)
+ addToRC(r'\converter platex dvi "%s" "latex=platex"' % PLATEX)
else:
PLATEX = ''
removeFiles(['chklatex.ltx', 'chklatex.log'])
\Format luatex tex "LaTeX (LuaTeX)" "" "" "%%" "document,menu=export" ""
\Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" "document,menu=export" ""
\Format xetex tex "LaTeX (XeTeX)" "" "" "%%" "document,menu=export" ""
+\Format latexclipboard tex "LaTeX (clipboard)" "" "" "%%" "" ""
\Format text txt "Plain text" a "" "%%" "document,menu=export" "text/plain"
\Format text2 txt "Plain text (pstotext)" "" "" "%%" "document" ""
\Format text3 txt "Plain text (ps2ascii)" "" "" "%%" "document" ""
\Format lyx13x 13.lyx "LyX 1.3.x" "" "" "" "document" ""
\Format lyx14x 14.lyx "LyX 1.4.x" "" "" "" "document" ""
\Format lyx15x 15.lyx "LyX 1.5.x" "" "" "" "document" ""
-\Format lyx16x 16.lyx "LyX 1.6.x" "" "" "" "document,menu=export" ""
+\Format lyx16x 16.lyx "LyX 1.6.x" "" "" "" "document" ""
\Format lyx20x 20.lyx "LyX 2.0.x" "" "" "" "document,menu=export" ""
\Format clyx cjklyx "CJK LyX 1.4.x (big5)" "" "" "" "document" ""
\Format jlyx cjklyx "CJK LyX 1.4.x (euc-jp)" "" "" "" "document" ""
path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [in_binary_subdir, in_binary_subdir + version_suffix, in_binary_dir, in_binary_dir + version_suffix, 'tex2lyx' + version_suffix, 'tex2lyx'],
rc_entry = [r'''\converter latex lyx "%% -f $$i $$o" ""
+\converter latexclipboard lyx "%% -fixedenc utf8 -f $$i $$o" ""
\converter literate lyx "%% -n -m noweb -f $$i $$o" ""'''], not_found = 'tex2lyx')
if path == '':
logger.warning("Failed to find tex2lyx on your system.")
checkProg('a Noweb -> LaTeX converter', ['noweave -delay -index $$i > $$o'],
rc_entry = [r'''\converter literate latex "%%" ""
\converter literate pdflatex "%%" ""
+\converter literate xetex "%%" ""
\converter literate luatex "%%" ""'''])
#
checkProg('a Sweave -> LaTeX converter', ['Rscript --verbose --no-save --no-restore $$s/scripts/lyxsweave.R $$p$$i $$p$$o $$e $$r'],
lyx_check_config = True
lyx_kpsewhich = True
outfile = 'lyxrc.defaults'
- lyxrc_fileformat = 11
+ lyxrc_fileformat = 15
rc_entries = ''
lyx_keep_temps = False
version_suffix = ''
logger.error("configure: error: cannot find chkconfig.ltx script")
sys.exit(1)
setEnviron()
+ if sys.platform == 'darwin' and len(version_suffix) > 0:
+ checkUpgrade()
createDirectories()
dtl_tools = checkDTLtools()
## Write the first part of outfile