#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/os.h"
+#include "support/PathChanger.h"
+#include "support/Systemcall.h"
#if defined (USE_WINDOWS_PACKAGING)
# include "support/os_win32.h"
#endif
+#include <iostream>
#include <list>
#if !defined (USE_WINDOWS_PACKAGING) && \
!defined (USE_MACOSX_PACKAGING) && \
+ !defined (USE_HAIKU_PACKAGING) && \
!defined (USE_POSIX_PACKAGING)
-#error USE_FOO_PACKAGING must be defined for FOO = WINDOWS, MACOSX or POSIX.
+#error USE_FOO_PACKAGING must be defined for FOO = WINDOWS, MACOSX, HAIKU or POSIX.
#endif
#if defined (USE_MACOSX_PACKAGING)
Package package_;
bool initialised_ = false;
-} // namespace anon
+} // namespace
void init_package(string const & command_line_arg0,
Package const & package()
{
- LASSERT(initialised_, /**/);
+ LAPPERR(initialised_);
return package_;
}
string const fix_dir_name(string const & name);
-} // namespace anon
+} // namespace
Package::Package(string const & command_line_arg0,
lyx_dir_ = FileName(lyx_dir_.realPath());
// Is LyX being run in-place from the build tree?
- bool in_build_dir = inBuildDir(abs_binary, build_support_dir_, system_support_dir_);
+ in_build_dir_ = inBuildDir(abs_binary, build_support_dir_, system_support_dir_);
- if (!in_build_dir) {
+ if (!in_build_dir_) {
system_support_dir_ =
get_system_support_dir(abs_binary,
command_line_system_support_dir);
- }
+ }
// Find the LyX executable
lyx_binary_ = findLyxBinary(abs_binary);
explicit_user_support_dir_ = userSupportDir(default_user_support_dir,
command_line_user_support_dir, user_support_dir_);
- FileName const configure_script(addName(system_support().absFileName(), "configure.py"));
- configure_command_ = os::python() + ' ' +
- quoteName(configure_script.toFilesystemEncoding(), quote_python) +
- with_version_suffix();
LYXERR(Debug::INIT, "<package>\n"
<< "\tbinary_dir " << binary_dir().absFileName() << '\n'
}
+int Package::reconfigureUserLyXDir(string const & option) const
+{
+ if (configure_command_.empty()) {
+ FileName const configure_script(addName(system_support().absFileName(), "configure.py"));
+ configure_command_ = os::python() + ' ' +
+ quoteName(configure_script.toFilesystemEncoding()) +
+ with_version_suffix() + " --binary-dir=" +
+ quoteName(FileName(binary_dir().absFileName()).toFilesystemEncoding());
+ }
+
+ lyxerr << to_utf8(_("LyX: reconfiguring user directory")) << endl;
+ PathChanger p(user_support());
+ Systemcall one;
+ int const ret = one.startscript(Systemcall::Wait, configure_command_ + option);
+ lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;
+ return ret;
+}
+
+
+string Package::getConfigureLockName() const
+{
+ return addName(user_support().absFileName(), ".lyx_configure_lock");
+}
+
+
void Package::set_temp_dir(FileName const & temp_dir) const
{
if (temp_dir.empty())
temp_dir_ = temp_dir;
}
+
+FileName Package::messages_file(string const & c) const
+{
+ if (in_build_dir_) {
+ FileName res = FileName(lyx_dir().absFileName() + "/po/" + c + ".gmo");
+ if (!res.isReadableFile())
+ res = FileName(lyx_dir().absFileName() + "../po/" + c + ".gmo");
+ if (!res.isReadableFile())
+ res = FileName(top_srcdir().absFileName() + "/po/" + c + ".gmo");
+ return res;
+ } else
+ return FileName(locale_dir_.absFileName() + "/" + c
+ + "/LC_MESSAGES/" PACKAGE ".mo");
+}
+
+
// The specification of home_dir_ is fixed for a given OS.
// A typical example on Windows: "C:/Documents and Settings/USERNAME"
// and on a Posix-like machine: "/home/USERNAME".
return program_suffix.empty() ? program_suffix : with_version_suffix;
}
-} // namespace anon
+} // namespace
FileName const & Package::top_srcdir()
return true;
}
// cmake file, no Makefile in lib
- FileName build_boost_dir = FileName(addPath(search_dir, "boost"));
- if (!fileSearch(build_boost_dir.absFileName(), "cmake_install.cmake").empty()) {
+ FileName build_src_dir = FileName(addPath(search_dir, "src"));
+ if (!fileSearch(build_src_dir.absFileName(), "cmake_install.cmake").empty()) {
return true;
}
// Note that the name of the lyx binary may be a symbolic link.
// If that is the case, then we follow the links too.
- FileName binary = abs_binary;
+ FileName binary = abs_binary;
while (true) {
// Try and find "lyxrc.defaults".
- if( isBuildDir(binary, "../", build_support_dir) ||
- isBuildDir(binary, "../../", build_support_dir))
- {
+ if ( isBuildDir(binary, "../", build_support_dir)
+ || isBuildDir(binary, "../../", build_support_dir))
+ {
// Try and find "chkconfig.ltx".
system_support_dir =
FileName(addPath(Package::top_srcdir().absFileName(), "lib"));
system_support_dir = FileName();
build_support_dir = FileName();
- return false;
+ return false;
}
bool lyxBinaryPath(FileName & lyx_binary, string const & search_dir, string const & ext)
{
lyx_binary = FileName();
- if(false) {
+ if(false) {
} else if (doesFileExist(lyx_binary, search_dir, "lyx" + ext)) {
} else if (doesFileExist(lyx_binary, search_dir, "LyX" + ext)) {
} else if (doesFileExist(lyx_binary, search_dir, "lyx" + string(PROGRAM_SUFFIX) + ext)) {
else if (!abs_binary.extension().empty()) {
ext = "." + abs_binary.extension();
}
-
+
string binary_dir = onlyPath(abs_binary.absFileName());
-
+
FileName lyx_binary;
if (lyxBinaryPath(lyx_binary, binary_dir, ext))
return lyx_binary;
string search_dir = onlyPath(FileName(addPath(binary_dir, "/../")).absFileName());
if (lyxBinaryPath(lyx_binary, search_dir, ext))
return lyx_binary;
-
+
return FileName();
}
(void)home_dir; // Silence warning about unused variable.
os::GetFolderPath win32_folder_path;
return FileName(win32_folder_path(os::GetFolderPath::PERSONAL));
+#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
+ (void)home_dir; // Silence warning about unused variable.
+ return FileName(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)));
#elif defined (USE_MACOSX_PACKAGING)
(void)home_dir; // Silence warning about unused variable.
return FileName(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)));
// This will do nothing if *it is already absolute.
string const exe_dir = makeAbsPath(*it).absFileName();
- FileName const exe_path(addName(exe_dir, exe_name));
- if (exe_path.exists())
- return exe_path;
+ FileName const exe_path2(addName(exe_dir, exe_name));
+ if (exe_path2.exists())
+ return exe_path2;
}
// Didn't find anything.
"to the LyX system directory containing the "
"file `chkconfig.ltx'."),
from_utf8(searched_dirs_str), from_ascii(LYX_DIR_VER)));
-
- // Keep the compiler happy.
- return FileName();
}
os::GetFolderPath win32_folder_path;
return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE));
+#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
+ (void)home_dir; // Silence warning about unused variable.
+ return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)), PACKAGE));
+
#elif defined (USE_MACOSX_PACKAGING)
(void)home_dir; // Silence warning about unused variable.
return FileName(addPath(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), PACKAGE));
+#elif defined (USE_HAIKU_PACKAGING)
+ return FileName(addPath(home_dir.absFileName(), string("/config/settings/") + PACKAGE));
+
#else // USE_POSIX_PACKAGING
return FileName(addPath(home_dir.absFileName(), string(".") + PACKAGE));
#endif
return result;
}
-} // namespace anon
+} // namespace
} // namespace support
} // namespace lyx