archrelease: copy trunk to extra-x86_64
[arch-packages.git] / libreoffice-still / repos / extra-x86_64 / firebird-icu70.patch
blobfa0e6783bf6f00884783192f646e21c415fb2cf9
1 From 6a63c3bf47aa190138a696a1e524949eeba031c8 Mon Sep 17 00:00:00 2001
2 From: Alex Peshkoff <alexander.peshkoff@gmail.com>
3 Date: Fri, 7 Sep 2018 17:05:42 +0300
4 Subject: [PATCH] Backported CORE-5908: Enhance dynamic libraries loading
5 related error messages
7 ---
8 src/common/os/darwin/mod_loader.cpp | 13 +++++--
9 src/common/os/mod_loader.h | 14 +++----
10 src/common/os/posix/mod_loader.cpp | 17 ++++++---
11 src/common/os/win32/mod_loader.cpp | 9 ++++-
12 src/common/unicode_util.cpp | 6 +--
13 src/jrd/IntlManager.cpp | 9 +++--
14 src/jrd/flu.cpp | 2 +-
15 src/jrd/fun.epp | 2 +-
16 src/plugins/udr_engine/UdrEngine.cpp | 55 +++++++++++++---------------
17 src/remote/remote.cpp | 2 +-
18 src/yvalve/PluginManager.cpp | 11 ++++--
19 11 files changed, 79 insertions(+), 61 deletions(-)
21 diff --git a/src/common/os/darwin/mod_loader.cpp b/src/common/os/darwin/mod_loader.cpp
22 index b7b6acac09..1556d02cd6 100644
23 --- a/src/common/os/darwin/mod_loader.cpp
24 +++ b/src/common/os/darwin/mod_loader.cpp
25 @@ -87,14 +87,19 @@ void ModuleLoader::doctorModuleExtension(Firebird::PathName& name)
26 #define FB_RTLD_MODE RTLD_LAZY
27 #endif
29 -ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath)
30 +ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const Firebird::PathName& modPath)
32 void* module = dlopen(modPath.c_str(), FB_RTLD_MODE);
33 if (module == NULL)
35 -#ifdef DEBUG_LOADER
36 - fprintf(stderr, "load error: %s: %s\n", modPath.c_str(), dlerror());
37 -#endif // DEBUG_LOADER
38 + if (status)
39 + {
40 + status[0] = isc_arg_gds;
41 + status[1] = isc_random;
42 + status[2] = isc_arg_string;
43 + status[3] = (ISC_STATUS) dlerror();
44 + status[4] = isc_arg_end;
45 + }
46 return 0;
49 diff --git a/src/common/os/mod_loader.h b/src/common/os/mod_loader.h
50 index b57af4ac9f..069ab23039 100644
51 --- a/src/common/os/mod_loader.h
52 +++ b/src/common/os/mod_loader.h
53 @@ -90,11 +90,11 @@ class ModuleLoader
54 /** loadModule is given as a string the path to the module to load. It
55 attempts to load the module. If successful it returns the ModuleLoader::Module
56 object that represents the loaded module in memory and can be used to
57 - perform symbol lookups on the module. If unsuccessful it returns NULL.
58 - It is the callers responsibility to delete the returned module object
59 - when it is no longer needed.
60 + perform symbol lookups on the module. It is the callers responsibility to delete
61 + the returned module object when it is no longer needed.
62 + If unsuccessful it returns NULL. OS-specific error is returned in status parameter.
63 **/
64 - static Module* loadModule(const Firebird::PathName&);
65 + static Module* loadModule(ISC_STATUS* status, const Firebird::PathName&);
67 /** doctorModuleExtension modifies the given path name to add the platform
68 specific module extention. This allows the user to provide the root name
69 @@ -107,14 +107,14 @@ class ModuleLoader
70 /** Almost like loadModule(), but in case of failure invokes doctorModuleExtension()
71 and retries.
72 **/
73 - static Module* fixAndLoadModule(const Firebird::PathName& modName)
74 + static Module* fixAndLoadModule(ISC_STATUS* status, const Firebird::PathName& modName)
76 - Module* mod = loadModule(modName);
77 + Module* mod = loadModule(NULL, modName);
78 if (!mod)
80 Firebird::PathName fixed(modName);
81 doctorModuleExtension(fixed);
82 - mod = loadModule(fixed);
83 + mod = loadModule(status, fixed);
85 return mod;
87 diff --git a/src/common/os/posix/mod_loader.cpp b/src/common/os/posix/mod_loader.cpp
88 index 2b42c59a5c..9c8ba38ddd 100644
89 --- a/src/common/os/posix/mod_loader.cpp
90 +++ b/src/common/os/posix/mod_loader.cpp
91 @@ -72,7 +72,9 @@ void ModuleLoader::doctorModuleExtension(Firebird::PathName& name)
92 Firebird::PathName::size_type pos = name.rfind("." SHRLIB_EXT);
93 if (pos != name.length() - 3)
95 - name += "." SHRLIB_EXT;
96 + pos = name.rfind("." SHRLIB_EXT ".");
97 + if (pos == Firebird::PathName::npos)
98 + name += "." SHRLIB_EXT;
100 pos = name.rfind('/');
101 pos = (pos == Firebird::PathName::npos) ? 0 : pos + 1;
102 @@ -88,14 +90,19 @@ void ModuleLoader::doctorModuleExtension(Firebird::PathName& name)
103 #define FB_RTLD_MODE RTLD_LAZY // save time when loading library
104 #endif
106 -ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath)
107 +ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const Firebird::PathName& modPath)
109 void* module = dlopen(modPath.nullStr(), FB_RTLD_MODE);
110 if (module == NULL)
112 -#ifdef DEV_BUILD
113 -// gds__log("loadModule failed loading %s: %s", modPath.c_str(), dlerror());
114 -#endif
115 + if (status)
117 + status[0] = isc_arg_gds;
118 + status[1] = isc_random;
119 + status[2] = isc_arg_string;
120 + status[3] = (ISC_STATUS) dlerror();
121 + status[4] = isc_arg_end;
123 return 0;
126 diff --git a/src/common/os/win32/mod_loader.cpp b/src/common/os/win32/mod_loader.cpp
127 index 909de85026..2ffdbdfbeb 100644
128 --- a/src/common/os/win32/mod_loader.cpp
129 +++ b/src/common/os/win32/mod_loader.cpp
130 @@ -191,7 +191,7 @@ void ModuleLoader::doctorModuleExtension(PathName& name)
131 name += ".dll";
134 -ModuleLoader::Module* ModuleLoader::loadModule(const PathName& modPath)
135 +ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const PathName& modPath)
137 ContextActivator ctx;
139 @@ -214,6 +214,13 @@ ModuleLoader::Module* ModuleLoader::loadModule(const PathName& modPath)
140 if (!module)
141 module = LoadLibraryEx(modPath.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
143 + if (!module && status)
145 + status[0] = isc_arg_win32;
146 + status[1] = GetLastError();
147 + status[2] = isc_arg_end;
150 // Restore old mode in case we are embedded into user application
151 SetErrorMode(oldErrorMode);
153 diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp
154 index 1850ea2e96..a33f495910 100644
155 --- a/src/common/unicode_util.cpp
156 +++ b/src/common/unicode_util.cpp
157 @@ -233,7 +233,7 @@ class ImplementConversionICU : public UnicodeUtil::ConversionICU, BaseICU
158 PathName filename;
159 formatFilename(filename, ucTemplate, aMajorVersion, aMinorVersion);
161 - module = ModuleLoader::fixAndLoadModule(filename);
162 + module = ModuleLoader::fixAndLoadModule(NULL, filename);
163 if (!module)
164 return;
166 @@ -998,7 +998,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
168 icu = FB_NEW_POOL(*getDefaultMemoryPool()) ICU(majorVersion, minorVersion);
170 - icu->ucModule = ModuleLoader::fixAndLoadModule(filename);
171 + icu->ucModule = ModuleLoader::fixAndLoadModule(NULL, filename);
173 if (!icu->ucModule)
175 @@ -1009,7 +1009,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
177 formatFilename(filename, inTemplate, majorVersion, minorVersion);
179 - icu->inModule = ModuleLoader::fixAndLoadModule(filename);
180 + icu->inModule = ModuleLoader::fixAndLoadModule(NULL, filename);
182 if (!icu->inModule)
184 diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp
185 index b3e37afb61..4c8368ed22 100644
186 --- a/src/jrd/IntlManager.cpp
187 +++ b/src/jrd/IntlManager.cpp
188 @@ -471,15 +471,16 @@ bool IntlManager::initialize()
189 ModuleLoader::Module* mod = NULL;
190 bool exists = modules->exist(filename);
192 + ISC_STATUS_ARRAY status;
193 if (!exists)
195 - mod = ModuleLoader::loadModule(filename);
196 + mod = ModuleLoader::loadModule(status, filename);
197 if (!mod)
199 ModuleLoader::doctorModuleExtension(filename);
200 exists = modules->exist(filename);
201 if (!exists)
202 - mod = ModuleLoader::loadModule(filename);
203 + mod = ModuleLoader::loadModule(status, filename);
207 @@ -512,8 +513,8 @@ bool IntlManager::initialize()
209 else
211 - gds__log((string("Can't load INTL module '") +
212 - filename.c_str() + "'").c_str());
213 + iscLogStatus((string("Can't load INTL module '") +
214 + filename.c_str() + "'").c_str(), status);
215 ok = false;
218 diff --git a/src/jrd/flu.cpp b/src/jrd/flu.cpp
219 index c0b9c453a0..e8a5bd7878 100644
220 --- a/src/jrd/flu.cpp
221 +++ b/src/jrd/flu.cpp
222 @@ -245,7 +245,7 @@ namespace Jrd
223 Arg::Str(initialModule));
226 - ModuleLoader::Module* mlm = ModuleLoader::loadModule(fixedModule);
227 + ModuleLoader::Module* mlm = ModuleLoader::loadModule(NULL, fixedModule);
228 if (mlm)
230 im = FB_NEW_POOL(*getDefaultMemoryPool())
231 diff --git a/src/jrd/fun.epp b/src/jrd/fun.epp
232 index ca964be72b..44fd5dde67 100644
233 --- a/src/jrd/fun.epp
234 +++ b/src/jrd/fun.epp
235 @@ -105,7 +105,7 @@ namespace
237 ModuleLoader::doctorModuleExtension(libName);
239 - ModuleLoader::Module* module = ModuleLoader::loadModule(libName);
240 + ModuleLoader::Module* module = ModuleLoader::loadModule(NULL, libName);
241 if (!module)
243 message.printf("%s library has not been found", libName.c_str());
244 diff --git a/src/plugins/udr_engine/UdrEngine.cpp b/src/plugins/udr_engine/UdrEngine.cpp
245 index 9c64ebee9a..a49ecf4120 100644
246 --- a/src/plugins/udr_engine/UdrEngine.cpp
247 +++ b/src/plugins/udr_engine/UdrEngine.cpp
248 @@ -567,47 +567,42 @@ UdrPluginImpl* Engine::loadModule(ThrowStatusWrapper* status, IRoutineMetadata*
249 PathName path;
250 PathUtils::concatPath(path, *i, *moduleName);
252 - ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(path);
254 - if (module)
256 - FB_BOOLEAN* (*entryPoint)(IStatus*, FB_BOOLEAN*, IUdrPlugin*);
258 - if (!module->findSymbol(STRINGIZE(FB_UDR_PLUGIN_ENTRY_POINT), entryPoint))
260 - static const ISC_STATUS statusVector[] = {
261 - isc_arg_gds, isc_random,
262 - isc_arg_string, (ISC_STATUS) "UDR plugin entry point not found",
263 - isc_arg_end
264 - };
265 + static ISC_STATUS_ARRAY statusArray = {
266 + isc_arg_gds, isc_random,
267 + isc_arg_string, (ISC_STATUS) "UDR module not loaded",
268 + isc_arg_end
269 + };
270 + const unsigned ARG_END = 4;
272 - throw FbException(status, statusVector);
274 + ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(&statusArray[ARG_END], path);
275 + if (!module)
276 + throw FbException(status, statusArray);
278 - UdrPluginImpl* udrPlugin = FB_NEW UdrPluginImpl(*moduleName, module);
279 - udrPlugin->theirUnloadFlag = entryPoint(status, &udrPlugin->myUnloadFlag, udrPlugin);
280 + FB_BOOLEAN* (*entryPoint)(IStatus*, FB_BOOLEAN*, IUdrPlugin*);
282 - if (status->getState() & IStatus::STATE_ERRORS)
284 - delete udrPlugin;
285 - ThrowStatusWrapper::checkException(status);
288 - modules->put(*moduleName, udrPlugin);
290 - return udrPlugin;
292 - else
293 + if (!module->findSymbol(STRINGIZE(FB_UDR_PLUGIN_ENTRY_POINT), entryPoint))
295 static const ISC_STATUS statusVector[] = {
296 isc_arg_gds, isc_random,
297 - isc_arg_string, (ISC_STATUS) "Module not found",
298 - //// TODO: isc_arg_gds, isc_random, isc_arg_string, (ISC_STATUS) moduleName->c_str(),
299 + isc_arg_string, (ISC_STATUS) "UDR plugin entry point not found",
300 isc_arg_end
303 throw FbException(status, statusVector);
306 + UdrPluginImpl* udrPlugin = FB_NEW UdrPluginImpl(*moduleName, module);
307 + udrPlugin->theirUnloadFlag = entryPoint(status, &udrPlugin->myUnloadFlag, udrPlugin);
309 + if (status->getState() & IStatus::STATE_ERRORS)
311 + delete udrPlugin;
312 + ThrowStatusWrapper::checkException(status);
315 + modules->put(*moduleName, udrPlugin);
317 + return udrPlugin;
320 static const ISC_STATUS statusVector[] = {
321 diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp
322 index 9b99080c0c..dc2bc0c9bc 100644
323 --- a/src/remote/remote.cpp
324 +++ b/src/remote/remote.cpp
325 @@ -1335,7 +1335,7 @@ namespace {
326 #else
327 const char* name = "libz." SHRLIB_EXT ".1";
328 #endif
329 - z.reset(ModuleLoader::fixAndLoadModule(name));
330 + z.reset(ModuleLoader::fixAndLoadModule(NULL, name));
331 if (z)
332 symbols();
334 diff --git a/src/yvalve/PluginManager.cpp b/src/yvalve/PluginManager.cpp
335 index b0067a0c36..2875f62983 100644
336 --- a/src/yvalve/PluginManager.cpp
337 +++ b/src/yvalve/PluginManager.cpp
338 @@ -928,24 +928,27 @@ namespace
339 RefPtr<PluginModule> PluginSet::loadModule(const PluginLoadInfo& info)
341 PathName fixedModuleName(info.curModule);
342 + ISC_STATUS_ARRAY statusArray;
344 - ModuleLoader::Module* module = ModuleLoader::loadModule(fixedModuleName);
345 + ModuleLoader::Module* module = ModuleLoader::loadModule(statusArray, fixedModuleName);
347 if (!module && !ModuleLoader::isLoadableModule(fixedModuleName))
349 ModuleLoader::doctorModuleExtension(fixedModuleName);
350 - module = ModuleLoader::loadModule(fixedModuleName);
351 + module = ModuleLoader::loadModule(statusArray, fixedModuleName);
354 if (!module)
356 if (ModuleLoader::isLoadableModule(fixedModuleName))
358 - loadError(Arg::Gds(isc_pman_module_bad) << fixedModuleName);
359 + loadError(Arg::Gds(isc_pman_module_bad) << fixedModuleName <<
360 + Arg::StatusVector(statusArray));
362 if (info.required)
364 - loadError(Arg::Gds(isc_pman_module_notfound) << fixedModuleName);
365 + loadError(Arg::Gds(isc_pman_module_notfound) << fixedModuleName <<
366 + Arg::StatusVector(statusArray));
369 return RefPtr<PluginModule>(NULL);
371 From 4df43606a293ff3a9a6883a638b4559375449055 Mon Sep 17 00:00:00 2001
372 From: AlexPeshkoff <alexander.peshkoff@gmail.com>
373 Date: Tue, 18 Sep 2018 10:33:18 +0300
374 Subject: [PATCH] Backported CORE-5764: Installation of Firebird 3.0.3 on SLES
375 12 SP3 fails with "Could not find acceptable ICU library"
378 src/common/unicode_util.cpp | 75 +++++++++++++++++--------------------
379 1 file changed, 34 insertions(+), 41 deletions(-)
381 diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp
382 index a33f495910..d24eba9432 100644
383 --- a/src/common/unicode_util.cpp
384 +++ b/src/common/unicode_util.cpp
385 @@ -50,9 +50,6 @@
386 # include <unicode/utf_old.h>
387 #endif
389 -// The next major ICU version after 4.8 is 49.
390 -#define ICU_NEW_VERSION_MEANING 49
393 using namespace Firebird;
395 @@ -122,7 +119,7 @@ struct BaseICU
397 namespace Jrd {
399 -static void formatFilename(PathName& filename, const char* templateName,
400 +static ModuleLoader::Module* formatAndLoad(const char* templateName,
401 int majorVersion, int minorVersion);
404 @@ -230,10 +227,7 @@ class ImplementConversionICU : public UnicodeUtil::ConversionICU, BaseICU
405 ImplementConversionICU(int aMajorVersion, int aMinorVersion)
406 : BaseICU(aMajorVersion, aMinorVersion)
408 - PathName filename;
409 - formatFilename(filename, ucTemplate, aMajorVersion, aMinorVersion);
411 - module = ModuleLoader::fixAndLoadModule(NULL, filename);
412 + module = formatAndLoad(ucTemplate, aMajorVersion, aMinorVersion);
413 if (!module)
414 return;
416 @@ -343,16 +337,27 @@ static const char* const COLL_30_VERSION = "41.128.4.4"; // ICU 3.0 collator ver
417 static GlobalPtr<UnicodeUtil::ICUModules> icuModules;
420 -static void formatFilename(PathName& filename, const char* templateName,
421 +static ModuleLoader::Module* formatAndLoad(const char* templateName,
422 int majorVersion, int minorVersion)
424 - string s;
425 - if (majorVersion >= ICU_NEW_VERSION_MEANING)
426 - s.printf("%d", majorVersion);
427 - else
428 - s.printf("%d%d", majorVersion, minorVersion);
429 + // ICU has several schemas for placing version into file name
430 + const char* patterns[] =
432 + "%d", "%d_%d", "%d%d", NULL
433 + };
435 + PathName s, filename;
436 + for (const char** p = patterns; *p; ++p)
438 + s.printf(*p, majorVersion, minorVersion);
439 + filename.printf(templateName, s.c_str());
441 - filename.printf(templateName, s.c_str());
442 + ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(NULL, filename);
443 + if (module)
444 + return module;
447 + return NULL;
451 @@ -975,17 +980,14 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
452 continue;
454 string configVersion;
456 - if (majorVersion >= ICU_NEW_VERSION_MEANING)
457 + configVersion.printf("%d.%d", majorVersion, minorVersion);
458 + if (version != configVersion)
460 minorVersion = 0;
461 configVersion.printf("%d", majorVersion);
462 + if (version != configVersion)
463 + continue;
465 - else
466 - configVersion.printf("%d.%d", majorVersion, minorVersion);
468 - if (version != configVersion)
469 - continue;
471 ReadLockGuard readGuard(icuModules->lock, "UnicodeUtil::loadICU");
473 @@ -993,27 +995,19 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
474 if (icuModules->modules.get(version, icu))
475 return icu;
477 - PathName filename;
478 - formatFilename(filename, ucTemplate, majorVersion, minorVersion);
480 icu = FB_NEW_POOL(*getDefaultMemoryPool()) ICU(majorVersion, minorVersion);
482 - icu->ucModule = ModuleLoader::fixAndLoadModule(NULL, filename);
484 + icu->ucModule = formatAndLoad(ucTemplate, majorVersion, minorVersion);
485 if (!icu->ucModule)
487 - gds__log("failed to load module %s", filename.c_str());
488 + gds__log("failed to load UC icu module version %s", configVersion.c_str());
489 delete icu;
490 continue;
493 - formatFilename(filename, inTemplate, majorVersion, minorVersion);
495 - icu->inModule = ModuleLoader::fixAndLoadModule(NULL, filename);
497 + icu->inModule = formatAndLoad(inTemplate, majorVersion, minorVersion);
498 if (!icu->inModule)
500 - gds__log("failed to load module %s", filename.c_str());
501 + gds__log("failed to load IN icu module version %s", configVersion.c_str());
502 delete icu;
503 continue;
505 @@ -1138,26 +1132,25 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU()
506 LocalStatus ls;
507 CheckStatusWrapper lastError(&ls);
508 string version;
509 - const int majorArray[] = {5, 4, 3, 6, 0};
511 - for (const int* major = majorArray; *major; ++major)
512 + for (int major = 4; major <= 79; ++major)
514 for (int minor = 20; minor--; ) // from 19 down to 0
516 - if ((*major == favMaj) && (minor == favMin))
517 + if ((major == favMaj) && (minor == favMin))
519 continue;
524 - if ((convIcu = ImplementConversionICU::create(*major, minor)))
525 + if ((convIcu = ImplementConversionICU::create(major, minor)))
526 return *convIcu;
528 catch (const Exception& ex)
530 ex.stuffException(&lastError);
531 - version.printf("Error loading ICU library version %d.%d", *major, minor);
532 + version.printf("Error loading ICU library version %d.%d", major, minor);
536 @@ -1180,7 +1173,7 @@ string UnicodeUtil::getDefaultIcuVersion()
537 string rc;
538 UnicodeUtil::ConversionICU& icu(UnicodeUtil::getConversionICU());
540 - if (icu.vMajor >= ICU_NEW_VERSION_MEANING)
541 + if (icu.vMajor >= 10 && icu.vMinor == 0)
542 rc.printf("%d", icu.vMajor);
543 else
544 rc.printf("%d.%d", icu.vMajor, icu.vMinor);
545 @@ -1425,7 +1418,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
546 UErrorCode status = U_ZERO_ERROR;
547 int len = icu->usetGetItem(contractions, i, NULL, NULL, str, sizeof(str), &status);
549 - if (len > srcLenLong)
550 + if (len > SLONG(srcLenLong))
551 len = srcLenLong;
552 else
553 --len;