Sync the 13x and 14x trees.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10015 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2005-06-08 13:41:02 +00:00
parent 75a5ef3c61
commit 279e74de66
7 changed files with 251 additions and 55 deletions

View File

@ -0,0 +1,3 @@
*.dvi
*.dtl
*.log

View File

@ -263,7 +263,7 @@
Abort ; Return to the page
go_on:
${ReadDownloadValues} ${DoNotRequire} ${Download} $0 ${FolderPath}
${ReadDownloadValues} ${DoNotRequire} ${Download} $0 ${FolderPath}
${if} ${DoNotRequire} == 1
;

View File

@ -209,11 +209,16 @@ Section "-Installation actions" SecInstallation
File /r "${PRODUCT_SOURCEDIR}\bin"
${if} "$PathPrefix" != ""
lyx_path_prefix::set "$INSTDIR\Resources\lyx\configure" "$PathPrefix"
lyx_path_prefix::set_path_prefix "$INSTDIR\Resources\lyx\configure" "$PathPrefix"
Pop $0
${if} $0 != 0
MessageBox MB_OK "$(ModifyingConfigureFailed)"
${endif}
lyx_path_prefix::run_configure "$INSTDIR\Resources\lyx\configure" "$PathPrefix"
Pop $0
${if} $0 != 0
MessageBox MB_OK "$(RunConfigureFailed)"
${endif}
${endif}
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
@ -296,6 +301,8 @@ FunctionEnd
;--------------------------------
Function DownloadMinSYS
StrCpy $MinSYSPath ""
StrCpy $DownloadMinSYS "0"
; Search the registry for the MinSYS uninstaller.
; If successful, put its location in $2.
@ -343,6 +350,9 @@ FunctionEnd
;--------------------------------
Function DownloadPython
StrCpy $PythonPath ""
StrCpy $DownloadPython "0"
${DownloadEnter} \
$PythonPath "Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe" "" \
"\Python.exe" "" \
@ -367,6 +377,10 @@ FunctionEnd
;--------------------------------
Function DownloadMiKTeX
StrCpy $DoNotRequireMiKTeX "1"
StrCpy $MiKTeXPath ""
StrCpy $DownloadMiKTeX "0"
${DownloadEnter} \
$MiKTeXPath "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root" \
"" "\miktex\bin" \
@ -391,6 +405,10 @@ FunctionEnd
;--------------------------------
Function DownloadPerl
StrCpy $DoNotRequirePerl "1"
StrCpy $PerlPath ""
StrCpy $DownloadPerl "1"
${DownloadEnter} \
$PerlPath "Software\Perl" BinDir \
"\perl.exe" "" \
@ -415,6 +433,9 @@ FunctionEnd
;--------------------------------
Function DownloadGhostscript
StrCpy $DoNotRequireGhostscript "1"
StrCpy $GhostscriptPath ""
StrCpy $DownloadGhostscript "0"
; Find which version of ghostscript, if any, is installed.
EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
@ -448,6 +469,10 @@ FunctionEnd
;--------------------------------
Function DownloadImageMagick
StrCpy $DoNotRequireImageMagick "1"
StrCpy $ImageMagickPath ""
StrCpy $DownloadImageMagick "0"
${DownloadEnter} \
$ImageMagickPath "Software\ImageMagick\Current" "BinPath" \
"" "" \

View File

@ -18,6 +18,7 @@ LangString SecFileAssocDescription "${LYX_LANG}" "Create associations between th
LangString SecDesktopDescription "${LYX_LANG}" "A ${PRODUCT_NAME} icon on the desktop."
LangString ModifyingConfigureFailed "${LYX_LANG}" "Failed attempting to set 'path_prefix' in the configure script"
LangString RunConfigureFailed "${LYX_LANG}" "Failed attempting to execute the configure script"
LangString FinishPageMessage "${LYX_LANG}" "Congratulations! LyX has been installed successfully."
LangString FinishPageRun "${LYX_LANG}" "Launch LyX"
@ -26,8 +27,8 @@ LangString DownloadPageField2 "${LYX_LANG}" "&Do not install"
LangString MinSYSHeader "${LYX_LANG}" "MinSYS"
LangString MinSYSDescription "${LYX_LANG}" "MinSYS is a minimal unix scripting environment (www.mingw.org/msys.shtml) which ${PRODUCT_NAME} needs to run a number of scripts."
LangString EnterMinSYSFolder "${LYX_LANG}" "Please input the path to the folder containing MinSYS.exe"
LangString InvalidMinSYSFolder "${LYX_LANG}" "Unable to find MinSYS.exe"
LangString EnterMinSYSFolder "${LYX_LANG}" "Please input the path to the folder containing sh.exe"
LangString InvalidMinSYSFolder "${LYX_LANG}" "Unable to find sh.exe"
LangString MinSYSDownloadLabel "${LYX_LANG}" "&Download MinSYS"
LangString MinSYSFolderLabel "${LYX_LANG}" "&Folder containing sh.exe"

View File

@ -14,11 +14,12 @@ LangString SecFileAssocTitle "${LYX_LANG}" "Associations de fichiers"
LangString SecDesktopTitle "${LYX_LANG}" "Icône du bureau"
LangString SecCoreDescription "${LYX_LANG}" "Les fichiers ${PRODUCT_NAME}"
LangString SecAllUsersDescription "${LYX_LANG}" "Installer pour tous les utilisateurs, ou seulement pour l'utilisateur courant (nécessite les droits d'administrateur) ?."
LangString SecAllUsersDescription "${LYX_LANG}" "Installer pour tous les utilisateurs (nécessite les droits d'administrateur), ou seulement pour l'utilisateur courant ?."
LangString SecFileAssocDescription "${LYX_LANG}" "Crée les associations entre l'exécutable et le suffixe .lyx."
LangString SecDesktopDescription "${LYX_LANG}" "Une icône ${PRODUCT_NAME} sur le bureau."
LangString ModifyingConfigureFailed "${LYX_LANG}" "Échec de l'allocation 'path_prefix' dans le script de configuration."
LangString ModifyingConfigureFailed "${LYX_LANG}" "Échec de l'allocation 'path_prefix' lors de la configuration."
LangString RunConfigureFailed "${LYX_LANG}" "Failed attempting to execute the configure script"
LangString FinishPageMessage "${LYX_LANG}" "Félicitations ! LyX est installé avec succès."
LangString FinishPageRun "${LYX_LANG}" "Démarrer LyX"
@ -26,14 +27,14 @@ LangString FinishPageRun "${LYX_LANG}" "D
LangString DownloadPageField2 "${LYX_LANG}" "&Ne pas installer"
LangString MinSYSHeader "${LYX_LANG}" "MinSYS"
LangString MinSYSDescription "${LYX_LANG}" "MinSYS est un environnement minimal pour gérer des fichiers de commande (www.mingw.org/msys.shtml) dont ${PRODUCT_NAME} a besoin pour exécuter un certain nombre de commandes."
LangString EnterMinSYSFolder "${LYX_LANG}" "Merci de saisir le chemin conduisant au répertoire où se trouve MinSYS.exe"
LangString InvalidMinSYSFolder "${LYX_LANG}" "MinSYS.exe introuvable"
LangString MinSYSDescription "${LYX_LANG}" "MinSYS est un environnement minimal pour gérer des commandes (www.mingw.org/msys.shtml) dont ${PRODUCT_NAME} a besoin pour ses traitements."
LangString EnterMinSYSFolder "${LYX_LANG}" "Merci de saisir le chemin conduisant au répertoire où se trouve sh.exe"
LangString InvalidMinSYSFolder "${LYX_LANG}" "sh.exe introuvable"
LangString MinSYSDownloadLabel "${LYX_LANG}" "&Télécharger MinSYS"
LangString MinSYSFolderLabel "${LYX_LANG}" "&Répertoire contenant sh.exe"
LangString PythonHeader "${LYX_LANG}" "Python"
LangString PythonDescription "${LYX_LANG}" "Le language de scripting Python (www.python.org) doit être installé ou ${PRODUCT_NAME} ne pourra pas exécuter un certain nombre de commandes."
LangString PythonDescription "${LYX_LANG}" "Le langage de commandes Python (www.python.org) doit être installé ou ${PRODUCT_NAME} ne pourra pas exécuter un certain nombre de commandes."
LangString EnterPythonFolder "${LYX_LANG}" "Merci de saisir le chemin conduisant au répertoire où se trouve Python.exe"
LangString InvalidPythonFolder "${LYX_LANG}" "Python.exe introuvable"
LangString PythonDownloadLabel "${LYX_LANG}" "&Télécharger Python"
@ -47,7 +48,7 @@ LangString MiKTeXDownloadLabel "${LYX_LANG}" "&T
LangString MiKTeXFolderLabel "${LYX_LANG}" "&Répertoire contenant latex.exe"
LangString PerlHeader "${LYX_LANG}" "Perl"
LangString PerlDescription "${LYX_LANG}" "Si vous avez l'intention d'utilier reLyX pour convertir des documents LaTeX en LyX, vous devez installer Perl (www.perl.com)."
LangString PerlDescription "${LYX_LANG}" "Si vous avez l'intention d'utiliser reLyX pour convertir des documents LaTeX en LyX, vous devez installer Perl (www.perl.com)."
LangString EnterPerlFolder "${LYX_LANG}" "Merci de saisir le chemin conduisant au répertoire où se trouve Perl.exe"
LangString InvalidPerlFolder "${LYX_LANG}" "Perl.exe introuvable"
LangString PerlDownloadLabel "${LYX_LANG}" "&Télécharger Perl"

View File

@ -18,6 +18,7 @@ LangString SecFileAssocDescription "${LYX_LANG}" "Create associations between th
LangString SecDesktopDescription "${LYX_LANG}" "A ${PRODUCT_NAME} icon on the desktop."
LangString ModifyingConfigureFailed "${LYX_LANG}" "Failed attempting to set 'path_prefix' in the configure script"
LangString RunConfigureFailed "${LYX_LANG}" "Failed attempting to execute the configure script"
LangString FinishPageMessage "${LYX_LANG}" "Congratulations! LyX has been installed successfully."
LangString FinishPageRun "${LYX_LANG}" "Launch LyX"
@ -26,8 +27,8 @@ LangString DownloadPageField2 "${LYX_LANG}" "&Do not install"
LangString MinSYSHeader "${LYX_LANG}" "MinSYS"
LangString MinSYSDescription "${LYX_LANG}" "MinSYS is a minimal unix scripting environment (www.mingw.org/msys.shtml) which ${PRODUCT_NAME} needs to run a number of scripts."
LangString EnterMinSYSFolder "${LYX_LANG}" "Please input the path to the folder containing MinSYS.exe"
LangString InvalidMinSYSFolder "${LYX_LANG}" "Unable to find MinSYS.exe"
LangString EnterMinSYSFolder "${LYX_LANG}" "Please input the path to the folder containing sh.exe"
LangString InvalidMinSYSFolder "${LYX_LANG}" "Unable to find sh.exe"
LangString MinSYSDownloadLabel "${LYX_LANG}" "&Download MinSYS"
LangString MinSYSFolderLabel "${LYX_LANG}" "&Folder containing sh.exe"

View File

@ -18,7 +18,7 @@
* Compile the code with
*
* g++ -I/c/Program\ Files/NSIS/Contrib -Wall -shared \
* lyx_path_prefix.c -o lyx_path_prefix.dll
* lyx_path_prefix.C -o lyx_path_prefix.dll
*
* Move resulting .dll to /c/Program\ Files/NSIS/Plugins
*/
@ -29,6 +29,8 @@
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
namespace {
@ -42,12 +44,154 @@ std::string const subst(std::string const & a,
std::string::size_type const olen = oldstr.length();
while ((i = lstr.find(oldstr, i)) != std::string::npos) {
lstr.replace(i, olen, newstr);
i += newstr.length(); // We need to be sure that we dont
// use the same i over and over again.
i += newstr.length();
}
return lstr;
}
std::string const basename(std::string const & path)
{
std::string::size_type const final_slash = path.find_last_of('\\');
if (final_slash == std::string::npos)
return path;
return path.substr(final_slash+1);
}
std::string const dirname(std::string const & path)
{
std::string::size_type const final_slash = path.find_last_of('\\');
if (final_slash == std::string::npos)
return std::string();
return path.substr(0, final_slash);
}
std::string const pop_from_stack()
{
char data[10*MAX_PATH];
popstring(data);
return data;
}
std::list<std::string> const tokenize(std::string data,
char const separator)
{
std::list<std::string> result;
while (true) {
std::string::size_type const end = data.find(separator);
if (end == std::string::npos) {
result.push_back(data);
break;
}
result.push_back(data.substr(0, end));
data = data.substr(end+1);
}
return result;
}
void remove_duplicates(std::list<std::string> & data)
{
typedef std::list<std::string>::iterator iterator;
for (iterator it = data.begin(); it != data.end(); ++it) {
iterator next = it;
++next;
if (next == data.end())
break;
iterator end = std::remove(next, data.end(), *it);
data.erase(end, data.end());
}
}
std::string concatenate(std::list<std::string> const & data,
char const separator)
{
typedef std::list<std::string>::const_iterator iterator;
iterator it = data.begin();
iterator const end = data.end();
if (it == end)
return std::string();
std::ostringstream result;
result << *it;
++it;
for (; it != end; ++it) {
result << separator << *it;
}
return result.str();
}
std::string const sanitize_path(std::string const & in)
{
// Replace multiple, adjacent directory separators.
std::string out = subst(in, "\\\\", "\\");
std::list<std::string> out_list = tokenize(out, ';');
remove_duplicates(out_list);
return concatenate(out_list, ';');
}
bool replace_path_prefix(std::string & data,
std::string::size_type prefix_pos,
std::string const & path_prefix)
{
std::string::size_type start_prefix =
data.find_first_of('"', prefix_pos);
if (start_prefix == std::string::npos)
return false;
start_prefix += 1;
std::string::size_type end_line =
data.find_first_of('\n', prefix_pos);
if (end_line == std::string::npos)
return false;
std::string::size_type end_prefix =
data.find_last_of('"', end_line);
if (end_prefix == std::string::npos || end_prefix == start_prefix)
return false;
std::string::size_type const count = end_prefix - start_prefix;
std::string const old_prefix = data.substr(start_prefix, count);
std::string const prefix =
subst(sanitize_path(path_prefix + ';' + old_prefix), "\\", "\\\\");
data.erase(start_prefix, count);
data.insert(start_prefix, prefix);
return true;
}
bool insert_path_prefix(std::string & data,
std::string::size_type xfonts_pos,
std::string const & path_prefix)
{
std::string::size_type const xfonts_start =
data.find_last_of('\n', xfonts_pos);
if (xfonts_start == std::string::npos)
return false;
std::string const prefix = subst(sanitize_path(path_prefix), "\\", "\\\\");
std::ostringstream ss;
ss << data.substr(0, xfonts_start)
<< "\n"
"cat >>$outfile <<EOF\n"
"\n"
"\\\\path_prefix \"" << prefix << "\"\n"
"EOF\n"
<< data.substr(xfonts_start);
data = ss.str();
return true;
}
} // namespace anon
@ -57,76 +201,97 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
}
// Inserts code into "configure" to output "path_prefix" to lyxrc.defaults.
extern "C"
void __declspec(dllexport) set(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
void __declspec(dllexport) set_path_prefix(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
{
char configure_file[MAX_PATH];
char path_prefix[MAX_PATH];
EXDLL_INIT();
popstring(configure_file);
popstring(path_prefix);
std::string const configure_file = pop_from_stack();
std::string const path_prefix = pop_from_stack();
std::fstream fs(configure_file);
if (!fs) {
std::ifstream ifs(configure_file.c_str());
if (!ifs) {
pushstring("-1");
return;
}
std::istreambuf_iterator<char> const begin(fs);
std::istreambuf_iterator<char> const end;
std::istreambuf_iterator<char> const begin_ifs(ifs);
std::istreambuf_iterator<char> const end_ifs;
std::string configure_data(begin_ifs, end_ifs);
ifs.close();
std::string configure_data(begin, end);
std::string::size_type const xfonts_pos = configure_data.find("X FONTS");
if (xfonts_pos == std::string::npos) {
// Does configure already contain a "path_prefix" entry
// or should we insert one?
std::string::size_type const prefix_pos =
configure_data.find("path_prefix");
if (prefix_pos != std::string::npos) {
if (!replace_path_prefix(configure_data, prefix_pos, path_prefix)) {
pushstring("-1");
return;
}
} else {
std::string::size_type const xfonts_pos =
configure_data.find("X FONTS");
if (xfonts_pos == std::string::npos) {
pushstring("-1");
return;
}
if (!insert_path_prefix(configure_data, xfonts_pos, path_prefix)) {
pushstring("-1");
return;
}
}
std::ofstream ofs(configure_file.c_str());
if (!ofs) {
pushstring("-1");
return;
}
std::string::size_type const xfonts_start =
configure_data.find_last_of('\n', xfonts_pos);
if (xfonts_start == std::string::npos) {
ofs << configure_data;
pushstring("0");
}
// Runs "sh configure" to generate things like lyxrc.defaults.
extern "C"
void __declspec(dllexport) run_configure(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
{
EXDLL_INIT();
std::string configure_file = pop_from_stack();
std::string const path_prefix = pop_from_stack();
std::string const configure_dir = dirname(configure_file);
configure_file = basename(configure_file);
if (configure_dir.empty()) {
pushstring("-1");
return;
}
fs.seekg(0);
fs << configure_data.substr(0, xfonts_start)
<< "\n"
"cat >>$outfile <<EOF\n"
"\n"
"\\\\path_prefix \"" << subst(path_prefix, "\\", "\\\\") << "\"\n"
"EOF\n"
<< configure_data.substr(xfonts_start);
// Now we've rebuilt configure, run it to generate things like
// lyxrc.defaults.
std::string configure_dir(configure_file);
std::string::size_type const final_slash = configure_dir.find_last_of('\\');
if (final_slash == std::string::npos) {
pushstring("-1");
return;
}
configure_dir = configure_dir.substr(0, final_slash);
if (SetCurrentDirectory(configure_dir.c_str()) == 0) {
pushstring("-1");
return;
}
char path[MAX_PATH];
if (GetEnvironmentVariable("PATH", path, MAX_PATH) == 0) {
char path_orig[10*MAX_PATH];
if (GetEnvironmentVariable("PATH", path_orig, 10*MAX_PATH) == 0) {
pushstring("-1");
return;
}
std::string const path_str = std::string(path_prefix) + ';' + path;
if (SetEnvironmentVariable("PATH", path_str.c_str()) == 0) {
std::string const path = path_prefix + ';' + path_orig;
if (SetEnvironmentVariable("PATH", path.c_str()) == 0) {
pushstring("-1");
return;
}
if (system("start /min sh.exe configure") != 0) {
std::string const command = std::string("start /WAIT /B sh.exe ") + configure_file;
if (system(command.c_str()) != 0) {
pushstring("-1");
return;
}