diff --git a/src/ChangeLog b/src/ChangeLog index f92642fd92..947c041013 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2006-05-05 Jean-Marc Lasgouttes + + * lyx_main.C (init): call queryUserLyXDir just after reading + lyxrc.dist, but before reading lyxrc.defaults; add extra_prefix to + the PATH before reconfiguring. + (needsUpdate): new helper function; returns true if file does not + exist or is older than configure.py. + (queryUserLyXDir): check textclass.lst and packages.lst in + addition to lyxrc.defaults. + (reconfigureUserLyXDir): use SystemCall, since system() does not + wait on windows. + 2006-04-28 Jean-Marc Lasgouttes * lyx_main.C (readRcFile): do not report an error if file is not diff --git a/src/lyx_main.C b/src/lyx_main.C index 0d0194127b..e19c0a942e 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -51,6 +51,7 @@ #include "support/os.h" #include "support/package.h" #include "support/path.h" +#include "support/systemcall.h" #include #include @@ -72,6 +73,7 @@ using lyx::support::Path; using lyx::support::prependEnvPath; using lyx::support::QuoteName; using lyx::support::rtrim; +using lyx::support::Systemcall; namespace os = lyx::support::os; namespace fs = boost::filesystem; @@ -120,7 +122,8 @@ void reconfigureUserLyXDir() lyxerr << _("LyX: reconfiguring user directory") << endl; Path p(package().user_support()); - ::system(configure_command.c_str()); + Systemcall one; + one.startscript(Systemcall::Wait, configure_command); lyxerr << "LyX: " << _("Done!") << endl; } @@ -401,16 +404,6 @@ void LyX::init(bool gui) signal(SIGTERM, error_handler); // SIGPIPE can be safely ignored. - // Check that user LyX directory is ok. We don't do that if - // running in batch mode. - bool reconfigure = false; - if (gui) { - reconfigure = - queryUserLyXDir(package().explicit_user_support()); - } else { - first_start = false; - } - // Disable gui when easyparse says so lyx_gui::use_gui = gui; @@ -439,6 +432,26 @@ void LyX::init(bool gui) // This one may have been distributed along with LyX. readRcFile("lyxrc.dist"); + + // Set the PATH correctly. +#if !defined (USE_POSIX_PACKAGING) + // Add the directory containing the LyX executable to the path + // so that LyX can find things like tex2lyx. + if (package().build_support().empty()) + prependEnvPath("PATH", package().binary_dir()); +#endif + if (!lyxrc.path_prefix.empty()) + prependEnvPath("PATH", lyxrc.path_prefix); + + // Check that user LyX directory is ok. We don't do that if + // running in batch mode. + if (gui) { + if (queryUserLyXDir(package().explicit_user_support())) + reconfigureUserLyXDir(); + } else { + first_start = false; + } + // This one is generated in user_support directory by lib/configure.py. readRcFile("lyxrc.defaults"); @@ -475,18 +488,6 @@ void LyX::init(bool gui) if (!lyxrc.path_prefix.empty()) prependEnvPath("PATH", lyxrc.path_prefix); -#if !defined (USE_POSIX_PACKAGING) - // Add the directory containing the LyX executable to the path - // so that LyX can find things like tex2lyx. - if (package().build_support().empty()) - prependEnvPath("PATH", package().binary_dir()); -#endif - - // Having reset the PATH we're now in a position to run configure - // if necessary. - if (reconfigure) - reconfigureUserLyXDir(); - if (fs::exists(lyxrc.document_path) && fs::is_directory(lyxrc.document_path)) package().document_dir() = lyxrc.document_path; @@ -609,25 +610,34 @@ void LyX::deadKeyBindings(kb_keymap * kbmap) } +namespace { + +// return true if file does not exist or is older than configure.py. +bool needsUpdate(string const & file) +{ + static string const configure_script = + AddName(package().system_support(), "configure.py"); + string const absfile = + AddName(package().user_support(), file); + + return (! fs::exists(absfile)) + || (fs::last_write_time(configure_script) + > fs::last_write_time(absfile)); +} + +} + + bool LyX::queryUserLyXDir(bool explicit_userdir) { - bool reconfigure = false; - // Does user directory exist? if (fs::exists(package().user_support()) && fs::is_directory(package().user_support())) { first_start = false; - string const configure_script = - AddName(package().system_support(), "configure.py"); - string const userDefaults = - AddName(package().user_support(), "lyxrc.defaults"); - if (fs::exists(configure_script) && - fs::exists(userDefaults) && - fs::last_write_time(configure_script) - > fs::last_write_time(userDefaults)) { - reconfigure = true; - } - return reconfigure; + + return needsUpdate("lyxrc.defaults") + || needsUpdate("textclass.lst") + || needsUpdate("packages.lst"); } first_start = !explicit_userdir; @@ -651,7 +661,6 @@ bool LyX::queryUserLyXDir(bool explicit_userdir) lyxerr << bformat(_("LyX: Creating directory %1$s"), package().user_support()) << endl; - reconfigure = true; if (!createDirectory(package().user_support(), 0755)) { // Failed, so let's exit. @@ -660,7 +669,7 @@ bool LyX::queryUserLyXDir(bool explicit_userdir) exit(1); } - return reconfigure; + return true; } diff --git a/status.14x b/status.14x index e7443f3d2b..7cebc33767 100644 --- a/status.14x +++ b/status.14x @@ -92,8 +92,10 @@ What's new - It is not needed anymore to run lib/configure.py in the main LyX support directory. -- LyX now reads the file lyxrc.init (if it exists) before - lyxrc.defaults and preferences. +- Reading of configuration now goes like this: LyX first reads the file + lyxrc.init (if it exists). If lib/configure.py is newer than + either lyxrc.defaults, textclass.lst or packages.lst, it is re-run + before loading lyxrc.defaults and preferences. - Fix lib/configure.py to find tex2lyx when compiling with --with-version-suffix (bug 2285)