Aspell lib loading: use simple name for the lib and let the system work instead of trying to guess the path. Fixes problem with multi-arch aspell on Debian Jessie

This commit is contained in:
Jean-Francois Dockes 2014-12-06 16:22:41 +01:00
parent 13570505b1
commit b11f66cb80
2 changed files with 22 additions and 32 deletions

View file

@ -151,34 +151,16 @@ bool Aspell::init(string &reason)
return false; return false;
} }
// We first look for the aspell library in libdir, and also try to
// be clever with ASPELL_PROG.
vector<string> libdirs;
libdirs.push_back(LIBDIR);
// If not in the standard place, the aspell library has to live
// under the same prefix as the aspell program.
{
string aspellPrefix = path_getfather(path_getfather(m_data->m_exec));
// This would probably require some more tweaking on solaris/irix etc.
string dir = sizeof(long) > 4 ? "lib64" : "lib";
string libaspell = path_cat(aspellPrefix, dir);
if (libaspell != LIBDIR)
libdirs.push_back(libaspell);
}
reason = "Could not open shared library "; reason = "Could not open shared library ";
for (vector<string>::iterator it = libdirs.begin(); string libbase("libaspell");
it != libdirs.end(); it++) { string lib;
string libbase = path_cat(*it, "libaspell"); for (unsigned int i = 0; i < nlibsuffs; i++) {
string lib; lib = libbase + aspell_lib_suffixes[i];
for (unsigned int i = 0; i < nlibsuffs; i++) { reason += string("[") + lib + "] ";
lib = libbase + aspell_lib_suffixes[i]; if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) != 0) {
reason += string("[") + lib + "] "; reason.erase();
if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) != 0) { goto found;
reason.erase(); }
goto found;
}
}
} }
found: found:
@ -288,13 +270,19 @@ bool Aspell::buildDict(Rcl::Db &db, string &reason)
// We create the dictionary by executing the aspell command: // We create the dictionary by executing the aspell command:
// aspell --lang=[lang] create master [dictApath] // aspell --lang=[lang] create master [dictApath]
string cmdstring(m_data->m_exec);
ExecCmd aspell; ExecCmd aspell;
vector<string> args; vector<string> args;
args.push_back(string("--lang=")+ m_lang); args.push_back(string("--lang=")+ m_lang);
cmdstring += string(" ") + string("--lang=") + m_lang;
args.push_back("--encoding=utf-8"); args.push_back("--encoding=utf-8");
cmdstring += string(" ") + "--encoding=utf-8";
args.push_back("create"); args.push_back("create");
cmdstring += string(" ") + "create";
args.push_back("master"); args.push_back("master");
cmdstring += string(" ") + "master";
args.push_back(dicPath()); args.push_back(dicPath());
cmdstring += string(" ") + dicPath();
// Have to disable stderr, as numerous messages about bad strings are // Have to disable stderr, as numerous messages about bad strings are
// printed. We'd like to keep errors about missing databases though, so // printed. We'd like to keep errors about missing databases though, so
@ -328,14 +316,17 @@ bool Aspell::buildDict(Rcl::Db &db, string &reason)
} }
if (hasdict) if (hasdict)
reason = string( reason = string(
"\naspell dictionary creation command failed. Reason unknown.\n" "\naspell dictionary creation command [") +
cmdstring + string("] failed. Reason unknown.\n"
"Try to set aspellKeepStderr = 1 in recoll.conf, and execute \n" "Try to set aspellKeepStderr = 1 in recoll.conf, and execute \n"
"the indexing command in a terminal to see the aspell " "the indexing command in a terminal to see the aspell "
"diagnostic output.\n"); "diagnostic output.\n");
else else
reason = string("aspell dictionary creation command failed.\n" reason = string("aspell dictionary creation command failed:\n") +
"One possible reason might be missing language " cmdstring + "\n"
"data files for lang = ") + m_lang; "One possible reason might be missing language "
"data files for lang = " + m_lang +
". Maybe try to execute the command by hand for a better diag.";
return false; return false;
} }
db.termWalkClose(tit); db.termWalkClose(tit);

View file

@ -32,7 +32,6 @@ RECOLL_DATADIR = ${datadir}/recoll
LOCALCXXFLAGS = -Wall -Wno-unused \ LOCALCXXFLAGS = -Wall -Wno-unused \
$(INCICONV) $(XAPIANCXXFLAGS) $(X_CFLAGS) \ $(INCICONV) $(XAPIANCXXFLAGS) $(X_CFLAGS) \
-DRECOLL_DATADIR=\"$(RECOLL_DATADIR)\" \ -DRECOLL_DATADIR=\"$(RECOLL_DATADIR)\" \
-DLIBDIR=\"$(libdir)\" \
$(PICFLAGS) \ $(PICFLAGS) \
@DEFS@ @DEFS@